[PATCH v4 9/9] config: enable comma warnings

Bruce Richardson bruce.richardson at intel.com
Mon Aug 18 18:36:21 CEST 2025


On Mon, Aug 18, 2025 at 09:18:14AM -0700, Stephen Hemminger wrote:
> Clang (3.9 or later) has a -Wcomma that emits warnings for questionable
> uses of the comma operator.
> 
> Don't enable it for drivers since many drivers still use
> comma operator unnecessarily.
> 
> Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
> Acked-by: Konstantin Ananyev <konstantin.ananyev at huawei.com>
> Acked-by: Chengwen Feng <fengchengwen at huawei.com>
> Acked-by: Morten Brørup <mb at smartsharesystems.com>
> ---
>  config/meson.build  | 1 +
>  drivers/meson.build | 2 +-
>  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/config/meson.build b/config/meson.build
> index f31fef216c..d9ff0e31c0 100644
> --- a/config/meson.build
> +++ b/config/meson.build
> @@ -313,6 +313,7 @@ endif
>  global_cflags = [
>          # additional warnings in alphabetical order
>          '-Wcast-qual',
> +        '-Wcomma',
>          '-Wdeprecated',
>          '-Wformat',
>          '-Wformat-nonliteral',
> diff --git a/drivers/meson.build b/drivers/meson.build
> index b62880db02..4c08a1dd9d 100644
> --- a/drivers/meson.build
> +++ b/drivers/meson.build
> @@ -59,7 +59,7 @@ default_cflags = machine_args
>  default_cflags += ['-DALLOW_EXPERIMENTAL_API']
>  default_cflags += ['-DALLOW_INTERNAL_API']
>  
> -warning_disable_cflags = ['-Wno-format-truncation', '-Wno-address-of-packed-member']
> +warning_disable_cflags = ['-Wno-format-truncation', '-Wno-address-of-packed-member', '-Wno-comma']

Since this patchset has already fixed some drivers, are we at a point where
we can just disable this warning on a driver-by-driver basis rather than
globally? That makes it easier to spot where the issues are and easier
allows incremental improvement.

>  foreach cflag:warning_disable_cflags
>      if cc.has_argument(cflag)
>          default_cflags += cflag
> -- 
> 2.47.2
> 


More information about the dev mailing list