Skip to contentSkip to conversation

eal: unreachable code warning

DPDK/core Bug 2135 [email protected] 2 participants 2 messages Nov 17

lore
Share & tools
lore
#0 lore raw

https://bugs.dpdk.org/show_bug.cgi?id=2135

            Bug ID: 2135
           Summary: eal: unreachable code warning
           Product: DPDK
           Version: 26.11
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: minor
          Priority: Low
         Component: core
          Assignee: [email protected]
          Reporter: [email protected]

Target Milestone: ---

Building with clang and -Wunreachable-code finds this:

[18/3982] Compiling C object lib/librte_eal.a.p/eal_common_rte_version.c.o ../lib/eal/common/rte_version.c:40:3: warning: code will never be executed [-Wunreachable-code]

   40 |                 snprintf(version, sizeof(version), "%s %d.%02d.%d",
      |                 ^~~~~~~~
../lib/eal/common/rte_version.c:39:32: note: silence by adding parentheses to
mark code as explicitly dead
   39 |         if (strlen(RTE_VER_SUFFIX) == 0)
      |                                       ^
      |                                       /* DISABLES CODE */ ( )

1 warning generated.

It can be fixed by adding parens, using sizeof, or useing RTE_VERSION which is already built by meson.

Signature · 2 lines
You are receiving this mail because:
You are the assignee for the bug.
#1 lore raw
Quoted 28 lines · On Tue, Nov 17, 2026 at 05:07:54PM +0000, [email protected] wrote:

https://bugs.dpdk.org/show_bug.cgi?id=2135

            Bug ID: 2135
           Summary: eal: unreachable code warning
           Product: DPDK
           Version: 26.11
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: minor
          Priority: Low
         Component: core
          Assignee: [email protected]
          Reporter: [email protected]

Target Milestone: ---

Building with clang and -Wunreachable-code finds this:

[18/3982] Compiling C object lib/librte_eal.a.p/eal_common_rte_version.c.o ../lib/eal/common/rte_version.c:40:3: warning: code will never be executed [-Wunreachable-code]

   40 |                 snprintf(version, sizeof(version), "%s %d.%02d.%d",
      |                 ^~~~~~~~
../lib/eal/common/rte_version.c:39:32: note: silence by adding parentheses to
mark code as explicitly dead
   39 |         if (strlen(RTE_VER_SUFFIX) == 0)
      |                                       ^
      |                                       /* DISABLES CODE */ ( )
Quoted 5 lines

1 warning generated.

It can be fixed by adding parens, using sizeof, or useing RTE_VERSION which is already built by meson.

Not a bug. The code is correct, but technically one or both branches are unreachable depending on whether we are at an RC version or not. This construct with dead code I still view as superior to using #ifdefs on the SUFFIX. We can't use RTE_VERSION as that's a numeric version number only, which doesn't include the "rc" part (see definition in rte_version.h).

/Bruce