]> skyeroc.xyz Git - dgamelaunch/commitdiff
Fix warnings from dgamelaunch.c and dgl-common.c
authorSkyebee <sb24kelley@gmail.com>
Sun, 21 Jun 2026 18:47:09 +0000 (14:47 -0400)
committerSkyebee <sb24kelley@gmail.com>
Mon, 22 Jun 2026 05:32:22 +0000 (01:32 -0400)
-Wparentheses

-Wformat-zero-length

-Wstringpop-truncation

-Wformat-truncation

Last few warnings

dgamelaunch.c
dgl-common.c

index 3374f72de7276852960ba6ec352f1680c291ccfa..34542f896eb3e1457c0c465dfcc30748505f88d9 100644 (file)
@@ -548,9 +548,9 @@ banner_addline(struct dg_banner *ban, char *line)
     ban->lines = realloc (ban->lines, sizeof (char *) * ban->len);
     if (len >= DGL_BANNER_LINELEN) {
        len = DGL_BANNER_LINELEN;
-       ban->lines[ban->len - 1] = malloc(len);
+       ban->lines[ban->len - 1] = malloc(len+1);
        strncpy(ban->lines[ban->len - 1], line, len);
-       ban->lines[ban->len - 1][len-1] = '\0';
+       ban->lines[ban->len - 1][len+1] = '\0';
     } else
        ban->lines[ban->len - 1] = strdup(line);
 }
@@ -585,8 +585,8 @@ loadbanner (char *fname, struct dg_banner *ban) {
     if ((slen > 0) && (buf[slen-1] == '\n'))
       buf[slen-1] = '\0';
 
-    strncpy(bufnew, buf, DGL_BANNER_LINELEN);
-    if ( inclpos = strstr(bufnew, "$INCLUDE(") ) {
+    strncpy(bufnew, buf, DGL_BANNER_LINELEN+1);
+    if ( (inclpos = strstr(bufnew, "$INCLUDE(")) ) {
       char *fn = inclpos + 9;
       char *fn_end = strchr(fn, ')');
       if (fn_end) {
@@ -827,7 +827,7 @@ shm_update(struct dg_shm *shm_dg_data, struct dg_game **games, int len)
                        games[i]->is_in_shm = 1;
                        games[i]->shm_idx = di;
                        shm_dg_data->cur_n_games++;
-                       strncpy(shm_dg_game[di].ttyrec_fn, games[i]->ttyrec_fn, 150);
+                       strncpy(shm_dg_game[di].ttyrec_fn, games[i]->ttyrec_fn, 149);
                        break;
                    }
            }
@@ -1036,7 +1036,7 @@ get_timediff(time_t ctime, long seconds)
     mins = (secs / 60) % 60;
     secs -= (mins*60);
     if (hours)
-       snprintf(data, 10, "%ldh %ldm", hours, mins);
+       snprintf(data, 24, "%ldh %ldm", hours, mins);
     else if (mins)
        snprintf(data, 10, "%ldm %lds", mins, secs);
     else if (secs > 4)
@@ -2991,7 +2991,7 @@ runmenuloop(struct dg_menu *menu)
        }
        drawbanner(&ban);
        if (menu->cursor_x >= 0 && menu->cursor_y >= 0)
-           mvprintw(menu->cursor_y, menu->cursor_x, "");
+           mvaddstr(menu->cursor_y, menu->cursor_x, "");
        refresh();
        userchoice = dgl_getch();
        if (userchoice == ERR) {
index ead97b9fb1bff5f634348071ec2614f1577d3169..82754e2e1d09c45fe9985720ba196a4a2d1004c4 100644 (file)
@@ -768,7 +768,7 @@ populate_games (int xgame, int *l, struct dg_user *me)
   DIR *pdir;
   struct dirent *pdirent;
   struct stat pstat;
-  char fullname[130], ttyrecname[130], pidws[80], playername[DGL_PLAYERNAMELEN+1];
+  char fullname[512], ttyrecname[130], pidws[80], playername[DGL_PLAYERNAMELEN+1];
   char *replacestr, *dir, *p;
   struct dg_game **games = NULL;
   struct flock fl = { 0 };
@@ -803,7 +803,7 @@ populate_games (int xgame, int *l, struct dg_user *me)
 
       if (!inprog) continue;
 
-      snprintf (fullname, 130, "%s%s", inprog, pdirent->d_name);
+      snprintf (fullname, 512, "%s%s", inprog, pdirent->d_name);
       free(inprog);
 
       fd = 0;