From 1384aa62afb20d640cf152c575b661f8203a0135 Mon Sep 17 00:00:00 2001 From: "C.W. Betts" Date: Wed, 31 Jul 2024 15:40:16 -0600 Subject: [PATCH] Quiet warnings about uninitialized values. --- 2dlib/font.cpp | 2 +- AudioEncode/encoder.cpp | 9 +++++---- Descent3/gamesave.cpp | 6 +++--- bitmap/bitmain.cpp | 10 +++++----- bitmap/tga.cpp | 4 ++-- grtext/grfont.cpp | 2 +- manage/pagelock.cpp | 4 ++-- misc/error.cpp | 4 ++-- model/polymodel.cpp | 8 ++++---- netcon/inetfile/inetgetfile.cpp | 4 ++-- scripts/AIGame.cpp | 6 +++--- 11 files changed, 30 insertions(+), 29 deletions(-) diff --git a/2dlib/font.cpp b/2dlib/font.cpp index aedfd724..b4086d2e 100644 --- a/2dlib/font.cpp +++ b/2dlib/font.cpp @@ -554,7 +554,7 @@ void grFont::translate_to_surfaces(int slot) { void grFont::translate_mono_char(grSurface *sf, int x, int y, int index, gr_font_file_record *ft, int width) { int row, col; // byte width of char int rowsize; - uint8_t bit_mask = 0, byte; + uint8_t bit_mask = 0, byte = 0; uint8_t *fp; fp = ft->char_data[index]; diff --git a/AudioEncode/encoder.cpp b/AudioEncode/encoder.cpp index 2e8c2eba..3b310cfa 100644 --- a/AudioEncode/encoder.cpp +++ b/AudioEncode/encoder.cpp @@ -42,9 +42,9 @@ bool aenc_Compress(char *input_filename, char *output_filename, const int *input FILE *in, *out; int32_t result; - int levels, samples_per_subband; - unsigned sample_rate, channels; - float factor, volume_scale; + int levels = 0, samples_per_subband = 0; + unsigned sample_rate = 0, channels = 0; + float factor = 0, volume_scale = 0; int levels_set = 0, samples_per_subband_set = 0, sample_rate_set = 0, channels_set = 0, factor_set = 0, volume_scale_set = 0; @@ -105,7 +105,8 @@ bool aenc_Compress(char *input_filename, char *output_filename, const int *input } if (!levels_set && !samples_per_subband_set) { - levels = 7, samples_per_subband = 16; + levels = 7; + samples_per_subband = 16; } else if (!samples_per_subband_set) { samples_per_subband = 2048 / (1 << levels); diff --git a/Descent3/gamesave.cpp b/Descent3/gamesave.cpp index 310ec0a5..94a5b3f0 100644 --- a/Descent3/gamesave.cpp +++ b/Descent3/gamesave.cpp @@ -622,7 +622,7 @@ bool LoadGameDialog() { fp = fopen(pathname, "rb"); if (fp) { - int bm_handle; + int bm_handle = -1; int *pbm_handle; fclose(fp); @@ -1121,11 +1121,11 @@ void SGSObjects(CFILE *fp) { gs_WriteInt(fp, op->attach_parent_handle); if ((op->attach_ultimate_handle) && (OBJECT_HANDLE_NONE != op->attach_ultimate_handle)) { mprintf(0, "Object %d has an ultimate parent of %d (%d)\n", i, OBJNUM(ObjGet(op->attach_ultimate_handle)), - op->attach_parent_handle); + op->attach_parent_handle); } if ((op->attach_ultimate_handle) && (OBJECT_HANDLE_NONE != op->attach_parent_handle)) { mprintf(0, "Object %d has a parent of %d (%d)\n", i, OBJNUM(ObjGet(op->attach_parent_handle)), - op->attach_parent_handle); + op->attach_parent_handle); } gs_WriteInt(fp, pm->n_attach); diff --git a/bitmap/bitmain.cpp b/bitmap/bitmain.cpp index 6a6edfa9..34b7a7e1 100644 --- a/bitmap/bitmain.cpp +++ b/bitmap/bitmain.cpp @@ -329,7 +329,7 @@ typedef int bm_hashTableIndex; /* index into hash table */ #define compEQ(a, b) (stricmp((a)->name, (b)->name) == 0) struct bm_Node { struct bm_Node *next; /* next bm_Node */ - bm_T data; /* data stored in bm_Node */ + bm_T data; /* data stored in bm_Node */ }; static bm_Node *bm_findNode(bm_T data); static void bm_deleteNode(bm_T data); @@ -510,7 +510,7 @@ int bm_AllocateMemoryForIndex(int n, int w, int h, int add_mem) { // If add_mem is nonzero, adds that to the amount alloced // Returns bitmap handle if successful, -1 if otherwise int bm_AllocBitmap(int w, int h, int add_mem) { - int n, i; + int n = 0, i; if (!Bitmaps_initted) { Int3(); mprintf(0, "Bitmaps not initted!!!\n"); @@ -539,7 +539,7 @@ int bm_AllocBitmap(int w, int h, int add_mem) { } // Just like bm_AllocBitmap but doesn't actually allocate memory. Useful for paging! int bm_AllocNoMemBitmap(int w, int h) { - int n, i; + int n = 0, i; if (!Bitmaps_initted) { Int3(); mprintf(0, "Bitmaps not initted!!!\n"); @@ -654,7 +654,7 @@ void bm_ChangeEndName(const char *src, char *dest) { uint32_t i, limit; int last = -1; int curnum = -1; - char namedest[256+16]; + char namedest[256 + 16]; char path[256], ext[256], filename[256]; ddio_SplitPath(src, path, filename, ext); @@ -1079,7 +1079,7 @@ int bm_MakeBitmapResident(int handle) { } // Saves a bitmap to a file. Saves the bitmap as an OUTRAGE_COMPRESSED_OGF. // Returns -1 if something is wrong. -int bm_SaveFileBitmap(const std::filesystem::path& filename, int handle) { +int bm_SaveFileBitmap(const std::filesystem::path &filename, int handle) { int ret; CFILE *fp; if (!GameBitmaps[handle].used) { diff --git a/bitmap/tga.cpp b/bitmap/tga.cpp index 18c610cc..fe1c6268 100644 --- a/bitmap/tga.cpp +++ b/bitmap/tga.cpp @@ -327,7 +327,7 @@ int bm_tga_alloc_file(CFILE *infile, char *name, int format) { uint8_t upside_down = 0; uint16_t width, height; uint32_t pixel; - int i, t, n, data8bit = 0, savepos; + int i, t, n, data8bit = 0, savepos = 0; int mipped = 0; int num_mips = 1; int read_ok = 1; @@ -539,7 +539,7 @@ int bm_page_in_file(int n) { uint8_t image_id_len, color_map_type, image_type, pixsize, descriptor; uint8_t upside_down = 0; uint16_t width, height; - int i, data8bit = 0, savepos; + int i, data8bit = 0, savepos = 0; int mipped = 0, file_mipped = 0; int num_mips = 1; char name[BITMAP_NAME_LEN]; diff --git a/grtext/grfont.cpp b/grtext/grfont.cpp index e425991f..b23d551c 100644 --- a/grtext/grfont.cpp +++ b/grtext/grfont.cpp @@ -913,7 +913,7 @@ void grfont_TranslateToBitmaps(int handle) { // Font translation routines void grfont_XlateMonoChar(int bmp_handle, int x, int y, int index, tFontFileInfo *ft, int width) { int row, col; // byte width of char - uint8_t bit_mask = 0, byte; + uint8_t bit_mask = 0, byte = 0; uint8_t *fp; fp = ft->char_data[index]; diff --git a/manage/pagelock.cpp b/manage/pagelock.cpp index a8355472..5422666a 100644 --- a/manage/pagelock.cpp +++ b/manage/pagelock.cpp @@ -362,7 +362,7 @@ int mng_CheckIfPageLocked(mngs_Pagelock *pl) { CFILE *infile; mngs_Pagelock testlock; - int r, done = 0; + int r = -1, done = 0; if (!Network_up) return 1; @@ -408,7 +408,7 @@ int mng_CheckIfPageOwned(mngs_Pagelock *pl, char *owner) { CFILE *infile; mngs_Pagelock testlock; - int r, done = 0; + int r = -1, done = 0; infile = (CFILE *)cfopen(TableLockFilename, "rb"); if (infile == NULL) { diff --git a/misc/error.cpp b/misc/error.cpp index 821d0c48..935a98c0 100644 --- a/misc/error.cpp +++ b/misc/error.cpp @@ -132,7 +132,7 @@ void Error(const char *fmt, ...) { mprintf(0, "%s\n", Exit_message); #ifdef _DEBUG - int answer; + int answer = IDOK; if (DebugBreak_callback_stop) (*DebugBreak_callback_stop)(); @@ -282,4 +282,4 @@ int OutrageMessageBox(int type, const char *str, ...) { "The dialog that follows this one overflowed its text buffer. The program may crash."); return Debug_MessageBox(os_flags, Messagebox_title, buf); -} \ No newline at end of file +} diff --git a/model/polymodel.cpp b/model/polymodel.cpp index e6bf7a46..0a1e0d19 100644 --- a/model/polymodel.cpp +++ b/model/polymodel.cpp @@ -1154,7 +1154,7 @@ void SetPolymodelProperties(bsp_info *subobj, char *props) { subobj->flags |= SOF_TURRET; subobj->fov = fov_angle / 720.0f; // 720 = 360 * 2 and we want to make fov the amount we can move in either // direction it has a minimum value of (0.0) to [0.5] - subobj->rps = 1.0f / turret_spr; // convert spr to rps (rotations per second) + subobj->rps = 1.0f / turret_spr; // convert spr to rps (rotations per second) subobj->think_interval = reaction_time; return; @@ -1779,7 +1779,7 @@ int ReadNewModelFile(int polynum, CFILE *infile) { case ID_ROT_ANIM: case ID_ANIM: { - int nframes; + int nframes = 0; // mprintf(0,"ROT ANIM chunk!!!\n"); if (!timed) { @@ -1861,7 +1861,7 @@ int ReadNewModelFile(int polynum, CFILE *infile) { } case ID_POS_ANIM: { - int nframes; + int nframes = 0; // mprintf(0,"POS ANIM chunk!!!\n"); if (!timed) { @@ -3052,7 +3052,7 @@ void FreeAllModels() { // Inits our models array and loads our ship pof int InitModels() { - for (auto & Poly_model : Poly_models) { + for (auto &Poly_model : Poly_models) { memset(&Poly_model, 0, sizeof(poly_model)); Poly_model.used = 0; } diff --git a/netcon/inetfile/inetgetfile.cpp b/netcon/inetfile/inetgetfile.cpp index 3c5401bb..d3014fc2 100644 --- a/netcon/inetfile/inetgetfile.cpp +++ b/netcon/inetfile/inetgetfile.cpp @@ -248,7 +248,7 @@ BOOL InetGetFile::IsFileReceived() { } BOOL InetGetFile::IsFileError() { - int state; + int state = FTP_STATE_INTERNAL_ERROR; if (m_HardError) return true; if (m_bUseHTTP) { @@ -278,7 +278,7 @@ BOOL InetGetFile::IsFileError() { } int InetGetFile::GetErrorCode() { - int state; + int state = FTP_STATE_INTERNAL_ERROR; if (m_HardError) return m_HardError; if (m_bUseHTTP) { diff --git a/scripts/AIGame.cpp b/scripts/AIGame.cpp index ad92eab7..faddc259 100644 --- a/scripts/AIGame.cpp +++ b/scripts/AIGame.cpp @@ -1516,7 +1516,7 @@ struct guidebot_data { float mode_time; uint16_t mp_slot; // Owner's slot number - int my_player; // Owner's object reference + int my_player; // Owner's object reference bool f_parented; // Buddy will not collide with parent until it isn't parented bool f_pickup; // Marked for pickup by the owner @@ -8072,8 +8072,8 @@ void BarnSwallow::DoFrame(int me) { case BSM_NEST: { if (Game_GetTime() > memory->next_mode_time) { int target; - int room; - int me_room; + int room = 0; + int me_room = 0; AI_Value(me, VF_GET, AIV_I_TARGET_HANDLE, &target);