]> granicus.if.org Git - nethack/commitdiff
gcc-11 warnings in tilemap.c
authornhmall <nhmall@nethack.org>
Tue, 4 Jan 2022 01:44:45 +0000 (20:44 -0500)
committernhmall <nhmall@nethack.org>
Tue, 4 Jan 2022 01:44:45 +0000 (20:44 -0500)
../win/share/tilemap.c: In function ‘init_tilemap’:
../win/share/tilemap.c:705:61: warning: ‘%s’ directive writing up to 255 bytes into a region of size 122 [-Wformat-overflow=]
  705 |         Sprintf(tilemap[GLYPH_MON_MALE_OFF + i].name, "male %s", buf);
      |                                                             ^~   ~~~
In file included from ../include/config.h:643,
                 from ../include/hack.h:10,
                 from ../win/share/tilemap.c:20:
../include/global.h:254:24: note: ‘sprintf’ output between 6 and 261 bytes into a destination of size 127
  254 | #define Sprintf (void) sprintf
../win/share/tilemap.c:705:9: note: in expansion of macro ‘Sprintf’
  705 |         Sprintf(tilemap[GLYPH_MON_MALE_OFF + i].name, "male %s", buf);
      |         ^~~~~~~
../win/share/tilemap.c:706:64: warning: ‘%s’ directive writing up to 255 bytes into a region of size 118 [-Wformat-overflow=]
  706 |         Sprintf(tilemap[GLYPH_PET_MALE_OFF + i].name, "%s male %s", "pet", buf);
      |                                                                ^~          ~~~
In file included from ../include/config.h:643,
                 from ../include/hack.h:10,
                 from ../win/share/tilemap.c:20:
../include/global.h:254:24: note: ‘sprintf’ output between 10 and 265 bytes into a destination of size 127
  254 | #define Sprintf (void) sprintf
../win/share/tilemap.c:706:9: note: in expansion of macro ‘Sprintf’
  706 |         Sprintf(tilemap[GLYPH_PET_MALE_OFF + i].name, "%s male %s", "pet", buf);
      |         ^~~~~~~
../win/share/tilemap.c:707:67: warning: ‘%s’ directive writing up to 255 bytes into a region of size 113 [-Wformat-overflow=]
  707 |         Sprintf(tilemap[GLYPH_DETECT_MALE_OFF + i].name, "%s male %s", "detected", buf);
      |                                                                   ^~               ~~~
In file included from ../include/config.h:643,
                 from ../include/hack.h:10,
                 from ../win/share/tilemap.c:20:
../include/global.h:254:24: note: ‘sprintf’ output between 15 and 270 bytes into a destination of size 127
  254 | #define Sprintf (void) sprintf
../win/share/tilemap.c:707:9: note: in expansion of macro ‘Sprintf’
  707 |         Sprintf(tilemap[GLYPH_DETECT_MALE_OFF + i].name, "%s male %s", "detected", buf);
      |         ^~~~~~~
../win/share/tilemap.c:708:67: warning: ‘%s’ directive writing up to 255 bytes into a region of size 115 [-Wformat-overflow=]
  708 |         Sprintf(tilemap[GLYPH_RIDDEN_MALE_OFF + i].name, "%s male %s", "ridden", buf);
      |                                                                   ^~             ~~~
In file included from ../include/config.h:643,
                 from ../include/hack.h:10,
                 from ../win/share/tilemap.c:20:
../include/global.h:254:24: note: ‘sprintf’ output between 13 and 268 bytes into a destination of size 127
  254 | #define Sprintf (void) sprintf
../win/share/tilemap.c:708:9: note: in expansion of macro ‘Sprintf’
  708 |         Sprintf(tilemap[GLYPH_RIDDEN_MALE_OFF + i].name, "%s male %s", "ridden", buf);
      |         ^~~~~~~
