On Thu, Dec 26, 2024 at 10:41:43AM -0800, Andre Muezerie wrote:
> Removed unused variables and added MSVC specific compiler flag to
> ignore warnings about unused variables, like is being done for
> other compilers.
> 
> Signed-off-by: Andre Muezerie <andre...@linux.microsoft.com>
> ---
>  drivers/common/idpf/base/meson.build       | 13 ++++++++++---
>  drivers/common/idpf/idpf_common_rxtx.c     |  2 --
>  drivers/common/idpf/idpf_common_virtchnl.c |  4 ++--
>  drivers/common/sfc_efx/base/efx_mae.c      |  2 +-
>  drivers/common/sfc_efx/base/efx_table.c    |  1 -
>  drivers/common/sfc_efx/base/meson.build    | 20 +++++++++++++-------
>  6 files changed, 26 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/common/idpf/base/meson.build 
> b/drivers/common/idpf/base/meson.build
> index f30ec7dfc2..c069507f12 100644
> --- a/drivers/common/idpf/base/meson.build
> +++ b/drivers/common/idpf/base/meson.build
> @@ -6,9 +6,16 @@ sources += files(
>          'idpf_controlq_setup.c',
>  )
>  
> -error_cflags = [
> -        '-Wno-unused-variable',
> -]
> +if is_ms_compiler
> +    error_cflags = [
> +            '/wd4101', # unreferenced local variable
> +    ]

Just an idea here, since I see this same flag with the same constant
appearing multiple times in the patches: Would it be worthwhile defining
these MSVC flags as global strings in meson e.g. in a file in the "config"
directory. That would then allow them to put in the flags array using
meaningful names, and avoid the need for putting in the same comment each
time.

if is_ms_compiler
    error_cflags = [
        msvc_no_unref_local_var
    ]

If we want to take this a step further, we could define all common error
flags across all compilers this way, so that we avoid the need for
conditional in each individual meson.build file - we just define the names
of the errors we want and let the string replacement handle the conversion
to the appropriate compiler flag. The names could be, for example, the
gcc/clang error names without the "-W" bit. If no MSVC equivalent they
could be empty strings in those builds.

WDYT?

/Bruce

Reply via email to