All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cornelia Huck <cohuck@redhat.com>
To: Daniele Buono <dbuono@linux.vnet.ibm.com>
Cc: Thomas Huth <thuth@redhat.com>,
	David Hildenbrand <david@redhat.com>,
	qemu-devel@nongnu.org, Halil Pasic <pasic@linux.ibm.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	"open list:S390-ccw boot" <qemu-s390x@nongnu.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Richard Henderson <rth@twiddle.net>
Subject: Re: [PATCH v3 4/9] s390x: Avoid variable size warning in ipl.h
Date: Mon, 9 Nov 2020 12:14:22 +0100	[thread overview]
Message-ID: <20201109121422.0a663e71.cohuck@redhat.com> (raw)
In-Reply-To: <20201105221905.1350-5-dbuono@linux.vnet.ibm.com>

On Thu,  5 Nov 2020 17:19:00 -0500
Daniele Buono <dbuono@linux.vnet.ibm.com> wrote:

> 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>
> ---
> There is the possibility of removing  IplBlockFcp from
> IplParameterBlock, since it is not actually used.
> This would also allow to entirely remove the definition of
> IplBlockFcp, but we may want to keep it for completeness.

We can easily do that in the future clean-up round, if we want that.

> 
>  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;
>  

For now, this is a nicely small patch.

Acked-by: Cornelia Huck <cohuck@redhat.com>



  reply	other threads:[~2020-11-09 11:15 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-05 22:18 [PATCH v3 0/9] Add support for Control-Flow Integrity Daniele Buono
2020-11-05 22:18 ` [PATCH v3 1/9] fuzz: Make fork_fuzz.ld compatible with LLVM's LLD Daniele Buono
2020-11-06 14:50   ` Alexander Bulekov
2020-11-19 22:06     ` Daniele Buono
2020-12-13  2:51       ` Alexander Bulekov
2020-11-05 22:18 ` [PATCH v3 2/9] s390x: fix clang 11 warnings in cpu_models.c Daniele Buono
2020-11-09 11:12   ` Cornelia Huck
2020-11-05 22:18 ` [PATCH v3 3/9] hw/usb: reorder fields in UASStatus Daniele Buono
2020-11-06 14:28   ` [PATCH-for-5.2? " Philippe Mathieu-Daudé
2020-11-19 16:16     ` Daniele Buono
2021-01-14  8:17       ` Marc-André Lureau
2021-01-14 19:33         ` Daniele Buono
2021-01-18 11:38       ` Philippe Mathieu-Daudé
2021-01-18 16:09         ` Gerd Hoffmann
2020-11-05 22:19 ` [PATCH v3 4/9] s390x: Avoid variable size warning in ipl.h Daniele Buono
2020-11-09 11:14   ` Cornelia Huck [this message]
2020-11-05 22:19 ` [PATCH v3 5/9] scsi: fix overflow in scsi_disk_new_request_dump Daniele Buono
2020-11-06 14:32   ` [PATCH-for-5.2? " Philippe Mathieu-Daudé
2020-11-06 14:43     ` Philippe Mathieu-Daudé
2020-11-09 13:26       ` Philippe Mathieu-Daudé
2020-11-19 16:44         ` Daniele Buono
2020-11-05 22:19 ` [PATCH v3 6/9] configure,meson: add option to enable LTO Daniele Buono
2020-11-05 22:19 ` [PATCH v3 7/9] cfi: Initial support for cfi-icall in QEMU Daniele Buono
2020-11-05 22:19 ` [PATCH v3 8/9] check-block: enable iotests with cfi-icall Daniele Buono
2020-11-05 22:19 ` [PATCH v3 9/9] configure,meson: support Control-Flow Integrity Daniele Buono
2020-11-06 12:47 ` [PATCH v3 0/9] Add support for " Cornelia Huck
2020-11-06 13:35   ` Daniele Buono
2020-11-06 14:58     ` Alexander Bulekov
2020-11-19 21:58       ` Daniele Buono

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=20201109121422.0a663e71.cohuck@redhat.com \
    --to=cohuck@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=david@redhat.com \
    --cc=dbuono@linux.vnet.ibm.com \
    --cc=pasic@linux.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=thuth@redhat.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 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.