[Qemu-devel] [PATCH] seccomp: Work-around GCC 4.x bug in gnu99 mode

Thomas Huth posted 1 patch 6 years, 11 months ago
Test docker-mingw@fedora failed
Test docker-clang@ubuntu passed
Test asan passed
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1547573562-32754-1-git-send-email-thuth@redhat.com
Maintainers: Eduardo Otubo <otubo@redhat.com>
qemu-seccomp.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[Qemu-devel] [PATCH] seccomp: Work-around GCC 4.x bug in gnu99 mode
Posted by Thomas Huth 6 years, 11 months ago
We'd like to compile QEMU with -std=gnu99, but GCC 4.8 currently
fails to compile qemu-seccomp.c in this mode:

qemu-seccomp.c:45:1: error: initializer element is not constant
 };
 ^
qemu-seccomp.c:45:1: error: (near initialization for ‘sched_setscheduler_arg[0]’)

This is due to a compiler bug which has just been fixed in GCC 5.0:

 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63567

Since we still want to support GCC 4.8 for a while and also want to use
gnu99 mode, work-around the issue by expanding the macro manually.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 qemu-seccomp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/qemu-seccomp.c b/qemu-seccomp.c
index 5c73e6a..36d5829 100644
--- a/qemu-seccomp.c
+++ b/qemu-seccomp.c
@@ -41,7 +41,8 @@ struct QemuSeccompSyscall {
 };
 
 const struct scmp_arg_cmp sched_setscheduler_arg[] = {
-    SCMP_A1(SCMP_CMP_NE, SCHED_IDLE)
+    /* was SCMP_A1(SCMP_CMP_NE, SCHED_IDLE), but expanded due to GCC 4.x bug */
+    { .arg = 1, .op = SCMP_CMP_NE, .datum_a = SCHED_IDLE }
 };
 
 static const struct QemuSeccompSyscall blacklist[] = {
-- 
1.8.3.1


Re: [Qemu-devel] [PATCH] seccomp: Work-around GCC 4.x bug in gnu99 mode
Posted by Daniel P. Berrangé 6 years, 11 months ago
On Tue, Jan 15, 2019 at 06:32:42PM +0100, Thomas Huth wrote:
> We'd like to compile QEMU with -std=gnu99, but GCC 4.8 currently
> fails to compile qemu-seccomp.c in this mode:
> 
> qemu-seccomp.c:45:1: error: initializer element is not constant
>  };
>  ^
> qemu-seccomp.c:45:1: error: (near initialization for ‘sched_setscheduler_arg[0]’)
> 
> This is due to a compiler bug which has just been fixed in GCC 5.0:
> 
>  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63567
> 
> Since we still want to support GCC 4.8 for a while and also want to use
> gnu99 mode, work-around the issue by expanding the macro manually.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  qemu-seccomp.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/qemu-seccomp.c b/qemu-seccomp.c
> index 5c73e6a..36d5829 100644
> --- a/qemu-seccomp.c
> +++ b/qemu-seccomp.c
> @@ -41,7 +41,8 @@ struct QemuSeccompSyscall {
>  };
>  
>  const struct scmp_arg_cmp sched_setscheduler_arg[] = {
> -    SCMP_A1(SCMP_CMP_NE, SCHED_IDLE)
> +    /* was SCMP_A1(SCMP_CMP_NE, SCHED_IDLE), but expanded due to GCC 4.x bug */
> +    { .arg = 1, .op = SCMP_CMP_NE, .datum_a = SCHED_IDLE }
>  };

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

