Skip to content

Commit

Permalink
Silence a format truncation warning
Browse files Browse the repository at this point in the history
This line generates a warning during compilation:

menu/menu_displaylist.c:11925:46: warning: '%d' directive output may be truncated writing between 1 and 3 bytes into a region of size 2 [-Wformat-truncation=]
11925 |                                        "Mode %d", toc->track[i].mode);
      |                                              ^~
menu/menu_displaylist.c:11925:40: note: directive argument in the range [0, 255]
11925 |                                        "Mode %d", toc->track[i].mode);
      |                                        ^~~~~~~~~
In file included from /usr/include/stdio.h:936,
                 from ./libretro-common/include/file/file_path.h:26,
                 from menu/menu_displaylist.c:27:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10: note: '__builtin___snprintf_chk' output between 7 and 9 bytes into a destination of size 7
   64 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   65 |        __bos (__s), __fmt, __va_arg_pack ());
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Since the value of the track mode should be either 1 or 2, a modulo 10 should not limit the displayed value, and it removes the warning.
  • Loading branch information
zoltanvb authored Nov 1, 2023
1 parent e7a10b2 commit 6242a19
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion menu/menu_displaylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -11922,7 +11922,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
else
snprintf(mode_str + strlen_mode_str,
sizeof(mode_str) - strlen_mode_str,
"Mode %d", toc->track[i].mode);
"Mode %d", toc->track[i].mode%10);

if (menu_entries_append(info->list,
mode_str,
Expand Down

0 comments on commit 6242a19

Please sign in to comment.