From a5aa8c1dff7388ed586ccc138f564667309b01b1 Mon Sep 17 00:00:00 2001 From: Bradley Bell Date: Mon, 19 Jan 2015 21:47:52 -0800 Subject: [PATCH] more warnings --- arch/ogl/gr.c | 2 +- main/cmd.c | 3 ++- main/gameseq.c | 2 +- main/gauges.c | 2 +- main/inferno.h | 12 ++++++++++++ main/menu.c | 2 +- main/newdemo.c | 46 +++++++++++++++++++++++----------------------- main/newmenu.c | 17 +++++++++-------- main/piggy.c | 6 +++--- main/state.c | 10 +++++----- main/wall.c | 4 ++-- 11 files changed, 60 insertions(+), 46 deletions(-) diff --git a/arch/ogl/gr.c b/arch/ogl/gr.c index 7aa217b8..e31028a1 100644 --- a/arch/ogl/gr.c +++ b/arch/ogl/gr.c @@ -835,7 +835,7 @@ void write_bmp(char *savename,int w,int h,unsigned char *buf){ f = PHYSFSX_openWriteBuffered(savename); - if (f>=0){ + if (f) { GLubyte targaMagic[12] = { 0, //no identification field 0,//no colormap 2,//RGB image (well, BGR, actually) diff --git a/main/cmd.c b/main/cmd.c index 1bee8e96..b228b47f 100644 --- a/main/cmd.c +++ b/main/cmd.c @@ -88,7 +88,8 @@ void cmd_execute(int argc, char **argv) for (cmd = cmd_list; cmd; cmd = cmd->next) { if (!stricmp(argv[0], cmd->name)) { con_printf(CON_DEBUG, "cmd_execute: executing %s\n", argv[0]); - return cmd->function(argc, argv); + cmd->function(argc, argv); + return; } } diff --git a/main/gameseq.c b/main/gameseq.c index 6fd7663b..1ec2537e 100644 --- a/main/gameseq.c +++ b/main/gameseq.c @@ -1007,7 +1007,7 @@ void DoEndLevelScoreGlitz(int network) #ifdef NETWORK if ( network && (Game_mode & GM_NETWORK) ) - newmenu_do2(NULL, title, c, m, (void (*))network_endlevel_poll2, 0, STARS_BACKGROUND); + newmenu_do2(NULL, title, c, m, network_endlevel_poll2, 0, STARS_BACKGROUND); else #endif // NOTE LINK TO ABOVE!!! diff --git a/main/gauges.c b/main/gauges.c index 633505f2..1fc2045b 100644 --- a/main/gauges.c +++ b/main/gauges.c @@ -2364,7 +2364,7 @@ void draw_weapon_boxes() } -void sb_draw_energy_bar(energy) +void sb_draw_energy_bar(int energy) { int erase_height, w, h, aw; char energy_str[20]; diff --git a/main/inferno.h b/main/inferno.h index 82dd7dd1..ba1a6aba 100644 --- a/main/inferno.h +++ b/main/inferno.h @@ -78,8 +78,20 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "screens.h" #include "powerup.h" #include "state.h" +#include "ai.h" +#include "bm.h" +#include "cntrlcen.h" #include "config.h" #include "controls.h" +#include "endlevel.h" +#include "gamefont.h" +#include "fireball.h" +#include "kconfig.h" +#include "laser.h" +#include "polyobj.h" +#include "songs.h" +#include "text.h" +#include "wall.h" /** diff --git a/main/menu.c b/main/menu.c index 95125657..caf68a10 100644 --- a/main/menu.c +++ b/main/menu.c @@ -1132,7 +1132,7 @@ void do_options_menu() extern int Redbook_playing; void set_redbook_volume(int volume); -WIN(static BOOL windigi_driver_off=FALSE); +WIN(static BOOL windigi_driver_off=FALSE;) void sound_menuset(int nitems, newmenu_item * items, int *last_key, int citem ) { diff --git a/main/newdemo.c b/main/newdemo.c index 80621b5a..b9358d89 100644 --- a/main/newdemo.c +++ b/main/newdemo.c @@ -221,10 +221,10 @@ PHYSFS_file *outfile = NULL; int newdemo_get_percent_done() { if ( Newdemo_state == ND_STATE_PLAYBACK ) { - return (PHYSFS_tell(infile) * 100) / Newdemo_size; + return ((unsigned int)PHYSFS_tell(infile) * 100) / Newdemo_size; } if ( Newdemo_state == ND_STATE_RECORDING ) { - return PHYSFS_tell(outfile); + return (int)PHYSFS_tell(outfile); } return 0; } @@ -264,7 +264,7 @@ void my_extract_shortpos(object *objp, shortpos *spp) int newdemo_read( void *buffer, int elsize, int nelem ) { int num_read; - num_read = PHYSFS_read(infile, buffer, elsize, nelem); + num_read = (int)PHYSFS_read(infile, buffer, elsize, nelem); if (num_read < nelem || PHYSFS_eof(infile)) nd_bad_read = -1; @@ -291,7 +291,7 @@ int newdemo_write( void *buffer, int elsize, int nelem ) frame_bytes_written += total_size; Newdemo_num_written += total_size; Assert(outfile != NULL); - num_written = PHYSFS_write(outfile, buffer, elsize, nelem); + num_written = (int)PHYSFS_write(outfile, buffer, elsize, nelem); //if ((Newdemo_num_written > Newdemo_size) && !Newdemo_no_space) { // Newdemo_no_space=1; // newdemo_stop_recording(); @@ -331,7 +331,7 @@ static void nd_write_int(int i) static void nd_write_string(char *str) { nd_write_byte(strlen(str) + 1); - newdemo_write(str, strlen(str) + 1, 1); + newdemo_write(str, (int)strlen(str) + 1, 1); } static void nd_write_fix(fix f) @@ -1642,7 +1642,7 @@ int newdemo_read_frame_information() { int done, segnum, side, objnum, soundno, angle, volume, i,shot; object *obj; - sbyte c,WhichWindow; + sbyte c = 0, WhichWindow; static sbyte saved_letter_cockpit; static sbyte saved_rearview_cockpit; object extraobj; @@ -1945,7 +1945,7 @@ int newdemo_read_frame_information() case ND_EVENT_PLAYER_ENERGY: { sbyte energy; - sbyte old_energy; + sbyte old_energy = 0; if (Newdemo_game_type >= DEMO_GAME_TYPE_D1) nd_read_byte(&old_energy); @@ -1978,7 +1978,7 @@ int newdemo_read_frame_information() case ND_EVENT_PLAYER_SHIELD: { sbyte shield; - sbyte old_shield; + sbyte old_shield = 0; if (Newdemo_game_type >= DEMO_GAME_TYPE_D1) nd_read_byte(&old_shield); @@ -2036,7 +2036,7 @@ int newdemo_read_frame_information() case ND_EVENT_PLAYER_WEAPON: { sbyte weapon_type, weapon_num; - sbyte old_weapon; + sbyte old_weapon = 0; nd_read_byte(&weapon_type); nd_read_byte(&weapon_num); @@ -2234,7 +2234,7 @@ int newdemo_read_frame_information() case ND_EVENT_MULTI_CONNECT: { sbyte pnum, new_player; - int killed_total, kills_total; + int killed_total = 0, kills_total = 0; char new_callsign[CALLSIGN_LEN+1], old_callsign[CALLSIGN_LEN+1]; nd_read_byte(&pnum); @@ -2570,7 +2570,7 @@ void newdemo_goto_end() PHYSFS_seek(infile, PHYSFS_fileLength(infile) - 12); nd_read_short(&frame_length); - loc = PHYSFS_tell(infile); + loc = (int)PHYSFS_tell(infile); if (Newdemo_game_mode & GM_MULTI) nd_read_byte(&Newdemo_players_cloaked); else @@ -2999,7 +2999,7 @@ void newdemo_playback_one_frame() void newdemo_start_recording() { - Newdemo_size = PHYSFSX_getFreeDiskSpace(); + Newdemo_size = (int)PHYSFSX_getFreeDiskSpace(); con_printf(CON_VERBOSE, "Free space = %d\n", Newdemo_size); Newdemo_size -= 100000; @@ -3112,14 +3112,14 @@ void newdemo_stop_recording() nd_write_byte(Current_level_num); nd_write_byte(ND_EVENT_EOF); - l = PHYSFS_tell(outfile); + l = (int)PHYSFS_tell(outfile); PHYSFS_close(outfile); outfile = NULL; Newdemo_state = ND_STATE_NORMAL; gr_palette_load( gr_palette ); if (filename[0] != '\0') { - int num, i = strlen(filename) - 1; + int num, i = (int)strlen(filename) - 1; char newfile[15]; while (isdigit(filename[i])) { @@ -3279,7 +3279,7 @@ void newdemo_start_playback(char * filename) Newdemo_state = ND_STATE_PLAYBACK; Newdemo_vcr_state = ND_STATE_PLAYBACK; Newdemo_old_cockpit = Cockpit_mode.intval; - Newdemo_size = PHYSFS_fileLength(infile); + Newdemo_size = (unsigned int)PHYSFS_fileLength(infile); nd_bad_read = 0; Newdemo_at_eof = 0; NewdemoFrameCount = 0; @@ -3320,7 +3320,7 @@ void newdemo_strip_frames(char *outname, int bytes_to_strip) short last_frame_length; bytes_done = 0; - total_size = PHYSFS_fileLength(infile); + total_size = (int)PHYSFS_fileLength(infile); outfile = PHYSFSX_openWriteBuffered(outname); if (outfile == NULL) { newmenu_item m[1]; @@ -3341,35 +3341,35 @@ void newdemo_strip_frames(char *outname, int bytes_to_strip) return; } newdemo_goto_end(); - trailer_start = PHYSFS_tell(infile); + trailer_start = (int)PHYSFS_tell(infile); PHYSFS_seek(infile, PHYSFS_tell(infile) + 11); bytes_back = 0; while (bytes_back < bytes_to_strip) { - loc1 = PHYSFS_tell(infile); + loc1 = (int)PHYSFS_tell(infile); //PHYSFS_seek(infile, PHYSFS_tell(infile) - 10); //nd_read_short(&last_frame_length); //PHYSFS_seek(infile, PHYSFS_tell(infile) + 8 - last_frame_length); newdemo_back_frames(1); - loc2 = PHYSFS_tell(infile); + loc2 = (int)PHYSFS_tell(infile); bytes_back += (loc1 - loc2); } PHYSFS_seek(infile, PHYSFS_tell(infile) - 10); nd_read_short(&last_frame_length); PHYSFS_seek(infile, PHYSFS_tell(infile) - 3); - stop_loc = PHYSFS_tell(infile); + stop_loc = (int)PHYSFS_tell(infile); PHYSFS_seek(infile, 0); while (stop_loc > 0) { if (stop_loc < BUF_SIZE) bytes_to_read = stop_loc; else bytes_to_read = BUF_SIZE; - read_elems = PHYSFS_read(infile, buf, 1, bytes_to_read); + read_elems = (int)PHYSFS_read(infile, buf, 1, bytes_to_read); PHYSFS_write(outfile, buf, 1, read_elems); stop_loc -= read_elems; } - stop_loc = PHYSFS_tell(outfile); + stop_loc = (int)PHYSFS_tell(outfile); PHYSFS_seek(infile, trailer_start); - while ((read_elems = PHYSFS_read(infile, buf, 1, BUF_SIZE)) != 0) + while ((read_elems = (int)PHYSFS_read(infile, buf, 1, BUF_SIZE)) != 0) PHYSFS_write(outfile, buf, 1, read_elems); PHYSFS_seek(outfile, stop_loc); PHYSFS_seek(outfile, PHYSFS_tell(infile) + 1); diff --git a/main/newmenu.c b/main/newmenu.c index fb3a969b..03c060ca 100644 --- a/main/newmenu.c +++ b/main/newmenu.c @@ -444,7 +444,7 @@ void nm_rstring( bkg * b,int w1,int x, int y, char * s ) //for text items, constantly redraw cursor (to achieve flash) void update_cursor( newmenu_item *item) { - int w,h,aw; + int w = 0, h, aw; fix time = timer_get_approx_seconds(); int x,y; char * text = item->text; @@ -472,7 +472,7 @@ void update_cursor( newmenu_item *item) void nm_string_inputbox( bkg *b, int w, int x, int y, char * text, int current ) { - int w1,h1,aw; + int w1 = 0, h1, aw; while( *text ) { gr_get_string_size(text, &w1, &h1, &aw ); @@ -600,7 +600,7 @@ int char_allowed(char c) void strip_end_whitespace( char * text ) { int i,l; - l = strlen( text ); + l = (int)strlen( text ); for (i=l-1; i>=0; i-- ) { if ( isspace(text[i]) ) text[i] = 0; @@ -697,7 +697,7 @@ int newmenu_do4( char * title, char * subtitle, int nitems, newmenu_item * item, int choice,old_choice,i,j,x,y,w,h,aw, tw, th, twidth,fm,right_offset; int k, nmenus, nothers,ScrollOffset=0,LastScrollCheck=-1,MaxDisplayable,sx,sy; grs_font * save_font; - int string_width, string_height, average_width; + int string_width, string_height = 0, average_width; int ty; bkg bg; int all_text=0; //set true if all text items @@ -1577,7 +1577,7 @@ int newmenu_do4( char * title, char * subtitle, int nitems, newmenu_item * item, choice = i + ScrollOffset; if ( item[choice].type == NM_TYPE_SLIDER ) { - char slider_text[NM_MAX_TEXT_LEN+1], *p, *s1; + char slider_text[NM_MAX_TEXT_LEN+1], *p, *s1 = NULL; int slider_width, height, aw, sleft_width, sright_width, smiddle_width; strcpy(slider_text, item[choice].saved_text); @@ -1678,7 +1678,8 @@ int newmenu_do4( char * title, char * subtitle, int nitems, newmenu_item * item, if ( ((item[choice].type==NM_TYPE_INPUT)||((item[choice].type==NM_TYPE_INPUT_MENU)&&(item[choice].group==1)) )&& (old_choice==choice) ) { if ( k==KEY_LEFT || k==KEY_BACKSP || k==KEY_PAD4 ) { - if (item[choice].value==-1) item[choice].value = strlen(item[choice].text); + if (item[choice].value == -1) + item[choice].value = (int)strlen(item[choice].text); if (item[choice].value > 0) item[choice].value--; item[choice].text[item[choice].value] = 0; @@ -3067,7 +3068,7 @@ void nm_wrap_text(char *dbuf, char *sbuf, int line_length) char *wordptr; char *tbuf; - tbuf = (char *)d_malloc(strlen(sbuf)+1); + tbuf = (char *)d_malloc((unsigned int)strlen(sbuf) + 1); strcpy(tbuf, sbuf); wordptr = strtok(tbuf, " "); @@ -3077,7 +3078,7 @@ void nm_wrap_text(char *dbuf, char *sbuf, int line_length) while (wordptr) { - col = col+strlen(wordptr)+1; + col = col + (int)strlen(wordptr) + 1; if (col >=line_length) { col = 0; sprintf(dbuf, "%s\n%s ", dbuf, wordptr); diff --git a/main/piggy.c b/main/piggy.c index da690c98..255d7d71 100644 --- a/main/piggy.c +++ b/main/piggy.c @@ -247,7 +247,7 @@ char* piggy_game_bitmap_name(grs_bitmap *bmp) { if (bmp >= GameBitmaps && bmp < &GameBitmaps[MAX_BITMAP_FILES]) { - int i = bmp-GameBitmaps; // i = (bmp - GameBitmaps) / sizeof(grs_bitmap); + int i = (int)(bmp - GameBitmaps); // i = (bmp - GameBitmaps) / sizeof(grs_bitmap); Assert (bmp == &GameBitmaps[i] && i >= 0 && i < MAX_BITMAP_FILES); return AllBitmaps[i].name; } @@ -2061,7 +2061,7 @@ void read_d1_tmap_nums_from_hog(CFILE *d1_pig) if (bitmaps_tbl_is_binary) decode_text_line((inputline)); else - while (inputline[(i=strlen(inputline))-2]=='\\') + while (inputline[(i = (int)strlen(inputline)) - 2] == '\\') cfgets(inputline+i-2,LINEBUF_SIZE-(i-2), bitmaps); // strip comments REMOVE_EOL(inputline); if (strchr(inputline, ';')!=NULL) REMOVE_COMMENTS(inputline); @@ -2207,7 +2207,7 @@ void load_d1_bitmap_replacements() if ( (p = strchr(AllBitmaps[d2_index].name, '#')) /* d2 BM is animated */ && !(bmh.dflags & DBM_FLAG_ABM) ) { /* d1 bitmap is not animated */ - int i, len = p - AllBitmaps[d2_index].name; + int i, len = (int)(p - AllBitmaps[d2_index].name); for (i = 0; i < Num_bitmap_files; i++) if (i != d2_index && ! memcmp(AllBitmaps[d2_index].name, AllBitmaps[i].name, len)) { diff --git a/main/state.c b/main/state.c index ab4ee235..1932bc2a 100644 --- a/main/state.c +++ b/main/state.c @@ -372,7 +372,7 @@ int state_get_restore_file(char * fname, int multi) // Imagine if C had a function to copy a file... int copy_file(char *old_file, char *new_file) { - sbyte *buf; + sbyte *buf = NULL; int buf_size; PHYSFS_file *in_file, *out_file; @@ -386,7 +386,7 @@ int copy_file(char *old_file, char *new_file) if (in_file == NULL) return -2; - buf_size = PHYSFS_fileLength(in_file); + buf_size = (int)PHYSFS_fileLength(in_file); while (buf_size && !(buf = d_malloc(buf_size))) buf_size /= 2; if (buf_size == 0) @@ -396,7 +396,7 @@ int copy_file(char *old_file, char *new_file) { int bytes_read; - bytes_read = PHYSFS_read(in_file, buf, 1, buf_size); + bytes_read = (int)PHYSFS_read(in_file, buf, 1, buf_size); if (bytes_read < 0) Error("Cannot read from file <%s>: %s", old_file, PHYSFS_getLastError()); @@ -949,7 +949,7 @@ int state_restore_all_sub(char *filename, int multi, int secret_restore) char org_callsign[CALLSIGN_LEN+16]; #ifdef NETWORK int found; - int nplayers; //,playid[12],mynum; + int nplayers = 0; //,playid[12],mynum; player restore_players[MAX_PLAYERS]; #endif fix old_gametime = GameTime; @@ -1132,7 +1132,7 @@ int state_restore_all_sub(char *filename, int multi, int secret_restore) if ( !between_levels ) { Do_appearance_effect = 0; // Don't do this for middle o' game stuff. - ObjectStartLocation = PHYSFS_tell(fp); + ObjectStartLocation = (int)PHYSFS_tell(fp); //Clear out all the objects from the lvl file for (segnum=0; segnum <= Highest_segment_index; segnum++) Segments[segnum].objects = -1; diff --git a/main/wall.c b/main/wall.c index fe0952e6..f0037a55 100644 --- a/main/wall.c +++ b/main/wall.c @@ -367,7 +367,7 @@ void wall_open_door(segment *seg, int side) Assert(seg->sides[side].wall_num != -1); //Opening door on illegal wall w = &Walls[seg->sides[side].wall_num]; - wall_num = w - Walls; + wall_num = (int)(w - Walls); //kill_stuck_objects(seg->sides[side].wall_num); if ((w->state == WALL_DOOR_OPENING) || //already opening @@ -736,7 +736,7 @@ void wall_close_door(segment *seg, int side) Assert(seg->sides[side].wall_num != -1); //Opening door on illegal wall w = &Walls[seg->sides[side].wall_num]; - wall_num = w - Walls; + wall_num = (int)(w - Walls); if ((w->state == WALL_DOOR_CLOSING) || //already closing (w->state == WALL_DOOR_WAITING) || //open, waiting to close (w->state == WALL_DOOR_CLOSED)) //closed -- 2.39.2