Re: [Qemu-devel] [PATCH] seccomp: Work-around GCC 4.x bug in gnu99 mode
Posted by Eduardo Otubo 6 years, 10 months ago
On 15/01/2019 - 18:32:42, Thomas Huth wrote:
> We'd like to compile QEMU with -std=gnu99, but GCC 4.8 currently
> fails to compile qemu-seccomp.c in this mode:
> 
> qemu-seccomp.c:45:1: error: initializer element is not constant
>  };
>  ^
> qemu-seccomp.c:45:1: error: (near initialization for ‘sched_setscheduler_arg[0]’)
> 
> This is due to a compiler bug which has just been fixed in GCC 5.0:
> 
>  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63567
> 
> Since we still want to support GCC 4.8 for a while and also want to use
> gnu99 mode, work-around the issue by expanding the macro manually.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  qemu-seccomp.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/qemu-seccomp.c b/qemu-seccomp.c
> index 5c73e6a..36d5829 100644
> --- a/qemu-seccomp.c
> +++ b/qemu-seccomp.c
> @@ -41,7 +41,8 @@ struct QemuSeccompSyscall {
>  };
>  
>  const struct scmp_arg_cmp sched_setscheduler_arg[] = {
> -    SCMP_A1(SCMP_CMP_NE, SCHED_IDLE)
> +    /* was SCMP_A1(SCMP_CMP_NE, SCHED_IDLE), but expanded due to GCC 4.x bug */
> +    { .arg = 1, .op = SCMP_CMP_NE, .datum_a = SCHED_IDLE }
>  };
>  
>  static const struct QemuSeccompSyscall blacklist[] = {
> -- 
> 1.8.3.1
> 
Acked-by: Eduardo Otubo <otubo@redhat.com>
Re: [Qemu-devel] [PATCH] seccomp: Work-around GCC 4.x bug in gnu99 mode
Posted by no-reply@patchew.org 6 years, 10 months ago
Patchew URL: https://patchew.org/QEMU/1547573562-32754-1-git-send-email-thuth@redhat.com/



Hi,

This series failed the docker-mingw@fedora build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-mingw@fedora SHOW_ENV=1 J=14
=== TEST SCRIPT END ===

  CC      backends/rng-egd.o
  CC      backends/tpm.o
/tmp/qemu-test/src/block/sheepdog.c: In function 'find_vdi_name':
/tmp/qemu-test/src/block/sheepdog.c:1239:5: error: 'strncpy' specified bound 256 equals destination size [-Werror=stringop-truncation]
     strncpy(buf + SD_MAX_VDI_LEN, tag, SD_MAX_VDI_TAG_LEN);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors


The full log is available at
http://patchew.org/logs/1547573562-32754-1-git-send-email-thuth@redhat.com/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
Re: [Qemu-devel] [PATCH] seccomp: Work-around GCC 4.x bug in gnu99 mode
Posted by Eduardo Otubo 6 years, 10 months ago
On 23/01/2019 - 07:57:51, no-reply@patchew.org wrote:
> Patchew URL: https://patchew.org/QEMU/1547573562-32754-1-git-send-email-thuth@redhat.com/
> 
> 
> 
> Hi,
> 
> This series failed the docker-mingw@fedora build test. Please find the testing commands and
> their output below. If you have Docker installed, you can probably reproduce it
> locally.
> 
> === TEST SCRIPT BEGIN ===
> #!/bin/bash
> time make docker-test-mingw@fedora SHOW_ENV=1 J=14
> === TEST SCRIPT END ===
> 
>   CC      backends/rng-egd.o
>   CC      backends/tpm.o
> /tmp/qemu-test/src/block/sheepdog.c: In function 'find_vdi_name':
> /tmp/qemu-test/src/block/sheepdog.c:1239:5: error: 'strncpy' specified bound 256 equals destination size [-Werror=stringop-truncation]
>      strncpy(buf + SD_MAX_VDI_LEN, tag, SD_MAX_VDI_TAG_LEN);
>      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
> 
> 
> The full log is available at
> http://patchew.org/logs/1547573562-32754-1-git-send-email-thuth@redhat.com/testing.docker-mingw@fedora/?type=message.
> ---
> Email generated automatically by Patchew [http://patchew.org/].
> Please send your feedback to patchew-devel@redhat.com

This issue was not introduced by the patch itself.
Will send a pull request anyways.

-- 
Eduardo Otubo
Re: [Qemu-devel] [PATCH] seccomp: Work-around GCC 4.x bug in gnu99 mode
Posted by Philippe Mathieu-Daudé 6 years, 11 months ago
On 1/15/19 6:32 PM, Thomas Huth wrote:
> We'd like to compile QEMU with -std=gnu99, but GCC 4.8 currently
> fails to compile qemu-seccomp.c in this mode:
> 
> qemu-seccomp.c:45:1: error: initializer element is not constant
>  };
>  ^
> qemu-seccomp.c:45:1: error: (near initialization for ‘sched_setscheduler_arg[0]’)
> 
> This is due to a compiler bug which has just been fixed in GCC 5.0:
> 
>  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63567
> 
> Since we still want to support GCC 4.8 for a while and also want to use
> gnu99 mode, work-around the issue by expanding the macro manually.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---
>  qemu-seccomp.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/qemu-seccomp.c b/qemu-seccomp.c
> index 5c73e6a..36d5829 100644
> --- a/qemu-seccomp.c
> +++ b/qemu-seccomp.c
> @@ -41,7 +41,8 @@ struct QemuSeccompSyscall {
>  };
>  
>  const struct scmp_arg_cmp sched_setscheduler_arg[] = {
> -    SCMP_A1(SCMP_CMP_NE, SCHED_IDLE)
> +    /* was SCMP_A1(SCMP_CMP_NE, SCHED_IDLE), but expanded due to GCC 4.x bug */
> +    { .arg = 1, .op = SCMP_CMP_NE, .datum_a = SCHED_IDLE }
>  };
>  
>  static const struct QemuSeccompSyscall blacklist[] = {
>