After installing a copy of GCC 7, It looks like this patch is an
incomplete fix. With this patch applied older GCC 6.3.0 continues to
work fine, but GCC 7.0.1 generates the following errors:

Making all in platform/linux-generic
make[1]: Entering directory '/home/bill/linaro/gcc7fix/platform/linux-generic'
  CC       pktio/ipc.lo
pktio/ipc.c: In function ‘ipc_close’:
pktio/ipc.c:698:33: error: ‘%s’ directive output may be truncated
writing up to 255 bytes into a region of size 32
[-Werror=format-truncation=]
   snprintf(name, sizeof(name), "%s", dev);
                                 ^~
In file included from /usr/include/stdio.h:938:0,
                 from /usr/include/openssl/crypto.h:125,
                 from /usr/include/openssl/ui.h:64,
                 from /usr/include/openssl/ui_compat.h:64,
                 from /usr/include/openssl/des_old.h:495,
                 from /usr/include/openssl/des.h:102,
                 from ./include/odp_crypto_internal.h:14,
                 from ./include/odp_packet_internal.h:28,
                 from ./include/odp_classification_datamodel.h:25,
                 from ./include/odp_packet_io_internal.h:23,
                 from ./include/odp_packet_io_ipc_internal.h:8,
                 from pktio/ipc.c:6:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10: note:
‘__builtin_snprintf’ output between 1 and 256 bytes into a destination
of size 32
   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        __bos (__s), __fmt, __va_arg_pack ());
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Makefile:920: recipe for target 'pktio/ipc.lo' failed
make[1]: *** [pktio/ipc.lo] Error 1
  CC       pktio/pktio_common.lo
  CC       pktio/loop.lo
  CC       pktio/netmap.lo
  CC       pktio/dpdk.lo
  CC       pktio/socket.lo
  CC       pktio/socket_mmap.lo
  CC       pktio/sysfs.lo
pktio/sysfs.c: In function ‘sysfs_stats’:
pktio/sysfs.c:50:33: error: ‘%s’ directive writing up to 255 bytes
into a region of size 241 [-Werror=format-overflow=]
  sprintf(fname, "/sys/class/net/%s/statistics/rx_bytes", dev);
                                 ^~
In file included from /usr/include/stdio.h:938:0,
                 from /usr/include/openssl/crypto.h:125,
                 from /usr/include/openssl/ui.h:64,
                 from /usr/include/openssl/ui_compat.h:64,
                 from /usr/include/openssl/des_old.h:495,
                 from /usr/include/openssl/des.h:102,
                 from ./include/odp_crypto_internal.h:14,
                 from ./include/odp_packet_internal.h:28,
                 from ./include/odp_classification_datamodel.h:25,
                 from ./include/odp_packet_io_internal.h:23,
                 from pktio/sysfs.c:8:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:33:10: note:
‘__builtin___sprintf_chk’ output between 36 and 291 bytes into a
destination of size 256
   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       __bos (__s), __fmt, __va_arg_pack ());
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pktio/sysfs.c:53:33: error: ‘%s’ directive writing up to 255 bytes
into a region of size 241 [-Werror=format-overflow=]
  sprintf(fname, "/sys/class/net/%s/statistics/rx_packets", dev);
                                 ^~
In file included from /usr/include/stdio.h:938:0,
                 from /usr/include/openssl/crypto.h:125,
                 from /usr/include/openssl/ui.h:64,
                 from /usr/include/openssl/ui_compat.h:64,
                 from /usr/include/openssl/des_old.h:495,
                 from /usr/include/openssl/des.h:102,
                 from ./include/odp_crypto_internal.h:14,
                 from ./include/odp_packet_internal.h:28,
                 from ./include/odp_classification_datamodel.h:25,
                 from ./include/odp_packet_io_internal.h:23,
                 from pktio/sysfs.c:8:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:33:10: note:
‘__builtin___sprintf_chk’ output between 38 and 293 bytes into a
destination of size 256
   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       __bos (__s), __fmt, __va_arg_pack ());
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pktio/sysfs.c:56:33: error: ‘%s’ directive writing up to 255 bytes
into a region of size 241 [-Werror=format-overflow=]
  sprintf(fname, "/sys/class/net/%s/statistics/rx_droppped", dev);
                                 ^~