../win/share/tilemap.c:709:55: warning: ‘%s’ directive writing up to 255 bytes into a region of size 119 [-Wformat-overflow=]
  709 |         Sprintf(tilemap[GLYPH_BODY_OFF + i].name, "%s %s", "body of", buf);
      |                                                       ^~              ~~~
In file included from ../include/config.h:643,
                 from ../include/hack.h:10,
                 from ../win/share/tilemap.c:20:
../include/global.h:254:24: note: ‘sprintf’ output between 9 and 264 bytes into a destination of size 127
  254 | #define Sprintf (void) sprintf
../win/share/tilemap.c:709:9: note: in expansion of macro ‘Sprintf’
  709 |         Sprintf(tilemap[GLYPH_BODY_OFF + i].name, "%s %s", "body of", buf);
      |         ^~~~~~~
../win/share/tilemap.c:710:63: warning: ‘%s’ directive writing up to 255 bytes into a region of size 111 [-Wformat-overflow=]
  710 |         Sprintf(tilemap[GLYPH_BODY_PILETOP_OFF + i].name, "%s %s", "piletop body of", buf);
      |                                                               ^~                      ~~~
In file included from ../include/config.h:643,
                 from ../include/hack.h:10,
                 from ../win/share/tilemap.c:20:
../include/global.h:254:24: note: ‘sprintf’ output between 17 and 272 bytes into a destination of size 127
  254 | #define Sprintf (void) sprintf
../win/share/tilemap.c:710:9: note: in expansion of macro ‘Sprintf’
  710 |         Sprintf(tilemap[GLYPH_BODY_PILETOP_OFF + i].name, "%s %s", "piletop body of", buf);
      |         ^~~~~~~
../win/share/tilemap.c:732:62: warning: ‘%s’ directive writing up to 255 bytes into a region of size 120 [-Wformat-overflow=]
  732 |         Sprintf(tilemap[GLYPH_MON_FEM_OFF + i].name, "female %s", buf);
      |                                                              ^~   ~~~
In file included from ../include/config.h:643,
                 from ../include/hack.h:10,
                 from ../win/share/tilemap.c:20:
../include/global.h:254:24: note: ‘sprintf’ output between 8 and 263 bytes into a destination of size 127
  254 | #define Sprintf (void) sprintf
../win/share/tilemap.c:732:9: note: in expansion of macro ‘Sprintf’
  732 |         Sprintf(tilemap[GLYPH_MON_FEM_OFF + i].name, "female %s", buf);
      |         ^~~~~~~
../win/share/tilemap.c:733:65: warning: ‘%s’ directive writing up to 255 bytes into a region of size 116 [-Wformat-overflow=]
  733 |         Sprintf(tilemap[GLYPH_PET_FEM_OFF + i].name, "%s female %s", "pet",
      |                                                                 ^~
  734 |                 buf);
      |                 ~~~
In file included from ../include/config.h:643,
                 from ../include/hack.h:10,
                 from ../win/share/tilemap.c:20:
../include/global.h:254:24: note: ‘sprintf’ output between 12 and 267 bytes into a destination of size 127
  254 | #define Sprintf (void) sprintf
