qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Marcel Holtmann <marcel@holtmann.org>,
	qemu-devel@nongnu.org, mst@redhat.com, xieyongji@bytedance.com
Subject: Re: [PATCH v3 02/10] libvhost-user: Replace typeof with __typeof__
Date: Thu, 22 Dec 2022 09:16:29 +0100	[thread overview]
Message-ID: <2196cf80-5f59-37a5-1efe-7e4ff9767109@redhat.com> (raw)
In-Reply-To: <79297841f1aad83d85297afef99369004d9d19a4.1671628158.git.marcel@holtmann.org>

On 12/21/22 14:10, Marcel Holtmann wrote:
> Strictly speaking only -std=gnu99 support the usage of typeof and for
> easier inclusion in external projects, it is better to use __typeof__.
> 
>    CC       libvhost-user.o
> libvhost-user.c: In function ‘vu_log_queue_fill’:
> libvhost-user.c:86:13: error: implicit declaration of function ‘typeof’ [-Werror=implicit-function-declaration]
>     86 |             typeof(x) _min1 = (x);              \
>        |             ^~~~~~
> 
> Changing these two users of typeof makes the compiler happy and no extra
> flags or pragmas need to be provided.
> 
> Signed-off-by: Marcel Holtmann<marcel@holtmann.org>
> Reviewed-by: Philippe Mathieu-Daudé<philmd@linaro.org>

The build system uses "c_std=gnu99".  If you are extracting 
libvhost-user and not using its build files, you need to add --std=gnu99 
yourself when compiling.

If you really don't want to do that, as long as it's just a couple 
underscores that's fine I guess, but mixed declarations and code are 
going to reappear sooner or later.  Please add a patch like this:

diff --git a/subprojects/libvhost-user/meson.build 
b/subprojects/libvhost-user/meson.build
index 39825d9404ae..5deecbfe377d 100644
--- a/subprojects/libvhost-user/meson.build
+++ b/subprojects/libvhost-user/meson.build
@@ -1,6 +1,13 @@
  project('libvhost-user', 'c',
          license: 'GPL-2.0-or-later',
-        default_options: ['c_std=gnu99'])
+        default_options: ['warning_level=1', 'c_std=gnu99'])
+
+cc = meson.get_compiler('c')
+add_project_arguments(cc.get_supported_arguments(
+  '-Wsign-compare',
+  '-Wdeclaration-after-statement',
+  '-Wstrict-aliasing'),
+  native: false, language: 'c')

  threads = dependency('threads')
  glib = dependency('glib-2.0')


to avoid regressions, and likewise for libvduse.

Paolo



  reply	other threads:[~2022-12-22  8:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-21 13:10 [PATCH v3 00/10] Compiler warning fixes for libvhost-user,libvduse Marcel Holtmann
2022-12-21 13:10 ` [PATCH v3 01/10] libvhost-user: Provide _GNU_SOURCE when compiling outside of QEMU Marcel Holtmann
2022-12-21 13:10 ` [PATCH v3 02/10] libvhost-user: Replace typeof with __typeof__ Marcel Holtmann
2022-12-22  8:16   ` Paolo Bonzini [this message]
2022-12-22 20:37     ` Marcel Holtmann
2022-12-21 13:10 ` [PATCH v3 03/10] libvhost-user: Cast rc variable to avoid compiler warning Marcel Holtmann
2022-12-21 13:10 ` [PATCH v3 04/10] libvhost-user: Use unsigned int i for some for-loop iterations Marcel Holtmann
2022-12-21 13:10 ` [PATCH v3 05/10] libvhost-user: Declare uffdio_register early to make it C90 compliant Marcel Holtmann
2022-12-21 13:10 ` [PATCH v3 06/10] libvhost-user: Change dev->postcopy_ufd assignment " Marcel Holtmann
2022-12-21 13:10 ` [PATCH v3 07/10] libvhost-user: Switch to unsigned int for inuse field in struct VuVirtq Marcel Holtmann
2022-12-21 13:10 ` [PATCH v3 08/10] libvduse: Provide _GNU_SOURCE when compiling outside of QEMU Marcel Holtmann
2022-12-21 13:10 ` [PATCH v3 09/10] libvduse: Switch to unsigned int for inuse field in struct VduseVirtq Marcel Holtmann
2022-12-21 13:10 ` [PATCH v3 10/10] libvduse: Fix assignment in vring_set_avail_event Marcel Holtmann
2022-12-22  8:09   ` Paolo Bonzini
2022-12-22 20:38     ` Marcel Holtmann

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=2196cf80-5f59-37a5-1efe-7e4ff9767109@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=marcel@holtmann.org \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=xieyongji@bytedance.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).