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

            Bug ID: 1986
           Summary: dpaax: build warnings with clang-23
           Product: DPDK
           Version: 26.11
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: minor
          Priority: Normal
         Component: ethdev
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

Clang 23 checks for set but not used global variables.



  ../drivers/common/dpaax/dpaa_of.c:14:12: error: variable 'alive' set but not
used
     [-Werror,-Wunused-but-set-global]
     14 | static int alive;
        |            ^

  clang-23 extends -Wunused-but-set-variable to file-scope statics
  (-Wunused-but-set-global), which is enabled by -Wall and fatal under -Werror.
  Earlier clang and GCC releases do not diagnose this case, so the code builds
  there.


  alive is assigned in of_init_path() and of_finish(), and is otherwise
referenced
  only as the condition argument to DPAAX_HWWARN(), at 13 call sites in
dpaa_of.c.
  That macro is defined in drivers/common/dpaax/dpaax_logs.h:

  #ifdef RTE_LIBRTE_DPAAX_DEBUG
  #define DPAAX_HWWARN(cond, fmt, ...) \
        do {\
                if (cond) \
                        DPAAX_LOG(DEBUG, "WARN: " fmt, ##__VA_ARGS__); \
        } while (0)
  #else
  #define DPAAX_HWWARN(cond, fmt, ...) do { } while (0)
  #endif

  The disabled variant discards cond entirely, so alive is never read — hence
the
  warning.

There are three options:
1. Remove all this code, since RTE_LIBRTE_DPAAX_DEBUG is not defined anywhere
and there is no meson build to set it. I.e dead code.

2. Add 0 to the do { } while() like:

#ifdef RTE_LIBRTE_DPAAX_DEBUG
#define DPAAX_HWWARN(cond, fmt, ...) \
        do {\
                if (cond) \
                        DPAAX_LOG(DEBUG, "WARN: " fmt, ##__VA_ARGS__); \
        } while (0)
#else
#define DPAAX_HWWARN(cond, fmt, ...) \
        do {\
                if (0 && (cond)) \
                        break; \
        } while (0)
#endif

3. Cleanup and keep the check.
Rename the variable because 'alive' is not descriptive.
Always do the check (no #ifdef) since it is good bug trap.
Make it a warning or notice level since buggy device tree is worth checking.

That would end up renaming or removing macro.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to