In file included from /usr/include/stdio.h:938:0,
                 from /usr/include/openssl/crypto.h:125,
                 from /usr/include/openssl/ui.h:64,
                 from /usr/include/openssl/ui_compat.h:64,
                 from /usr/include/openssl/des_old.h:495,
                 from /usr/include/openssl/des.h:102,
                 from ./include/odp_crypto_internal.h:14,
                 from ./include/odp_packet_internal.h:28,
                 from ./include/odp_classification_datamodel.h:25,
                 from ./include/odp_packet_io_internal.h:23,
                 from pktio/sysfs.c:8:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:33:10: note:
‘__builtin___sprintf_chk’ output between 39 and 294 bytes into a
destination of size 256
   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       __bos (__s), __fmt, __va_arg_pack ());
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pktio/sysfs.c:59:33: error: ‘%s’ directive writing up to 255 bytes
into a region of size 241 [-Werror=format-overflow=]
  sprintf(fname, "/sys/class/net/%s/statistics/rx_errors", dev);
                                 ^~
In file included from /usr/include/stdio.h:938:0,
                 from /usr/include/openssl/crypto.h:125,
                 from /usr/include/openssl/ui.h:64,
                 from /usr/include/openssl/ui_compat.h:64,
                 from /usr/include/openssl/des_old.h:495,
                 from /usr/include/openssl/des.h:102,
                 from ./include/odp_crypto_internal.h:14,
                 from ./include/odp_packet_internal.h:28,
                 from ./include/odp_classification_datamodel.h:25,
                 from ./include/odp_packet_io_internal.h:23,
                 from pktio/sysfs.c:8:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:33:10: note:
‘__builtin___sprintf_chk’ output between 37 and 292 bytes into a
destination of size 256
   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       __bos (__s), __fmt, __va_arg_pack ());
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pktio/sysfs.c:64:33: error: ‘%s’ directive writing up to 255 bytes
into a region of size 241 [-Werror=format-overflow=]
  sprintf(fname, "/sys/class/net/%s/statistics/tx_bytes", dev);
                                 ^~
In file included from /usr/include/stdio.h:938:0,
                 from /usr/include/openssl/crypto.h:125,
                 from /usr/include/openssl/ui.h:64,
                 from /usr/include/openssl/ui_compat.h:64,
                 from /usr/include/openssl/des_old.h:495,
                 from /usr/include/openssl/des.h:102,
                 from ./include/odp_crypto_internal.h:14,
                 from ./include/odp_packet_internal.h:28,
                 from ./include/odp_classification_datamodel.h:25,
                 from ./include/odp_packet_io_internal.h:23,
                 from pktio/sysfs.c:8:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:33:10: note:
‘__builtin___sprintf_chk’ output between 36 and 291 bytes into a
destination of size 256
   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       __bos (__s), __fmt, __va_arg_pack ());
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pktio/sysfs.c:67:33: error: ‘%s’ directive writing up to 255 bytes
into a region of size 241 [-Werror=format-overflow=]
  sprintf(fname, "/sys/class/net/%s/statistics/tx_packets", dev);
                                 ^~
In file included from /usr/include/stdio.h:938:0,
                 from /usr/include/openssl/crypto.h:125,
                 from /usr/include/openssl/ui.h:64,
                 from /usr/include/openssl/ui_compat.h:64,
                 from /usr/include/openssl/des_old.h:495,
                 from /usr/include/openssl/des.h:102,
                 from ./include/odp_crypto_internal.h:14,
                 from ./include/odp_packet_internal.h:28,
                 from ./include/odp_classification_datamodel.h:25,
                 from ./include/odp_packet_io_internal.h:23,
                 from pktio/sysfs.c:8:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:33:10: note:
‘__builtin___sprintf_chk’ output between 38 and 293 bytes into a
destination of size 256
   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       __bos (__s), __fmt, __va_arg_pack ());
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pktio/sysfs.c:70:33: error: ‘%s’ directive writing up to 255 bytes
into a region of size 241 [-Werror=format-overflow=]
  sprintf(fname, "/sys/class/net/%s/statistics/tx_dropped", dev);
                                 ^~
