Fix most remaining release warnings (#1243)

Bug: #1003
This commit is contained in:
Fabrice de Gans 2024-03-11 18:56:01 -07:00 committed by GitHub
parent 18b97b4342
commit 07e490254c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 109 additions and 129 deletions

View File

@ -28,8 +28,6 @@ Effects_Buffer::Effects_Buffer( int max_bufs, long echo_size_ ) : Multi_Buffer(
echo_size = max( max_read * (long) stereo, echo_size_ & ~1 );
clock_rate_ = 0;
bass_freq_ = 90;
bufs = 0;
bufs_size = 0;
bufs_max = max( max_bufs, (int) extra_chans );
no_echo = true;
no_effects = true;
@ -59,24 +57,13 @@ Effects_Buffer::~Effects_Buffer()
// avoid using new []
blargg_err_t Effects_Buffer::new_bufs( int size )
{
bufs = (buf_t*) malloc( size * sizeof *bufs );
CHECK_ALLOC( bufs );
for ( int i = 0; i < size; i++ )
new (bufs + i) buf_t;
bufs_size = size;
bufs = std::vector<buf_t>( size );
return 0;
}
void Effects_Buffer::delete_bufs()
{
if ( bufs )
{
for ( int i = bufs_size; --i >= 0; )
bufs [i].~buf_t();
free( bufs );
bufs = 0;
}
bufs_size = 0;
bufs.clear();
}
blargg_err_t Effects_Buffer::set_sample_rate( long rate, int msec )
@ -90,15 +77,15 @@ blargg_err_t Effects_Buffer::set_sample_rate( long rate, int msec )
void Effects_Buffer::clock_rate( long rate )
{
clock_rate_ = rate;
for ( int i = bufs_size; --i >= 0; )
bufs [i].clock_rate( clock_rate_ );
for ( auto& buf : bufs )
buf.clock_rate( clock_rate_ );
}
void Effects_Buffer::bass_freq( int freq )
{
bass_freq_ = freq;
for ( int i = bufs_size; --i >= 0; )
bufs [i].bass_freq( bass_freq_ );
for ( auto& buf : bufs )
buf.bass_freq( bass_freq_ );
}
blargg_err_t Effects_Buffer::set_channel_count( int count, int const* types )
@ -113,8 +100,8 @@ blargg_err_t Effects_Buffer::set_channel_count( int count, int const* types )
RETURN_ERR( new_bufs( min( bufs_max, count + extra_chans ) ) );
for ( int i = bufs_size; --i >= 0; )
RETURN_ERR( bufs [i].set_sample_rate( sample_rate(), length() ) );
for ( auto& buf : bufs )
RETURN_ERR( buf.set_sample_rate( sample_rate(), length() ) );
for ( int i = chans.size(); --i >= 0; )
{
@ -149,8 +136,8 @@ void Effects_Buffer::clear()
s.low_pass [1] = 0;
mixer.samples_read = 0;
for ( int i = bufs_size; --i >= 0; )
bufs [i].clear();
for ( auto& buf : bufs )
buf.clear();
clear_echo();
}
@ -246,7 +233,7 @@ void Effects_Buffer::apply_config()
{
int i;
if ( !bufs_size )
if ( bufs.empty() )
return;
s.treble = TO_FIXED( config_.treble );
@ -427,8 +414,8 @@ void Effects_Buffer::assign_buffers()
void Effects_Buffer::end_frame( blip_time_t time )
{
for ( int i = bufs_size; --i >= 0; )
bufs [i].end_frame( time );
for ( auto& buf : bufs )
buf.end_frame( time );
}
long Effects_Buffer::read_samples( blip_sample_t* out, long out_size )
@ -476,14 +463,13 @@ long Effects_Buffer::read_samples( blip_sample_t* out, long out_size )
if ( samples_avail() <= 0 || immediate_removal() )
{
for ( int i = bufs_size; --i >= 0; )
for ( buf_t& buf : bufs )
{
buf_t& b = bufs [i];
// TODO: might miss non-silence settling since it checks END of last read
if ( b.non_silent() )
b.remove_samples( mixer.samples_read );
if ( buf.non_silent() )
buf.remove_samples( mixer.samples_read );
else
b.remove_silence( mixer.samples_read );
buf.remove_silence( mixer.samples_read );
}
mixer.samples_read = 0;
}
@ -501,8 +487,8 @@ void Effects_Buffer::mix_effects( blip_sample_t* out_, int pair_count )
{
// mix any modified buffers
{
buf_t* buf = bufs;
int bufs_remain = bufs_size;
buf_t* buf = bufs.data();
int bufs_remain = bufs.size();
do
{
if ( buf->non_silent() && ( buf->echo == !!echo_phase ) )

View File

@ -4,6 +4,8 @@
#ifndef EFFECTS_BUFFER_H
#define EFFECTS_BUFFER_H
#include <vector>
#include "Multi_Buffer.h"
// See Simple_Effects_Buffer (below) for a simpler interface
@ -94,21 +96,8 @@ class Effects_Buffer : public Multi_Buffer
struct buf_t : Tracked_Blip_Buffer {
fixed_t vol[stereo];
bool echo;
void *operator new(size_t, void *p)
{
return p;
}
void operator delete(void *)
{
}
~buf_t()
{
}
};
buf_t *bufs;
int bufs_size;
std::vector<buf_t> bufs;
int bufs_max; // bufs_size <= bufs_max, to limit memory usage
Stereo_Mixer mixer;

View File

@ -89,7 +89,7 @@ unsigned dictionary_hash(const char *key)
{
size_t len;
unsigned hash;
int i;
size_t i;
len = strlen(key);
for (hash = 0, i = 0; i < len; i++) {

View File

@ -4,6 +4,25 @@
#define STREAM_PIXEL_FORMAT AV_PIX_FMT_YUV420P
#define IN_SOUND_FORMAT AV_SAMPLE_FMT_S16
namespace {
// Wrapper around an AVPacket that frees the underlying packet on destruction.
class ScopedAVPacket {
public:
ScopedAVPacket() : av_packet_(av_packet_alloc()) {}
~ScopedAVPacket() {
av_packet_free(&av_packet_);
}
AVPacket* operator->() { return av_packet_; }
AVPacket* get() { return av_packet_; }
private:
AVPacket* av_packet_;
};
} // namespace
struct supportedCodecs {
AVCodecID codecId;
char const *longName;
@ -377,10 +396,9 @@ recording::MediaRet recording::MediaRecorder::AddFrame(const uint8_t *vid)
if (!isRecording) return MRET_OK;
// fill and encode frame variables
int got_packet = 0, ret = 0;
AVPacket pkt;
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
ScopedAVPacket pkt;
pkt->data = NULL;
pkt->size = 0;
// fill frame with current pic
ret = av_image_fill_arrays(frameIn->data, frameIn->linesize,
(uint8_t *)vid + tbord * (linesize + pixsize * rbord),
@ -393,17 +411,17 @@ recording::MediaRet recording::MediaRecorder::AddFrame(const uint8_t *vid)
// set valid pts for frame
frameOut->pts = npts++;
// finally, encode frame
got_packet = avcodec_receive_packet(enc, &pkt);
got_packet = avcodec_receive_packet(enc, pkt.get());
ret = avcodec_send_frame(enc, frameOut);
if (ret < 0) return MRET_ERR_RECORDING;
if (!got_packet)
{
// rescale output packet timestamp values from codec
// to stream timebase
av_packet_rescale_ts(&pkt, enc->time_base, st->time_base);
pkt.stream_index = st->index;
//log_packet(oc, &pkt);
ret = av_interleaved_write_frame(oc, &pkt);
av_packet_rescale_ts(pkt.get(), enc->time_base, st->time_base);
pkt->stream_index = st->index;
//log_packet(oc, pkt.get());
ret = av_interleaved_write_frame(oc, pkt.get());
if (ret < 0) return MRET_ERR_RECORDING;
}
return MRET_OK;
@ -584,10 +602,9 @@ recording::MediaRet recording::MediaRecorder::AddFrame(const uint16_t *aud, int
}
int got_packet;
AVPacket pkt;
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
ScopedAVPacket pkt;
pkt->data = NULL;
pkt->size = 0;
if (avcodec_fill_audio_frame(audioframeTmp, c->channels, IN_SOUND_FORMAT, (const uint8_t *)audioBuffer, samples_size, 1) < 0)
{
@ -604,17 +621,17 @@ recording::MediaRet recording::MediaRecorder::AddFrame(const uint16_t *aud, int
audioframe->pts = av_rescale_q(samplesCount, {1, c->sample_rate}, c->time_base);
samplesCount += dst_nb_samples;
got_packet = avcodec_receive_packet(c, &pkt);
got_packet = avcodec_receive_packet(c, pkt.get());
if (avcodec_send_frame(c, audioframe) < 0)
{
return MRET_ERR_RECORDING;
}
if (!got_packet)
{
av_packet_rescale_ts(&pkt, { 1, c->sample_rate }, ast->time_base);
pkt.stream_index = ast->index;
//log_packet(oc, &pkt);
if (av_interleaved_write_frame(oc, &pkt) < 0)
av_packet_rescale_ts(pkt.get(), { 1, c->sample_rate }, ast->time_base);
pkt->stream_index = ast->index;
//log_packet(oc, pkt.get());
if (av_interleaved_write_frame(oc, pkt.get()) < 0)
{
return MRET_ERR_RECORDING;
}
@ -637,11 +654,10 @@ recording::MediaRet recording::MediaRecorder::AddFrame(const uint16_t *aud, int
// "X frames left in the queue on closing"
void recording::MediaRecorder::flush_frames()
{
AVPacket pkt;
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
ScopedAVPacket pkt;
pkt->data = NULL;
pkt->size = 0;
// flush last audio frames
while (avcodec_receive_packet(aenc, &pkt) >= 0)
while (avcodec_receive_packet(aenc, pkt.get()) >= 0)
avcodec_send_frame(aenc, NULL);
}

View File

@ -428,7 +428,7 @@ void blendPixel(const Kernel_3x3& ker,
return true;
//make sure there is no second blending in an adjacent rotation for this pixel: handles insular pixels, mario eyes
if (getTopR(blend) != BLEND_NONE && !eq(e, g)) //but support double-blending for 90° corners
if (getTopR(blend) != BLEND_NONE && !eq(e, g)) //but support double-blending for 90<EFBFBD> corners
return false;
if (getBottomL(blend) != BLEND_NONE && !eq(e, c))
return false;
@ -1019,7 +1019,7 @@ struct Scaler6x : public ColorGradient
struct ColorDistanceRGB
{
static double dist(uint32_t pix1, uint32_t pix2, double luminanceWeight)
static double dist(uint32_t pix1, uint32_t pix2, double /* luminanceWeight */)
{
return distYCbCrBuffered(pix1, pix2);
@ -1031,7 +1031,7 @@ struct ColorDistanceRGB
struct ColorDistanceARGB
{
static double dist(uint32_t pix1, uint32_t pix2, double luminanceWeight)
static double dist(uint32_t pix1, uint32_t pix2, double /* luminanceWeight */)
{
const double a1 = getAlpha(pix1) / 255.0 ;
const double a2 = getAlpha(pix2) / 255.0 ;

View File

@ -3392,7 +3392,7 @@ static bool gbReadSaveState(gzFile gzFile)
ub = utilReadInt(gzFile) ? true : false;
ib = utilReadInt(gzFile) ? true : false;
if ((ub != coreOptions.useBios) && (ib)) {
if ((ub != (bool)(coreOptions.useBios)) && (ib)) {
if (coreOptions.useBios)
systemMessage(MSG_SAVE_GAME_NOT_USING_BIOS,
N_("Save game is not using the BIOS files"));

View File

@ -692,21 +692,20 @@ uint8_t parseExpressionType(char* given_type)
}
if ((type[0] == 'S') || type[0] == 'U') {
flags |= (4 - ((type[0] - 'S') << 1));
type++;
if (type[0] == 'H') {
type[0] = '1';
type[1] = '6';
if (type[1] == 'H') {
type[1] = '1';
type[2] = '6';
type[3] = '\0';
} else if (type[1] == 'W') {
type[1] = '3';
type[2] = '2';
type[3] = '\0';
} else if (type[1] == 'B') {
type[1] = '8';
type[2] = '\0';
} else if (type[0] == 'W') {
type[0] = '3';
type[1] = '2';
type[2] = '\0';
} else if (type[0] == 'B') {
type[0] = '8';
type[1] = '\0';
}
int size;
sscanf(type, "%d", &size);
sscanf(type + 1, "%d", &size);
size = (size >> 3) - 1;
flags |= (size >= 2 ? 2 : ((uint8_t)size));
free(type);

View File

@ -1689,7 +1689,7 @@ int CPULoadRomData(const char* data, int size)
void doMirroring(bool b)
{
if (romSize > k32MiB)
if (static_cast<size_t>(romSize) > k32MiB)
return;
int romSizeRounded = romSize;

View File

@ -1,6 +1,6 @@
// This file was written by denopqrihg
// with major changes by tjm
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <string>
@ -36,8 +36,8 @@ const char* MakeInstanceFilename(const char* Input)
#ifndef NO_LINK
enum {
SENDING = false,
RECEIVING = true
SENDING = 0,
RECEIVING = 1
};
enum siocnt_lo_32bit {
@ -472,7 +472,7 @@ static const int trtimeend[3][4] = {
// Hodgepodge
static uint8_t tspeed = 3;
static bool transfer_direction = false;
static int transfer_direction = 0;
static uint16_t linkid = 0;
#if (defined __WIN32__ || defined _WIN32)
static HANDLE linksync[4];
@ -2451,7 +2451,8 @@ static void UpdateRFUSocket(int ticks)
rfu_client.Recv(); // recv broadcast data
}
{
for (int i = 0; i < MAX_CLIENTS; i++) {
const int max_clients = MAX_CLIENTS > 5 ? 5 : MAX_CLIENTS;
for (int i = 0; i < max_clients; i++) {
if (i != linkid) {
rfu_data.rfu_listback[i] = 0; // Flush the queue
}

View File

@ -543,7 +543,8 @@ static inline void CPUWriteMemory(uint32_t address, uint32_t value)
(*cpuSaveGameFunc)(address, (uint8_t)value);
break;
}
// default
goto unwritable;
// fallthrough
default:
unwritable:
#ifdef GBA_LOGGING
@ -802,6 +803,7 @@ static inline void CPUWriteByte(uint32_t address, uint8_t b)
(*cpuSaveGameFunc)(address, b);
break;
}
goto unwritable;
// default
default:
unwritable:

View File

@ -1,7 +1,8 @@
#include <string.h>
#include "Sound.h"
#include <array>
#include <cstring>
#include "../Util.h"
#include "../common/Port.h"
#include "GBA.h"
@ -769,18 +770,22 @@ static void soundReadGameOld(gzFile in, int version)
skip_read(in, 6 * 735 + 2 * 735);
// Copy APU regs
static int const regs_to_copy[] = {
static constexpr std::array<int, 21> regs_to_copy {
NR10, NR11, NR12, NR13, NR14,
NR21, NR22, NR23, NR24,
NR30, NR31, NR32, NR33, NR34,
NR41, NR42, NR43, NR44,
NR50, NR51, NR52, -1
NR50, NR51, NR52,
};
g_ioMem[NR52] |= 0x80; // old sound played even when this wasn't set (power on)
for (int i = 0; regs_to_copy[i] >= 0; i++)
state.apu.regs[gba_to_gb_sound(regs_to_copy[i]) - 0xFF10] = g_ioMem[regs_to_copy[i]];
for (const int gba_reg: regs_to_copy) {
const int gb_reg = gba_to_gb_sound(gba_reg);
if (gb_reg >= 0xFF10) {
state.apu.regs[gb_reg - 0xFF10] = g_ioMem[gba_reg];
}
}
// Copy wave RAM to both banks
memcpy(&state.apu.regs[0x20], &g_ioMem[0x90], 0x10);

View File

@ -239,8 +239,8 @@ int sdlMirroringEnable = 1;
void systemConsoleMessage(const char*);
char* home;
char homeConfigDir[1024];
char homeDataDir[1024];
char homeConfigDir[1024] = "";
char homeDataDir[1024] = "";
bool screenMessage = false;
char screenMessageBuffer[21];
@ -399,7 +399,7 @@ FILE* sdlFindFile(const char* name)
return f;
}
if (homeDataDir) {
if (strlen(homeDataDir)) {
fprintf(stdout, "Searching home directory: %s\n", homeDataDir);
sprintf(path, "%s%c%s", homeDataDir, FILE_SEP, name);
f = fopen(path, "r");

View File

@ -18,10 +18,8 @@
#include "config/option.h"
#include "dialogs/validated-child.h"
#include "rpi.h"
#include "wayland.h"
#include "widgets/option-validator.h"
#include "widgets/render-plugin.h"
#include "widgets/wx/wxmisc.h"
#include "wxvbam.h"
namespace dialogs {

View File

@ -88,22 +88,22 @@ bool wxCheckedListCtrl::Init()
wxMemoryDC renderer_dc;
// Unchecked
renderer_dc.SelectObject(unchecked_bmp);
renderer_dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID));
renderer_dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxBRUSHSTYLE_SOLID));
renderer_dc.Clear();
wxRendererNative::Get().DrawCheckBox(this, renderer_dc, wxRect(0, 0, 16, 16), 0);
// Checked
renderer_dc.SelectObject(checked_bmp);
renderer_dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID));
renderer_dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxBRUSHSTYLE_SOLID));
renderer_dc.Clear();
wxRendererNative::Get().DrawCheckBox(this, renderer_dc, wxRect(0, 0, 16, 16), wxCONTROL_CHECKED);
// Unchecked and Disabled
renderer_dc.SelectObject(unchecked_disabled_bmp);
renderer_dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID));
renderer_dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxBRUSHSTYLE_SOLID));
renderer_dc.Clear();
wxRendererNative::Get().DrawCheckBox(this, renderer_dc, wxRect(0, 0, 16, 16), 0 | wxCONTROL_DISABLED);
// Checked and Disabled
renderer_dc.SelectObject(checked_disabled_bmp);
renderer_dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID));
renderer_dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxBRUSHSTYLE_SOLID));
renderer_dc.Clear();
wxRendererNative::Get().DrawCheckBox(this, renderer_dc, wxRect(0, 0, 16, 16), wxCONTROL_CHECKED | wxCONTROL_DISABLED);
}

View File

@ -40,24 +40,6 @@
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBUPDATE, wxEVT_COMMAND_LIST_ITEM_CHECKED, -1);
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBUPDATE, wxEVT_COMMAND_LIST_ITEM_UNCHECKED, -1);
#define EVT_LIST_ITEM_CHECKED(id, fn) \
DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_LIST_ITEM_CHECKED, \
id, \
-1, \
(wxObjectEventFunction)(wxEventFunction)( \
wxListEventFunction)&fn, \
(wxObject*)NULL) \
,
#define EVT_LIST_ITEM_UNCHECKED(id, fn) \
DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_LIST_ITEM_UNCHECKED, \
id, \
-1, \
(wxObjectEventFunction)(wxEventFunction)( \
wxListEventFunction)&fn, \
(wxObject*)NULL) \
,
//! This is the class which performs all transactions with the server.
//! It uses the wxSocket facilities.
class WXDLLIMPEXP_WEBUPDATE wxCheckedListCtrl : public wxListCtrl {

View File

@ -308,7 +308,9 @@ wxString wxvbamApp::GetAbsolutePath(wxString path)
if (fn.IsRelative()) {
fn.MakeRelativeTo(GetConfigurationPath());
fn.Normalize();
fn.Normalize(wxPATH_NORM_ENV_VARS | wxPATH_NORM_DOTS | wxPATH_NORM_TILDE |
wxPATH_NORM_CASE | wxPATH_NORM_ABSOLUTE | wxPATH_NORM_LONG |
wxPATH_NORM_SHORTCUT);
return fn.GetFullPath();
}

View File

@ -265,7 +265,7 @@ public:
void ResetMenuAccelerators();
// 2.8 has no HasFocus(), and FindFocus() doesn't work right
bool HasFocus() const
bool HasFocus() const override
{
return focused;
}