All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Nicholas Piggin" <npiggin@gmail.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>, qemu-devel@nongnu.org
Cc: "Harsh Prateek Bora" <harshpb@linux.ibm.com>,
	"Daniel Henrique Barboza" <danielhb413@gmail.com>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"BALATON Zoltan" <balaton@eik.bme.hu>,
	qemu-ppc@nongnu.org,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>
Subject: Re: [PATCH v3 1/7] meson: Run some compiler checks using -Wno-unused-value
Date: Thu, 19 Dec 2024 10:37:05 +1000	[thread overview]
Message-ID: <D6F99DW9FQ1Y.268COFM41BN5X@gmail.com> (raw)
In-Reply-To: <20241218182106.78800-2-philmd@linaro.org>

On Thu Dec 19, 2024 at 4:21 AM AEST, Philippe Mathieu-Daudé wrote:
> When running Clang static analyzer on macOS I'm getting:
>
>   include/qemu/osdep.h:634:8: error: redefinition of 'iovec'
>     634 | struct iovec {
>         |        ^
>   /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types/_iovec_t.h:31:8: note: previous definition is here
>      31 | struct iovec {
>         |        ^
>   1 error generated.
>
> Looking at meson-logs.txt, the analyzer enables -Wunused-value
> making meson generated code to fail:
>
>     Code:
>     #include <sys/uio.h>
>             void bar(void) {
>                 sizeof(struct iovec);
>             }
>     -----------
>     stderr:
>     meson-private/tmpe8_1b_00/testfile.c:3:13: error: expression result unused [-Werror,-Wunused-value]
>         3 |             sizeof(struct iovec);
>           |             ^~~~~~~~~~~~~~~~~~~~
>     1 error generated.
>     -----------
>     Checking for type "struct iovec" : NO
>
>     Code:
>     #include <utmpx.h>
>             void bar(void) {
>                 sizeof(struct utmpx);
>             }
>     -----------
>     stderr:
>     meson-private/tmp3n0u490p/testfile.c:3:13: error: expression result unused [-Werror,-Wunused-value]
>         3 |             sizeof(struct utmpx);
>           |             ^~~~~~~~~~~~~~~~~~~~
>     1 error generated.
>     -----------
>     Checking for type "struct utmpx" : NO
>
>     Code:
>
>             #include <getopt.h>
>             int main(void) {
>                 /* If it's not defined as a macro, try to use as a symbol */
>                 #ifndef optreset
>                     optreset;
>                 #endif
>                 return 0;
>             }
>     -----------
>     stderr:
>     meson-private/tmp1rzob_os/testfile.c:6:17: error: expression result unused [-Werror,-Wunused-value]
>         6 |                 optreset;
>           |                 ^~~~~~~~
>     1 error generated.
>     -----------
>     Header "getopt.h" has symbol "optreset" : NO
>
>     Code:
>
>             #include <vmnet/vmnet.h>
>             int main(void) {
>                 /* If it's not defined as a macro, try to use as a symbol */
>                 #ifndef VMNET_BRIDGED_MODE
>                     VMNET_BRIDGED_MODE;
>                 #endif
>                 return 0;
>             }
>     -----------
>     stderr:
>     meson-private/tmpl9jgsxpt/testfile.c:6:17: error: expression result unused [-Werror,-Wunused-value]
>         6 |                 VMNET_BRIDGED_MODE;
>           |                 ^~~~~~~~~~~~~~~~~~
>     1 error generated.
>     -----------
>     Header "vmnet/vmnet.h" has symbol "VMNET_BRIDGED_MODE" with dependency appleframeworks: NO
>     ../meson.build:1174: WARNING: vmnet.framework API is outdated, disabling
>
> Fix by explicitly disabling -Wunused-value from these meson checks.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> RFC: Probably meson should do that in has_header_symbol() / has_type()?

I don't know about the build system to answer this, but should we
instead disable -Werror on these tests to be a bit more future-proof?
Compilers often add new warnings or catch more cases of existing
warnings.

Alternative would be to keep -Werror but fail the build if a test
throws a warning, but that seems like a lot more work for little
benefit...

Thanks,
Nick

> ---
>  meson.build | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/meson.build b/meson.build
> index 85f74854735..9d93dcd95d7 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -1189,7 +1189,8 @@ cocoa = dependency('appleframeworks',
>  vmnet = dependency('appleframeworks', modules: 'vmnet', required: get_option('vmnet'))
>  if vmnet.found() and not cc.has_header_symbol('vmnet/vmnet.h',
>                                                'VMNET_BRIDGED_MODE',
> -                                              dependencies: vmnet)
> +                                              dependencies: vmnet,
> +                                              args: '-Wno-unused-value')
>    vmnet = not_found
>    if get_option('vmnet').enabled()
>      error('vmnet.framework API is outdated')
> @@ -2713,7 +2714,7 @@ config_host_data.set('CONFIG_RTNETLINK',
>  config_host_data.set('CONFIG_SYSMACROS',
>                       cc.has_header_symbol('sys/sysmacros.h', 'makedev'))
>  config_host_data.set('HAVE_OPTRESET',
> -                     cc.has_header_symbol('getopt.h', 'optreset'))
> +                     cc.has_header_symbol('getopt.h', 'optreset', args: '-Wno-unused-value'))
>  config_host_data.set('HAVE_IPPROTO_MPTCP',
>                       cc.has_header_symbol('netinet/in.h', 'IPPROTO_MPTCP'))
>  
> @@ -2731,10 +2732,12 @@ config_host_data.set('HAVE_BLK_ZONE_REP_CAPACITY',
>  # has_type
>  config_host_data.set('CONFIG_IOVEC',
>                       cc.has_type('struct iovec',
> -                                 prefix: '#include <sys/uio.h>'))
> +                                 prefix: '#include <sys/uio.h>',
> +                                 args: '-Wno-unused-value'))
>  config_host_data.set('HAVE_UTMPX',
>                       cc.has_type('struct utmpx',
> -                                 prefix: '#include <utmpx.h>'))
> +                                 prefix: '#include <utmpx.h>',
> +                                 args: '-Wno-unused-value'))
>  
>  config_host_data.set('CONFIG_EVENTFD', cc.links('''
>    #include <sys/eventfd.h>



  reply	other threads:[~2024-12-19  0:37 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-18 18:20 [PATCH v3 0/7] hw/ppc: Remove tswap() calls Philippe Mathieu-Daudé
2024-12-18 18:21 ` [PATCH v3 1/7] meson: Run some compiler checks using -Wno-unused-value Philippe Mathieu-Daudé
2024-12-19  0:37   ` Nicholas Piggin [this message]
2024-12-19 17:39     ` Philippe Mathieu-Daudé
2024-12-19 18:14       ` Richard Henderson
2024-12-18 18:21 ` [PATCH v3 2/7] hw/ppc/spapr: Convert HPTE() macro as hpte_get() method Philippe Mathieu-Daudé
2024-12-19  0:08   ` Nicholas Piggin
2024-12-19  6:31   ` Harsh Prateek Bora
2024-12-20 21:29     ` Philippe Mathieu-Daudé
2024-12-18 18:21 ` [PATCH v3 3/7] hw/ppc/spapr: Convert HPTE_VALID() macro as hpte_is_valid() method Philippe Mathieu-Daudé
2024-12-19  0:18   ` Nicholas Piggin
2024-12-18 18:21 ` [PATCH v3 4/7] hw/ppc/spapr: Convert HPTE_DIRTY() macro as hpte_is_dirty() method Philippe Mathieu-Daudé
2024-12-19  0:19   ` Nicholas Piggin
2024-12-19  6:52   ` Harsh Prateek Bora
2024-12-18 18:21 ` [PATCH v3 5/7] hw/ppc/spapr: Convert CLEAN_HPTE() macro as hpte_set_clean() method Philippe Mathieu-Daudé
2024-12-19  0:19   ` Nicholas Piggin
2024-12-19  6:56   ` Harsh Prateek Bora
2024-12-18 18:21 ` [PATCH v3 6/7] hw/ppc/spapr: Convert DIRTY_HPTE() macro as hpte_set_dirty() method Philippe Mathieu-Daudé
2024-12-19  0:19   ` Nicholas Piggin
2024-12-18 18:21 ` [PATCH v3 7/7] hw/ppc/epapr: Do not swap ePAPR magic value Philippe Mathieu-Daudé
2024-12-18 19:18   ` BALATON Zoltan
2024-12-19  0:29     ` Nicholas Piggin
2024-12-19  1:43       ` BALATON Zoltan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D6F99DW9FQ1Y.268COFM41BN5X@gmail.com \
    --to=npiggin@gmail.com \
    --cc=balaton@eik.bme.hu \
    --cc=berrange@redhat.com \
    --cc=danielhb413@gmail.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=harshpb@linux.ibm.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.