Skip to content

Commit

Permalink
Merge pull request #865 from edge-classic/cppcheck-fixes
Browse files Browse the repository at this point in the history
Fix various issues identified by cppcheck
  • Loading branch information
pbdot authored Jan 28, 2025
2 parents e639e09 + ebe4c55 commit b763ee0
Show file tree
Hide file tree
Showing 104 changed files with 504 additions and 502 deletions.
2 changes: 2 additions & 0 deletions libraries/fluidlite/src/fluid_voice.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,8 @@ fluid_voice_write(fluid_voice_t* voice,
fluid_voice_off(voice);
}

voice->dsp_buf = NULL;

post_process:
voice->ticks += FLUID_BUFSIZE;
return FLUID_OK;
Expand Down
2 changes: 1 addition & 1 deletion libraries/opalmidi/opal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ void Opal::Port(uint16_t reg_num, uint8_t val)
{

// The 4-op channels are 0, 1, 2, 9, 10, 11
uint16_t chan = i < 3 ? i : i + 6;
uint16_t chan = i < 3 ? i : (i + 6);
Channel *primary = &Chan[chan];
Channel *secondary = &Chan[chan + 3];

Expand Down
4 changes: 2 additions & 2 deletions libraries/sokol/sokol_gfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -4425,7 +4425,7 @@ SOKOL_GFX_API_DECL const void* sg_d3d11_device(void);
// D3D11: return ID3D11DeviceContext
SOKOL_GFX_API_DECL const void* sg_d3d11_device_context(void);
// D3D11: return ID3D11DepthStencilView
SOKOL_GFX_API_DECL const void sg_d3d11_clear_depth(float value);
SOKOL_GFX_API_DECL void sg_d3d11_clear_depth(float value);
// D3D11: get internal buffer resource objects
SOKOL_GFX_API_DECL sg_d3d11_buffer_info sg_d3d11_query_buffer_info(sg_buffer buf);
// D3D11: get internal image resource objects
Expand Down Expand Up @@ -19523,7 +19523,7 @@ SOKOL_API_IMPL const void* sg_d3d11_device_context(void) {
#endif
}

SOKOL_API_IMPL const void sg_d3d11_clear_depth(float value) {
SOKOL_API_IMPL void sg_d3d11_clear_depth(float value) {
#if defined(SOKOL_D3D11)
_sg.d3d11.ctx->ClearDepthStencilView(_sg.d3d11.cur_pass.depth_stencil_view, D3D11_CLEAR_DEPTH, value, 0);
#endif
Expand Down
2 changes: 1 addition & 1 deletion libraries/xxHash/xxhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -4492,7 +4492,7 @@ XXH3_mul128_fold64(xxh_u64 lhs, xxh_u64 rhs)
XXH_FORCE_INLINE XXH_CONSTF xxh_u64 XXH_xorshift64(xxh_u64 v64, int shift)
{
XXH_ASSERT(0 <= shift && shift < 64);
return v64 ^ (v64 >> shift);
return v64 ^ (v64 >> (unsigned int)shift);
}

/*
Expand Down
6 changes: 3 additions & 3 deletions source_files/ajbsp/bsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@ void ResetInfo();

// attempt to open a wad. on failure, the FatalError method in the
// BuildInfo interface is called.
void OpenWad(std::string filename);
void OpenWad(const std::string &filename);

// attempt to open a wad from memory; only intended for the use
// of WAD files inside archives
void OpenMem(std::string filename, epi::File *memfile);
void OpenMem(const std::string &filename, epi::File *memfile);

// close a previously opened wad.
void CloseWad();

// create/finish an XWA file
void CreateXWA(std::string filename);
void CreateXWA(const std::string &filename);
void FinishXWA();

// give the number of levels detected in the wad.
Expand Down
16 changes: 8 additions & 8 deletions source_files/ajbsp/bsp_level.cc
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ void GetLinedefs()

/* ----- UDMF reading routines ------------------------- */

void ParseThingField(Thing *thing, const int &key, epi::Scanner &lex)
static void ParseThingField(Thing *thing, const int &key, const epi::Scanner &lex)
{
// Do we need more precision than an int for things? I think this would only
// be an issue if/when polyobjects happen, as I think other thing types are
Expand All @@ -484,15 +484,15 @@ void ParseThingField(Thing *thing, const int &key, epi::Scanner &lex)
thing->type = lex.state_.number;
}

void ParseVertexField(Vertex *vertex, const int &key, epi::Scanner &lex)
static void ParseVertexField(Vertex *vertex, const int &key, const epi::Scanner &lex)
{
if (key == epi::kENameX)
vertex->x_ = lex.state_.decimal;
else if (key == epi::kENameY)
vertex->y_ = lex.state_.decimal;
}

void ParseSidedefField(Sidedef *side, const int &key, epi::Scanner &lex)
static void ParseSidedefField(Sidedef *side, const int &key, const epi::Scanner &lex)
{
if (key == epi::kENameSector)
{
Expand All @@ -505,7 +505,7 @@ void ParseSidedefField(Sidedef *side, const int &key, epi::Scanner &lex)
}
}

void ParseLinedefField(Linedef *line, const int &key, epi::Scanner &lex)
static void ParseLinedefField(Linedef *line, const int &key, const epi::Scanner &lex)
{
switch (key)
{
Expand Down Expand Up @@ -992,7 +992,7 @@ void SaveXGL3Format(Lump *lump, Node *root_node)

void LoadLevel()
{
Lump *LEV = cur_wad->GetLump(level_current_start);
const Lump *LEV = cur_wad->GetLump(level_current_start);

level_current_name = LEV->Name();
level_long_name = false;
Expand Down Expand Up @@ -1201,21 +1201,21 @@ void ResetInfo()
current_build_info.split_cost = kSplitCostDefault;
}

void OpenWad(std::string filename)
void OpenWad(const std::string &filename)
{
cur_wad = WadFile::Open(filename, 'r');
if (cur_wad == nullptr)
FatalError("AJBSP: Cannot open file: %s\n", filename.c_str());
}

void OpenMem(std::string filename, epi::File *memfile)
void OpenMem(const std::string &filename, epi::File *memfile)
{
cur_wad = WadFile::OpenMem(filename, memfile);
if (cur_wad == nullptr)
FatalError("AJBSP: Cannot open file from memory: %s\n", filename.c_str());
}

void CreateXWA(std::string filename)
void CreateXWA(const std::string &filename)
{
xwa_wad = WadFile::Open(filename, 'w');
if (xwa_wad == nullptr)
Expand Down
12 changes: 6 additions & 6 deletions source_files/ajbsp/bsp_wad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,12 @@ bool Lump::Finish()
// WAD Reading Interface
//------------------------------------------------------------------------

WadFile::WadFile(std::string name, char mode, FILE *file_pointer, epi::File *memory_file_pointer)
: mode_(mode), file_pointer_(file_pointer), memory_file_pointer_(memory_file_pointer), kind_('P'), total_size_(0),
WadFile::WadFile(const std::string &name, char mode, FILE *file_pointer, epi::File *memory_file_pointer)
: filename_(name), mode_(mode), file_pointer_(file_pointer), memory_file_pointer_(memory_file_pointer), kind_('P'), total_size_(0),
directory_(), directory_start_(0), directory_count_(0), levels_(), patches_(), sprites_(), flats_(),
tx_textures_(), begun_write_(false), insert_point_(-1)
{
filename_ = name;

}

WadFile::~WadFile()
Expand All @@ -236,7 +236,7 @@ WadFile::~WadFile()
filename_.clear();
}

WadFile *WadFile::Open(std::string filename, char mode)
WadFile *WadFile::Open(const std::string &filename, char mode)
{
EPI_ASSERT(mode == 'r' || mode == 'w' || mode == 'a');

Expand Down Expand Up @@ -294,7 +294,7 @@ WadFile *WadFile::Open(std::string filename, char mode)
return w;
}

WadFile *WadFile::OpenMem(std::string filename, epi::File *memfile)
WadFile *WadFile::OpenMem(const std::string &filename, epi::File *memfile)
{
EPI_ASSERT(memfile);

Expand All @@ -314,7 +314,7 @@ WadFile *WadFile::OpenMem(std::string filename, epi::File *memfile)
return w;
}

WadFile *WadFile::Create(std::string filename, char mode)
WadFile *WadFile::Create(const std::string &filename, char mode)
{
FileMessage("Creating new WAD file: %s\n", filename.c_str());

Expand Down
8 changes: 4 additions & 4 deletions source_files/ajbsp/bsp_wad.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class WadFile
int insert_point_;

// constructor is private
WadFile(std::string name, char mode, FILE *file_pointer, epi::File *memory_file_pointer);
WadFile(const std::string &name, char mode, FILE *file_pointer, epi::File *memory_file_pointer);

public:
~WadFile();
Expand All @@ -164,9 +164,9 @@ class WadFile
// Note: if 'a' is used and the file is read-only, it will be
// silently opened in 'r' mode instead.
//
static WadFile *Open(std::string filename, char mode = 'a');
static WadFile *Open(const std::string &filename, char mode = 'a');

static WadFile *OpenMem(std::string filename, epi::File *memfile);
static WadFile *OpenMem(const std::string &filename, epi::File *memfile);

bool IsReadOnly() const
{
Expand Down Expand Up @@ -235,7 +235,7 @@ class WadFile
void InsertPoint(int index = -1);

private:
static WadFile *Create(std::string filename, char mode);
static WadFile *Create(const std::string &filename, char mode);

// read the existing directory.
void ReadDirectory();
Expand Down
2 changes: 1 addition & 1 deletion source_files/coal/c_compile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include "epi.h"
#include "stb_sprintf.h"

extern void FatalError(const char *error, ...);
[[noreturn]] extern void FatalError(const char *error, ...);

namespace coal
{
Expand Down
2 changes: 1 addition & 1 deletion source_files/coal/c_execute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include "epi.h"
#include "stb_sprintf.h"

extern void FatalError(const char *error, ...);
[[noreturn]] extern void FatalError(const char *error, ...);

namespace coal
{
Expand Down
2 changes: 1 addition & 1 deletion source_files/ddf/ddf_anim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ AnimationDefinition::AnimationDefinition() : name_(), pics_()
//
// Copies all the detail with the exception of ddf info
//
void AnimationDefinition::CopyDetail(AnimationDefinition &src)
void AnimationDefinition::CopyDetail(const AnimationDefinition &src)
{
type_ = src.type_;
pics_ = src.pics_;
Expand Down
2 changes: 1 addition & 1 deletion source_files/ddf/ddf_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AnimationDefinition

public:
void Default(void);
void CopyDetail(AnimationDefinition &src);
void CopyDetail(const AnimationDefinition &src);

std::string name_;

Expand Down
2 changes: 1 addition & 1 deletion source_files/ddf/ddf_attack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ AttackDefinition::~AttackDefinition()
//
// AttackDefinition::CopyDetail()
//
void AttackDefinition::CopyDetail(AttackDefinition &src)
void AttackDefinition::CopyDetail(const AttackDefinition &src)
{
attackstyle_ = src.attackstyle_;
flags_ = src.flags_;
Expand Down
2 changes: 1 addition & 1 deletion source_files/ddf/ddf_colormap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ Colormap::~Colormap()
//
// Colormap::CopyDetail()
//
void Colormap::CopyDetail(Colormap &src)
void Colormap::CopyDetail(const Colormap &src)
{
lump_name_ = src.lump_name_;
pack_name_ = src.pack_name_;
Expand Down
2 changes: 1 addition & 1 deletion source_files/ddf/ddf_colormap.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Colormap
~Colormap();

public:
void CopyDetail(Colormap &src);
void CopyDetail(const Colormap &src);
void Default();

// Member vars...
Expand Down
2 changes: 1 addition & 1 deletion source_files/ddf/ddf_flat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ FlatDefinition::FlatDefinition() : name_()
Default();
}

void FlatDefinition::CopyDetail(FlatDefinition &src)
void FlatDefinition::CopyDetail(const FlatDefinition &src)
{
liquid_ = src.liquid_;
footstep_ = src.footstep_;
Expand Down
2 changes: 1 addition & 1 deletion source_files/ddf/ddf_flat.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class FlatDefinition

public:
void Default(void);
void CopyDetail(FlatDefinition &src);
void CopyDetail(const FlatDefinition &src);

// Member vars....
std::string name_;
Expand Down
Loading

0 comments on commit b763ee0

Please sign in to comment.