Skip to content

Commit

Permalink
fix compilation warnings with -Wall (gcc-12)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReinhardPrix committed Nov 6, 2023
1 parent 2d5cf64 commit 067fb98
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
10 changes: 6 additions & 4 deletions src/highscore.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ void
InitHighscores (void)
{
int i;
char fname[255];
const char *base = "highscores";
char fname[sizeof(ConfigDir)+strlen(base)+2];
FILE *file = NULL;

if (ConfigDir[0] != '\0')
{
sprintf (fname, "%s/highscores", ConfigDir);
sprintf (fname, "%s/%s", ConfigDir, base);
if ( (file = fopen (fname, "r")) == NULL)
DebugPrintf (0, "WARNING: no highscores file found... \n");
else
Expand Down Expand Up @@ -88,7 +89,8 @@ int
SaveHighscores (void)
{
int i;
char fname[255];
const char *base = "highscores";
char fname[sizeof(ConfigDir) + strlen(base) + 2];
FILE *file = NULL;

if (ConfigDir[0] == '\0')
Expand All @@ -97,7 +99,7 @@ SaveHighscores (void)
return (ERR);
}

sprintf (fname, "%s/highscores", ConfigDir);
sprintf (fname, "%s/%s", ConfigDir, base);
if ( (file = fopen (fname, "w")) == NULL)
{
DebugPrintf (0, "WARNING: failed to create highscores file. Giving up... \n");
Expand Down
2 changes: 1 addition & 1 deletion src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@ void
FindAllThemes (void)
{
int i, location;
char dname[500], tname[100], fpath[500];
char dname[500], tname[100], fpath[1024];
DIR *dir;
struct stat buf;
struct dirent *entry;
Expand Down
6 changes: 3 additions & 3 deletions src/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ const char *handle_LE_SaveShip ( MenuAction_t action )
if ( action == ACTION_CLICK )
{
SaveShip( shipname );
char output[255];
char output[512];
snprintf ( output, sizeof(output)-1, "Ship saved as '%s'", fname );
CenteredPutString (ne_screen, 3*FontHeight(Menu_BFont), output );
SDL_Flip ( ne_screen );
Expand Down Expand Up @@ -1095,7 +1095,7 @@ Key_Config_Menu (void)
{
int LastMenuPos = CMD_LAST;
int selx = 1, sely = 1; // currently selected menu-position
int oldkey, newkey = -1;
int newkey = -1;
MenuAction_t action = ACTION_NONE;
const Uint32 wait_move_ticks = 100;
static Uint32 last_move_tick = 0;
Expand All @@ -1118,7 +1118,7 @@ Key_Config_Menu (void)
case ACTION_CLICK:
MenuItemSelectedSound();

oldkey = key_cmds[sely-1][selx-1];
// oldkey = key_cmds[sely-1][selx-1];
key_cmds[sely-1][selx-1] = '_';
Display_Key_Config (selx, sely);
newkey = getchar_raw(); // includes joystick input!
Expand Down
12 changes: 7 additions & 5 deletions src/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ read_variable (char *data, char *var_name, char *fmt, void *var)
int
LoadGameConfig (void)
{
char fname[255];
const char *base = "config";
char fname[sizeof(ConfigDir) + strlen(base) + 2];
FILE *fp;
char *data;
off_t size, read_size;
Expand Down Expand Up @@ -183,7 +184,7 @@ LoadGameConfig (void)
#endif
}

sprintf (fname, "%s/config", ConfigDir);
sprintf (fname, "%s/%s", ConfigDir, base);

if( (fp = fopen (fname, "r")) == NULL)
{
Expand Down Expand Up @@ -264,14 +265,15 @@ LoadGameConfig (void)
int
SaveGameConfig (void)
{
char fname[255];
const char *base = "config";
char fname[sizeof(ConfigDir) + strlen(base) + 2];
FILE *fp;
int i;

if ( ConfigDir[0] == '\0')
return (ERR);

sprintf (fname, "%s/config", ConfigDir);
sprintf (fname, "%s/%s", ConfigDir, base);
if( (fp = fopen (fname, "w")) == NULL)
{
DebugPrintf (0, "WARNING: failed to create config-file: %s\n", fname);
Expand Down Expand Up @@ -639,7 +641,7 @@ ReadValueFromString (char* data, char* label, char* FormatString, void* dst)
char *
find_file (const char *fname, char *subdir, int use_theme, int critical)
{
static char File_Path[1024] = ""; /* hope this will be enough */
static char File_Path[2048] = ""; /* hope this will be enough */
int len = sizeof(File_Path);

char Theme_Dir[1024] = "";
Expand Down
4 changes: 2 additions & 2 deletions src/text.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,12 @@ ScrollText (char *Text, SDL_Rect *rect, int SecondsMinimumDuration )
int maxspeed = 150;
SDL_Surface* Background;
int ret = 0;
Uint32 first_tick, prev_tick, now;
Uint32 prev_tick, now;
bool just_started = TRUE;

Background = SDL_DisplayFormat( ne_screen );

first_tick = SDL_GetTicks ();
// first_tick = SDL_GetTicks ();

// count the number of lines in the text
textpt = Text;
Expand Down

0 comments on commit 067fb98

Please sign in to comment.