In file included from /usr/include/stdio.h:938:0,
                 from /usr/include/openssl/crypto.h:125,
                 from /usr/include/openssl/ui.h:64,
                 from /usr/include/openssl/ui_compat.h:64,
                 from /usr/include/openssl/des_old.h:495,
                 from /usr/include/openssl/des.h:102,
                 from ./include/odp_crypto_internal.h:14,
                 from ./include/odp_packet_internal.h:28,
                 from ./include/odp_classification_datamodel.h:25,
                 from ./include/odp_packet_io_internal.h:23,
                 from pktio/sysfs.c:8:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:33:10: note:
‘__builtin___sprintf_chk’ output between 38 and 293 bytes into a
destination of size 256
   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       __bos (__s), __fmt, __va_arg_pack ());
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pktio/sysfs.c:73:33: error: ‘%s’ directive writing up to 255 bytes
into a region of size 241 [-Werror=format-overflow=]
  sprintf(fname, "/sys/class/net/%s/statistics/tx_errors", dev);
                                 ^~
In file included from /usr/include/stdio.h:938:0,
                 from /usr/include/openssl/crypto.h:125,
                 from /usr/include/openssl/ui.h:64,
                 from /usr/include/openssl/ui_compat.h:64,
                 from /usr/include/openssl/des_old.h:495,
                 from /usr/include/openssl/des.h:102,
                 from ./include/odp_crypto_internal.h:14,
                 from ./include/odp_packet_internal.h:28,
                 from ./include/odp_classification_datamodel.h:25,
                 from ./include/odp_packet_io_internal.h:23,
                 from pktio/sysfs.c:8:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:33:10: note:
‘__builtin___sprintf_chk’ output between 37 and 292 bytes into a
destination of size 256
   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       __bos (__s), __fmt, __va_arg_pack ());
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Makefile:920: recipe for target 'pktio/sysfs.lo' failed
make[1]: *** [pktio/sysfs.lo] Error 1
  CC       pktio/tap.lo
  CC       pktio/ring.lo
pktio/ring.c: In function ‘___ring_mp_do_enqueue’:
pktio/ring.c:100:18: error: this statement may fall through
[-Werror=implicit-fallthrough=]
   r->ring[idx++] = obj_table[i++]; \
   ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
pktio/ring.c:295:2: note: in expansion of macro ‘ENQUEUE_PTRS’
  ENQUEUE_PTRS();
  ^~~~~~~~~~~~
pktio/ring.c:101:3: note: here
   case 2: \
   ^
pktio/ring.c:295:2: note: in expansion of macro ‘ENQUEUE_PTRS’
  ENQUEUE_PTRS();
  ^~~~~~~~~~~~
pktio/ring.c:102:18: error: this statement may fall through
[-Werror=implicit-fallthrough=]
   r->ring[idx++] = obj_table[i++]; \
   ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
pktio/ring.c:295:2: note: in expansion of macro ‘ENQUEUE_PTRS’
  ENQUEUE_PTRS();
  ^~~~~~~~~~~~
pktio/ring.c:103:3: note: here
   case 1: \
   ^
pktio/ring.c:295:2: note: in expansion of macro ‘ENQUEUE_PTRS’
  ENQUEUE_PTRS();
  ^~~~~~~~~~~~
pktio/ring.c: In function ‘___ring_sp_do_enqueue’:
pktio/ring.c:100:18: error: this statement may fall through
[-Werror=implicit-fallthrough=]
   r->ring[idx++] = obj_table[i++]; \
   ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
pktio/ring.c:353:2: note: in expansion of macro ‘ENQUEUE_PTRS’
  ENQUEUE_PTRS();
  ^~~~~~~~~~~~
pktio/ring.c:101:3: note: here
   case 2: \
   ^
pktio/ring.c:353:2: note: in expansion of macro ‘ENQUEUE_PTRS’
  ENQUEUE_PTRS();
  ^~~~~~~~~~~~
pktio/ring.c:102:18: error: this statement may fall through
[-Werror=implicit-fallthrough=]
   r->ring[idx++] = obj_table[i++]; \
   ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
