]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Fix minitrace.c compilation error with GCC 7.3
authorJoel Rosdahl <joel@rosdahl.net>
Mon, 22 Apr 2019 13:22:07 +0000 (15:22 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 22 Apr 2019 13:22:07 +0000 (15:22 +0200)
The error/warning looks like this:

src/minitrace.c: In function ‘mtr_flush’:
src/minitrace.c:256:54: error: ‘%.*s’ directive output may be truncated writing up to 700 bytes into a region of size 252 [-Werror=format-truncation=]
     snprintf(arg_buf, ARRAY_SIZE(arg_buf), "\"%s\":\"%.*s\"", raw->arg_name, 700, raw->a_str);
                                                      ^~~~
In file included from /usr/include/stdio.h:862:0,
                 from src/minitrace.c:9:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’ output 6 or more bytes (assuming 706) into a destination of size 256
   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        __bos (__s), __fmt, __va_arg_pack ());
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/minitrace.c

index 5e09c268717dd24ebd02e6ad0ac63516f81e3eac..cbbd28ca334020a0b794feee76784921248baa06 100644 (file)
@@ -232,7 +232,7 @@ void mtr_flush() {
 #endif
        int i = 0;
        char linebuf[1024];
-       char arg_buf[256];
+       char arg_buf[1024];
        char id_buf[256];
        // We have to lock while flushing. So we really should avoid flushing as much as possible.