Quiet warnings about uninitialized values.

This commit is contained in:
C.W. Betts 2024-07-31 15:40:16 -06:00
parent ae5840f314
commit 1384aa62af
11 changed files with 30 additions and 29 deletions

View File

@ -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) { 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 row, col; // byte width of char
int rowsize; int rowsize;
uint8_t bit_mask = 0, byte; uint8_t bit_mask = 0, byte = 0;
uint8_t *fp; uint8_t *fp;
fp = ft->char_data[index]; fp = ft->char_data[index];

View File

@ -42,9 +42,9 @@ bool aenc_Compress(char *input_filename, char *output_filename, const int *input
FILE *in, *out; FILE *in, *out;
int32_t result; int32_t result;
int levels, samples_per_subband; int levels = 0, samples_per_subband = 0;
unsigned sample_rate, channels; unsigned sample_rate = 0, channels = 0;
float factor, volume_scale; 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, int levels_set = 0, samples_per_subband_set = 0, sample_rate_set = 0, channels_set = 0, factor_set = 0,
volume_scale_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) { 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) { } else if (!samples_per_subband_set) {
samples_per_subband = 2048 / (1 << levels); samples_per_subband = 2048 / (1 << levels);

View File

@ -622,7 +622,7 @@ bool LoadGameDialog() {
fp = fopen(pathname, "rb"); fp = fopen(pathname, "rb");
if (fp) { if (fp) {
int bm_handle; int bm_handle = -1;
int *pbm_handle; int *pbm_handle;
fclose(fp); fclose(fp);
@ -1121,11 +1121,11 @@ void SGSObjects(CFILE *fp) {
gs_WriteInt(fp, op->attach_parent_handle); gs_WriteInt(fp, op->attach_parent_handle);
if ((op->attach_ultimate_handle) && (OBJECT_HANDLE_NONE != op->attach_ultimate_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)), 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)) { 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)), 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); gs_WriteInt(fp, pm->n_attach);

View File

@ -329,7 +329,7 @@ typedef int bm_hashTableIndex; /* index into hash table */
#define compEQ(a, b) (stricmp((a)->name, (b)->name) == 0) #define compEQ(a, b) (stricmp((a)->name, (b)->name) == 0)
struct bm_Node { struct bm_Node {
struct bm_Node *next; /* next 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 bm_Node *bm_findNode(bm_T data);
static void bm_deleteNode(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 // If add_mem is nonzero, adds that to the amount alloced
// Returns bitmap handle if successful, -1 if otherwise // Returns bitmap handle if successful, -1 if otherwise
int bm_AllocBitmap(int w, int h, int add_mem) { int bm_AllocBitmap(int w, int h, int add_mem) {
int n, i; int n = 0, i;
if (!Bitmaps_initted) { if (!Bitmaps_initted) {
Int3(); Int3();
mprintf(0, "Bitmaps not initted!!!\n"); 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! // Just like bm_AllocBitmap but doesn't actually allocate memory. Useful for paging!
int bm_AllocNoMemBitmap(int w, int h) { int bm_AllocNoMemBitmap(int w, int h) {
int n, i; int n = 0, i;
if (!Bitmaps_initted) { if (!Bitmaps_initted) {
Int3(); Int3();
mprintf(0, "Bitmaps not initted!!!\n"); mprintf(0, "Bitmaps not initted!!!\n");
@ -654,7 +654,7 @@ void bm_ChangeEndName(const char *src, char *dest) {
uint32_t i, limit; uint32_t i, limit;
int last = -1; int last = -1;
int curnum = -1; int curnum = -1;
char namedest[256+16]; char namedest[256 + 16];
char path[256], ext[256], filename[256]; char path[256], ext[256], filename[256];
ddio_SplitPath(src, path, filename, ext); 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. // Saves a bitmap to a file. Saves the bitmap as an OUTRAGE_COMPRESSED_OGF.
// Returns -1 if something is wrong. // 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; int ret;
CFILE *fp; CFILE *fp;
if (!GameBitmaps[handle].used) { if (!GameBitmaps[handle].used) {

View File

@ -327,7 +327,7 @@ int bm_tga_alloc_file(CFILE *infile, char *name, int format) {
uint8_t upside_down = 0; uint8_t upside_down = 0;
uint16_t width, height; uint16_t width, height;
uint32_t pixel; uint32_t pixel;
int i, t, n, data8bit = 0, savepos; int i, t, n, data8bit = 0, savepos = 0;
int mipped = 0; int mipped = 0;
int num_mips = 1; int num_mips = 1;
int read_ok = 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 image_id_len, color_map_type, image_type, pixsize, descriptor;
uint8_t upside_down = 0; uint8_t upside_down = 0;
uint16_t width, height; uint16_t width, height;
int i, data8bit = 0, savepos; int i, data8bit = 0, savepos = 0;
int mipped = 0, file_mipped = 0; int mipped = 0, file_mipped = 0;
int num_mips = 1; int num_mips = 1;
char name[BITMAP_NAME_LEN]; char name[BITMAP_NAME_LEN];

View File

@ -913,7 +913,7 @@ void grfont_TranslateToBitmaps(int handle) {
// Font translation routines // Font translation routines
void grfont_XlateMonoChar(int bmp_handle, int x, int y, int index, tFontFileInfo *ft, int width) { void grfont_XlateMonoChar(int bmp_handle, int x, int y, int index, tFontFileInfo *ft, int width) {
int row, col; // byte width of char int row, col; // byte width of char
uint8_t bit_mask = 0, byte; uint8_t bit_mask = 0, byte = 0;
uint8_t *fp; uint8_t *fp;
fp = ft->char_data[index]; fp = ft->char_data[index];

View File

@ -362,7 +362,7 @@ int mng_CheckIfPageLocked(mngs_Pagelock *pl) {
CFILE *infile; CFILE *infile;
mngs_Pagelock testlock; mngs_Pagelock testlock;
int r, done = 0; int r = -1, done = 0;
if (!Network_up) if (!Network_up)
return 1; return 1;
@ -408,7 +408,7 @@ int mng_CheckIfPageOwned(mngs_Pagelock *pl, char *owner) {
CFILE *infile; CFILE *infile;
mngs_Pagelock testlock; mngs_Pagelock testlock;
int r, done = 0; int r = -1, done = 0;
infile = (CFILE *)cfopen(TableLockFilename, "rb"); infile = (CFILE *)cfopen(TableLockFilename, "rb");
if (infile == NULL) { if (infile == NULL) {

View File

@ -132,7 +132,7 @@ void Error(const char *fmt, ...) {
mprintf(0, "%s\n", Exit_message); mprintf(0, "%s\n", Exit_message);
#ifdef _DEBUG #ifdef _DEBUG
int answer; int answer = IDOK;
if (DebugBreak_callback_stop) if (DebugBreak_callback_stop)
(*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."); "The dialog that follows this one overflowed its text buffer. The program may crash.");
return Debug_MessageBox(os_flags, Messagebox_title, buf); return Debug_MessageBox(os_flags, Messagebox_title, buf);
} }

View File

@ -1154,7 +1154,7 @@ void SetPolymodelProperties(bsp_info *subobj, char *props) {
subobj->flags |= SOF_TURRET; 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 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] // 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; subobj->think_interval = reaction_time;
return; return;
@ -1779,7 +1779,7 @@ int ReadNewModelFile(int polynum, CFILE *infile) {
case ID_ROT_ANIM: case ID_ROT_ANIM:
case ID_ANIM: { case ID_ANIM: {
int nframes; int nframes = 0;
// mprintf(0,"ROT ANIM chunk!!!\n"); // mprintf(0,"ROT ANIM chunk!!!\n");
if (!timed) { if (!timed) {
@ -1861,7 +1861,7 @@ int ReadNewModelFile(int polynum, CFILE *infile) {
} }
case ID_POS_ANIM: { case ID_POS_ANIM: {
int nframes; int nframes = 0;
// mprintf(0,"POS ANIM chunk!!!\n"); // mprintf(0,"POS ANIM chunk!!!\n");
if (!timed) { if (!timed) {
@ -3052,7 +3052,7 @@ void FreeAllModels() {
// Inits our models array and loads our ship pof // Inits our models array and loads our ship pof
int InitModels() { int InitModels() {
for (auto & Poly_model : Poly_models) { for (auto &Poly_model : Poly_models) {
memset(&Poly_model, 0, sizeof(poly_model)); memset(&Poly_model, 0, sizeof(poly_model));
Poly_model.used = 0; Poly_model.used = 0;
} }

View File

@ -248,7 +248,7 @@ BOOL InetGetFile::IsFileReceived() {
} }
BOOL InetGetFile::IsFileError() { BOOL InetGetFile::IsFileError() {
int state; int state = FTP_STATE_INTERNAL_ERROR;
if (m_HardError) if (m_HardError)
return true; return true;
if (m_bUseHTTP) { if (m_bUseHTTP) {
@ -278,7 +278,7 @@ BOOL InetGetFile::IsFileError() {
} }
int InetGetFile::GetErrorCode() { int InetGetFile::GetErrorCode() {
int state; int state = FTP_STATE_INTERNAL_ERROR;
if (m_HardError) if (m_HardError)
return m_HardError; return m_HardError;
if (m_bUseHTTP) { if (m_bUseHTTP) {

View File

@ -1516,7 +1516,7 @@ struct guidebot_data {
float mode_time; float mode_time;
uint16_t mp_slot; // Owner's slot number 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_parented; // Buddy will not collide with parent until it isn't parented
bool f_pickup; // Marked for pickup by the owner bool f_pickup; // Marked for pickup by the owner
@ -8072,8 +8072,8 @@ void BarnSwallow::DoFrame(int me) {
case BSM_NEST: { case BSM_NEST: {
if (Game_GetTime() > memory->next_mode_time) { if (Game_GetTime() > memory->next_mode_time) {
int target; int target;
int room; int room = 0;
int me_room; int me_room = 0;
AI_Value(me, VF_GET, AIV_I_TARGET_HANDLE, &target); AI_Value(me, VF_GET, AIV_I_TARGET_HANDLE, &target);