qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] 2fb513: ppc: e500: use g_strdup_printf() inst


From: GitHub
Subject: [Qemu-commits] [qemu/qemu] 2fb513: ppc: e500: use g_strdup_printf() instead of snprin...
Date: Tue, 08 May 2018 04:01:13 -0700

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 2fb513d3b1e3472ff02dc00e213db65bc56506cd
      
https://github.com/qemu/qemu/commit/2fb513d3b1e3472ff02dc00e213db65bc56506cd
  Author: Greg Kurz <address@hidden>
  Date:   2018-05-08 (Tue, 08 May 2018)

  Changed paths:
    M hw/ppc/e500.c

  Log Message:
  -----------
  ppc: e500: use g_strdup_printf() instead of snprintf()

qemu-system-ppc fails to build with GCC 8.0.1:

/home/hsp/src/qemu-master/hw/ppc/e500.c: In function ‘ppce500_load_device_tree’:
/home/hsp/src/qemu-master/hw/ppc/e500.c:442:37: error: ‘/address@hidden
directive output may be truncated writing 5 bytes into a region of
size between 1 and 128 [-Werror=format-truncation=]
     snprintf(mpic, sizeof(mpic), "%s/address@hidden", soc, 
MPC8544_MPIC_REGS_OFFSET);
                               ^~~~~
In file included from /usr/include/stdio.h:862,
           from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
           from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 11 and 138 bytes into a destination of size 128
   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  __bos (__s), __fmt, __va_arg_pack ());
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:470:39: error:
‘/address@hidden directive output may be truncated writing 18
bytes into a region of size between 1 and 128
[-Werror=format-truncation=]
     snprintf(gutil, sizeof(gutil), "%s/address@hidden", soc,
                                 ^~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:862,
           from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
           from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 24 and 151 bytes into a destination of size 128
   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  __bos (__s), __fmt, __va_arg_pack ());
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:477:36: error: ‘/address@hidden
directive output may be truncated writing 5 bytes into a region of
size between 0 and 127 [-Werror=format-truncation=]
     snprintf(msi, sizeof(msi), "/%s/address@hidden", soc, 
MPC8544_MSI_REGS_OFFSET);
                              ^~~~~
In file included from /usr/include/stdio.h:862,
           from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
           from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 12 and 139 bytes into a destination of size 128
   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  __bos (__s), __fmt, __va_arg_pack ());
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fix this by converting e500 to use g_strdup_printf()+g_free() instead
of snprintf(). This is done globally, even for call sites that don't
break build, since this is the preferred practice in QEMU.

Reported-by: Howard Spoelstra <address@hidden>
Signed-off-by: Greg Kurz <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-id: address@hidden
Cc: address@hidden
Signed-off-by: Peter Maydell <address@hidden>



      **NOTE:** This service been marked for deprecation: 
https://developer.github.com/changes/2018-04-25-github-services-deprecation/

      Functionality will be removed from GitHub.com on January 31st, 2019.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]