pktio/ring.c:353:2: note: in expansion of macro ‘ENQUEUE_PTRS’
  ENQUEUE_PTRS();
  ^~~~~~~~~~~~
pktio/ring.c:103:3: note: here
   case 1: \
   ^
pktio/ring.c:353:2: note: in expansion of macro ‘ENQUEUE_PTRS’
  ENQUEUE_PTRS();
  ^~~~~~~~~~~~
pktio/ring.c: In function ‘___ring_mc_do_dequeue’:
pktio/ring.c:129:18: error: this statement may fall through
[-Werror=implicit-fallthrough=]
   obj_table[i++] = r->ring[idx++]; \
   ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
pktio/ring.c:415:2: note: in expansion of macro ‘DEQUEUE_PTRS’
  DEQUEUE_PTRS();
  ^~~~~~~~~~~~
pktio/ring.c:130:3: note: here
   case 2: \
   ^
pktio/ring.c:415:2: note: in expansion of macro ‘DEQUEUE_PTRS’
  DEQUEUE_PTRS();
  ^~~~~~~~~~~~
pktio/ring.c:131:18: error: this statement may fall through
[-Werror=implicit-fallthrough=]
   obj_table[i++] = r->ring[idx++]; \
   ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
pktio/ring.c:415:2: note: in expansion of macro ‘DEQUEUE_PTRS’
  DEQUEUE_PTRS();
  ^~~~~~~~~~~~
pktio/ring.c:132:3: note: here
   case 1: \
   ^
pktio/ring.c:415:2: note: in expansion of macro ‘DEQUEUE_PTRS’
  DEQUEUE_PTRS();
  ^~~~~~~~~~~~
pktio/ring.c: In function ‘___ring_sc_do_dequeue’:
pktio/ring.c:129:18: error: this statement may fall through
[-Werror=implicit-fallthrough=]
   obj_table[i++] = r->ring[idx++]; \
   ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
pktio/ring.c:464:2: note: in expansion of macro ‘DEQUEUE_PTRS’
  DEQUEUE_PTRS();
  ^~~~~~~~~~~~
pktio/ring.c:130:3: note: here
   case 2: \
   ^
pktio/ring.c:464:2: note: in expansion of macro ‘DEQUEUE_PTRS’
  DEQUEUE_PTRS();
  ^~~~~~~~~~~~
pktio/ring.c:131:18: error: this statement may fall through
[-Werror=implicit-fallthrough=]
   obj_table[i++] = r->ring[idx++]; \
   ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
pktio/ring.c:464:2: note: in expansion of macro ‘DEQUEUE_PTRS’
  DEQUEUE_PTRS();
  ^~~~~~~~~~~~
pktio/ring.c:132:3: note: here
   case 1: \
   ^
pktio/ring.c:464:2: note: in expansion of macro ‘DEQUEUE_PTRS’
  DEQUEUE_PTRS();

On Mon, Jun 5, 2017 at 4:19 PM, Brian Brooks <[email protected]> wrote:
> The GCC 7 series introduces changes that expose ODP compilation
> issues. These include case statement fall through warnings, and
> stricter checks on potential string overflows and other semantic
> analysis.
>
> Fixes: https://bugs.linaro.org/show_bug.cgi?id=3027
>
> Brian Brooks (2):
>   build: GCC 7 fixes
>   pktio: GCC 7 fixes
>
>  DEPENDENCIES                                  |  5 +--
>  configure.ac                                  |  8 +++++
>  platform/linux-generic/m4/configure.m4        | 44 
> +++++++++++++++++++++++++++
>  test/common_plat/validation/api/pktio/pktio.c |  4 ++-
>  4 files changed, 58 insertions(+), 3 deletions(-)
>
> --
>
> v3:
>  - Split into multiple patches files (Maxim)
>  - Disable warnings in favor of patching right now (Dmitry)
>  - Improve libatomic detection in autoconf (Dmitry)
>  - Add autoconf-arch to DEPENDENCIES file
>
> v2:
>  - Add Bug id to commit message (Bill)
>
> 2.13.0
>

Reply via email to