../win/share/tilemap.c:733:9: note: in expansion of macro ‘Sprintf’
  733 |         Sprintf(tilemap[GLYPH_PET_FEM_OFF + i].name, "%s female %s", "pet",
      |         ^~~~~~~
../win/share/tilemap.c:735:68: warning: ‘%s’ directive writing up to 255 bytes into a region of size 111 [-Wformat-overflow=]
  735 |         Sprintf(tilemap[GLYPH_DETECT_FEM_OFF + i].name, "%s female %s",
      |                                                                    ^~
  736 |                 "detected", buf);
      |                             ~~~
In file included from ../include/config.h:643,
                 from ../include/hack.h:10,
                 from ../win/share/tilemap.c:20:
../include/global.h:254:24: note: ‘sprintf’ output between 17 and 272 bytes into a destination of size 127
  254 | #define Sprintf (void) sprintf
../win/share/tilemap.c:735:9: note: in expansion of macro ‘Sprintf’
  735 |         Sprintf(tilemap[GLYPH_DETECT_FEM_OFF + i].name, "%s female %s",
      |         ^~~~~~~
../win/share/tilemap.c:737:68: warning: ‘%s’ directive writing up to 255 bytes into a region of size 113 [-Wformat-overflow=]
  737 |         Sprintf(tilemap[GLYPH_RIDDEN_FEM_OFF + i].name, "%s female %s",
      |                                                                    ^~
  738 |                 "ridden", buf);
      |                           ~~~
In file included from ../include/config.h:643,
                 from ../include/hack.h:10,
                 from ../win/share/tilemap.c:20:
../include/global.h:254:24: note: ‘sprintf’ output between 15 and 270 bytes into a destination of size 127
  254 | #define Sprintf (void) sprintf
../win/share/tilemap.c:737:9: note: in expansion of macro ‘Sprintf’
  737 |         Sprintf(tilemap[GLYPH_RIDDEN_FEM_OFF + i].name, "%s female %s",
      |         ^~~~~~~
../win/share/tilemap.c:739:55: warning: ‘%s’ directive writing up to 255 bytes into a region of size 119 [-Wformat-overflow=]
  739 |         Sprintf(tilemap[GLYPH_BODY_OFF + i].name, "%s %s", "body of", buf);
      |                                                       ^~              ~~~
In file included from ../include/config.h:643,
                 from ../include/hack.h:10,
                 from ../win/share/tilemap.c:20:
../include/global.h:254:24: note: ‘sprintf’ output between 9 and 264 bytes into a destination of size 127
  254 | #define Sprintf (void) sprintf
../win/share/tilemap.c:739:9: note: in expansion of macro ‘Sprintf’
  739 |         Sprintf(tilemap[GLYPH_BODY_OFF + i].name, "%s %s", "body of", buf);
      |         ^~~~~~~
../win/share/tilemap.c:740:63: warning: ‘%s’ directive writing up to 255 bytes into a region of size 111 [-Wformat-overflow=]
  740 |         Sprintf(tilemap[GLYPH_BODY_PILETOP_OFF + i].name, "%s %s",
      |                                                               ^~
  741 |                 "piletop body of", buf);
      |                                    ~~~
In file included from ../include/config.h:643,
                 from ../include/hack.h:10,
                 from ../win/share/tilemap.c:20:
../include/global.h:254:24: note: ‘sprintf’ output between 17 and 272 bytes into a destination of size 127
  254 | #define Sprintf (void) sprintf
../win/share/tilemap.c:740:9: note: in expansion of macro ‘Sprintf’
  740 |         Sprintf(tilemap[GLYPH_BODY_PILETOP_OFF + i].name, "%s %s",
      |         ^~~~~~~
cc -rdynamic -lm -o tilemap tilemap.o ../src/objects.o  \
        ../src/monst.o  ../src/drawing.o

win/share/tilemap.c

index 5b64602729cd36eb348a44761bdecb93628d56fd..b415736d9df52770e8dd2b0dcda82a4ac793340e 100644 (file)
@@ -702,12 +702,18 @@ init_tilemap(void)
         tilemap[GLYPH_BODY_PILETOP_OFF + i].tilenum = corpsetile;
 #if defined(OBTAIN_TILEMAP)
         Sprintf(buf, "%s (mnum=%d)", tilename(MON_GLYPH, file_entry, 0), i);
-        Sprintf(tilemap[GLYPH_MON_MALE_OFF + i].name, "male %s", buf);
-        Sprintf(tilemap[GLYPH_PET_MALE_OFF + i].name, "%s male %s", "pet", buf);
-        Sprintf(tilemap[GLYPH_DETECT_MALE_OFF + i].name, "%s male %s", "detected", buf);
-        Sprintf(tilemap[GLYPH_RIDDEN_MALE_OFF + i].name, "%s male %s", "ridden", buf);
-        Sprintf(tilemap[GLYPH_BODY_OFF + i].name, "%s %s", "body of", buf);
-        Sprintf(tilemap[GLYPH_BODY_PILETOP_OFF + i].name, "%s %s", "piletop body of", buf);
+        Snprintf(tilemap[GLYPH_MON_MALE_OFF + i].name,
+                sizeof tilemap[0].name,"male %s", buf);
+        Snprintf(tilemap[GLYPH_PET_MALE_OFF + i].name,
+               sizeof tilemap[0].name, "%s male %s", "pet", buf);
+        Snprintf(tilemap[GLYPH_DETECT_MALE_OFF + i].name,
+               sizeof tilemap[0].name, "%s male %s", "detected", buf);
+        Snprintf(tilemap[GLYPH_RIDDEN_MALE_OFF + i].name,
+               sizeof tilemap[0].name, "%s male %s", "ridden", buf);
+        Snprintf(tilemap[GLYPH_BODY_OFF + i].name,
+               sizeof tilemap[0].name, "%s %s", "body of", buf);
+        Snprintf(tilemap[GLYPH_BODY_PILETOP_OFF + i].name,
+               sizeof tilemap[0].name, "%s %s", "piletop body of", buf);
         add_tileref(tilenum, GLYPH_MON_MALE_OFF + i, monsters_file,
                     file_entry, tilemap[GLYPH_MON_MALE_OFF + i].name, "");
         add_tileref(tilenum, GLYPH_PET_MALE_OFF + i, monsters_file,
@@ -729,15 +735,21 @@ init_tilemap(void)
         tilemap[GLYPH_RIDDEN_FEM_OFF + i].tilenum = tilenum;
 #if defined(OBTAIN_TILEMAP)
         Sprintf(buf, "%s (mnum=%d)", tilename(MON_GLYPH, file_entry, 0), i);
-        Sprintf(tilemap[GLYPH_MON_FEM_OFF + i].name, "female %s", buf);
-        Sprintf(tilemap[GLYPH_PET_FEM_OFF + i].name, "%s female %s", "pet",
+        Snprintf(tilemap[GLYPH_MON_FEM_OFF + i].name, 
+               sizeof tilemap[0].name, "female %s", buf);
+        Snprintf(tilemap[GLYPH_PET_FEM_OFF + i].name,
+               sizeof tilemap[0].name, "%s female %s", "pet",
                 buf);
-        Sprintf(tilemap[GLYPH_DETECT_FEM_OFF + i].name, "%s female %s",
+        Snprintf(tilemap[GLYPH_DETECT_FEM_OFF + i].name,
+               sizeof tilemap[0].name, "%s female %s",
                 "detected", buf);
-        Sprintf(tilemap[GLYPH_RIDDEN_FEM_OFF + i].name, "%s female %s",
+        Snprintf(tilemap[GLYPH_RIDDEN_FEM_OFF + i].name,
+                sizeof tilemap[0].name, "%s female %s",
                 "ridden", buf);
-        Sprintf(tilemap[GLYPH_BODY_OFF + i].name, "%s %s", "body of", buf);
-        Sprintf(tilemap[GLYPH_BODY_PILETOP_OFF + i].name, "%s %s",
+        Snprintf(tilemap[GLYPH_BODY_OFF + i].name,
+               sizeof tilemap[0].name, "%s %s", "body of", buf);
+        Snprintf(tilemap[GLYPH_BODY_PILETOP_OFF + i].name,
+               sizeof tilemap[0].name, "%s %s",
                 "piletop body of", buf);
         add_tileref(tilenum, GLYPH_MON_FEM_OFF + i, monsters_file,
                     file_entry, tilemap[GLYPH_MON_FEM_OFF + i].name, "");