rte_version() used "strlen(RTE_VER_SUFFIX) == 0" to detect an empty suffix. Clang evaluates strlen of a constant string at compile time and then reports the other branch as unreachable code.
Use sizeof instead, which clang treats as a configuration value and does not warn about. Note that sizeof of a string literal includes the NUL terminator, so the empty string is sizeof 1 rather than 0. Also fix the indentation of the else. Bugzilla ID: 2135 Signed-off-by: Stephen Hemminger <[email protected]> --- lib/eal/common/rte_version.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/eal/common/rte_version.c b/lib/eal/common/rte_version.c index 627b89d4a8..864d0cfdc5 100644 --- a/lib/eal/common/rte_version.c +++ b/lib/eal/common/rte_version.c @@ -36,14 +36,15 @@ rte_version(void) static char version[32]; if (version[0] != 0) return version; - if (strlen(RTE_VER_SUFFIX) == 0) + + if (sizeof(RTE_VER_SUFFIX) == 1) /* empty string */ snprintf(version, sizeof(version), "%s %d.%02d.%d", RTE_VER_PREFIX, RTE_VER_YEAR, RTE_VER_MONTH, RTE_VER_MINOR); - else - snprintf(version, sizeof(version), "%s %d.%02d.%d%s%d", + else + snprintf(version, sizeof(version), "%s %d.%02d.%d%s%d", RTE_VER_PREFIX, RTE_VER_YEAR, RTE_VER_MONTH, -- 2.53.0

