qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>
Cc: Alexander Bulekov <alxndr@bu.edu>, Cornelia Huck <cohuck@redhat.com>
Subject: [PULL 19/19] s390x: Avoid variable size warning in ipl.h
Date: Tue, 10 Nov 2020 12:11:32 +0100	[thread overview]
Message-ID: <20201110111132.559399-20-thuth@redhat.com> (raw)
In-Reply-To: <20201110111132.559399-1-thuth@redhat.com>

From: Daniele Buono <dbuono@linux.vnet.ibm.com>

S390IPLState contains two IplParameterBlock, which may in turn have
either a IPLBlockPV or a IplBlockFcp, both ending with a variable
sized field (an array).

This causes a warning with clang 11 or greater, which checks that
variable sized type are only allocated at the end of the struct:

In file included from ../qemu-cfi-v3/target/s390x/diag.c:21:
../qemu-cfi-v3/hw/s390x/ipl.h:161:23: error: field 'iplb' with variable sized type 'IplParameterBlock' (aka 'union IplParameterBlock') not at the end of a struct or class is a GNU extension [-Werror,-Wgnu-variable-sized-type-not-at-end]
    IplParameterBlock iplb;
                      ^
../qemu-cfi-v3/hw/s390x/ipl.h:162:23: error: field 'iplb_pv' with variable sized type 'IplParameterBlock' (aka 'union IplParameterBlock') not at the end of a struct or class is a GNU extension [-Werror,-Wgnu-variable-sized-type-not-at-end]
    IplParameterBlock iplb_pv;

In this case, however, the warning is a false positive, because
IPLBlockPV and IplBlockFcp are allocated in a union wrapped at 4K,
making the union non-variable sized.

Fix the warning by turning the two variable sized arrays into arrays
of size 0. This avoids the compiler error and should produce the
same code.

Signed-off-by: Daniele Buono <dbuono@linux.vnet.ibm.com>
Message-Id: <20201105221905.1350-5-dbuono@linux.vnet.ibm.com>
Acked-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 hw/s390x/ipl.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/s390x/ipl.h b/hw/s390x/ipl.h
index 9e90169695..dfc6dfd89c 100644
--- a/hw/s390x/ipl.h
+++ b/hw/s390x/ipl.h
@@ -32,7 +32,7 @@ struct IPLBlockPV {
     uint32_t num_comp;          /* 0x74 */
     uint64_t pv_header_addr;    /* 0x78 */
     uint64_t pv_header_len;     /* 0x80 */
-    struct IPLBlockPVComp components[];
+    struct IPLBlockPVComp components[0];
 } QEMU_PACKED;
 typedef struct IPLBlockPV IPLBlockPV;
 
@@ -63,7 +63,7 @@ struct IplBlockFcp {
     uint64_t br_lba;
     uint32_t scp_data_len;
     uint8_t  reserved6[260];
-    uint8_t  scp_data[];
+    uint8_t  scp_data[0];
 } QEMU_PACKED;
 typedef struct IplBlockFcp IplBlockFcp;
 
-- 
2.18.4



  parent reply	other threads:[~2020-11-10 11:34 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-10 11:11 [PULL 00/19] qtests, gitlab, s390x and misc patches Thomas Huth
2020-11-10 11:11 ` [PULL 01/19] meson: always include contrib/libvhost-user Thomas Huth
2020-11-10 11:11 ` [PULL 02/19] tests/vm: update openbsd to release 6.8 Thomas Huth
2020-11-10 11:11 ` [PULL 03/19] device-crash-test: Check if path is actually an executable file Thomas Huth
2020-11-10 11:11 ` [PULL 04/19] qtest: Fix bad printf format specifiers Thomas Huth
2020-11-10 11:11 ` [PULL 05/19] tests/qtest/tpm: Remove redundant check in the tpm_test_swtpm_test() Thomas Huth
2020-11-10 11:11 ` [PULL 06/19] gitlab-ci: Drop generic cache rule Thomas Huth
2020-11-10 11:11 ` [PULL 07/19] MAINTAINERS: Add gitlab-pipeline-status script to GitLab CI section Thomas Huth
2020-11-10 11:11 ` [PULL 08/19] docs/fuzz: rST-ify the fuzzing documentation Thomas Huth
2020-11-10 11:11 ` [PULL 09/19] docs/fuzz: update fuzzing documentation post-meson Thomas Huth
2020-11-10 11:11 ` [PULL 10/19] scripts/oss-fuzz: give all fuzzers -target names Thomas Huth
2020-11-10 11:11 ` [PULL 11/19] fuzz: Make fork_fuzz.ld compatible with LLVM's LLD Thomas Huth
2020-11-10 11:11 ` [PULL 12/19] configure: surface deprecated targets in the help output Thomas Huth
2020-11-10 11:11 ` [PULL 13/19] gitlab: publish the docs built during CI Thomas Huth
2020-11-10 11:11 ` [PULL 14/19] gitlab: force enable docs build in Fedora, Ubuntu, Debian Thomas Huth
2020-11-10 11:11 ` [PULL 15/19] docs: add "page source" link to sphinx documentation Thomas Huth
2020-11-10 11:11 ` [PULL 16/19] fuzz: add virtio-blk fuzz target Thomas Huth
2020-11-10 11:11 ` [PULL 17/19] qtest: Update references to parse_escape() in comments Thomas Huth
2020-11-10 11:11 ` [PULL 18/19] s390x: fix clang 11 warnings in cpu_models.c Thomas Huth
2020-11-10 11:11 ` Thomas Huth [this message]
2020-11-10 14:58 ` [PULL 00/19] qtests, gitlab, s390x and misc patches Peter Maydell

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=20201110111132.559399-20-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=alxndr@bu.edu \
    --cc=cohuck@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@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 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).