From: Michael Chang <mchang@suse.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Cc: <pmenzel@molgen.mpg.de>
Subject: Re: disk/mdraid1x_linux.c:181:15: warning: array subscript ...
Date: Thu, 26 Mar 2020 11:08:54 +0800 [thread overview]
Message-ID: <20200326030854.GA4258@mercury> (raw)
In-Reply-To: <6700719198161959727@scdbackup.webframe.org>
On Wed, Mar 25, 2020 at 12:13:49PM +0100, Thomas Schmitt wrote:
> Hi,
>
> Michael Chang wrote in patch 2/2:
> > ../../grub-core/fs/zfs/zfs.c:2263:44: error: array subscript '<unknown>' is
> > outside the bounds of an interior zero-length array 'grub_uint16_t[0]' {aka
> > 'short unsigned int[0]'} [-Werror=zero-length-bounds]
> > [...]
> > The l_hash[0] is apparnetly an interior member to the enclosed structure
> > [...] the l_entries[0] is used to get proper alignment to access leaf chunks
>
> That's what i call a dirty hack.
>
> I wonder what gcc would say to a union of [0]-sized arrays as last
> member of the struct type:
>
> struct typedef struct zap_leaf_phys {
> ...
> union {
> grub_uint16_t l_hash[0];
> grub_properly_aligned_t l_entries[0];
> } l_;
> } zap_leaf_phys_t;
As far as I know the union will store different types in same memory
location, thus the allocation is determined by the largest member in the
union, so does the padding has to meet the alignment requirement by the
largest member.
So in this case l_hash[0] (2 bytes) will be aligned to
grub_properly_aligned_t (8 bytes) and for the result is desired or not
really depends on what you want to achieve.
>
> Mine likes such a gesture, but it is way behind in respect to modern bitrot.
Admittedly that would produce much more readable code, but it is just
not work for the extraordinary case here because of specific requirment
to the alignment.
>
>
> So in the end, your patch looks like the solid and unambiguous way to
> implement what is desired.
>
>
> > It would be great if you can help to test patch to solve the build
> > problem for gcc-10 in your system or not.
>
> Due to lack of modernity i can only contribute statements that the
> concepts and motivations of your two patches look good to me.
>
> (I also lack the occasion to test the two use cases.
> Just lurking here for grub-mkrescue issues, where i provide the last stage
> of packing up the ISO image.)
The grub-mkrescue is a gem, it never disappoints me whenever I need it.
:)
Thanks a lot for your feedback.
Michael
>
>
> Have a nice day :)
>
> Thomas
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
next prev parent reply other threads:[~2020-03-26 3:09 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-24 4:00 grub/head build with pre-release GCC10 ; fail @ "grub-core/disk/mdraid1x_linux.c:181:15: error: ..." PGNet Dev
2020-03-24 14:51 ` Paul Menzel
2020-03-24 16:52 ` PGNet Dev
2020-03-24 17:04 ` PGNet Dev
2020-03-24 17:54 ` disk/mdraid1x_linux.c:181:15: warning: array subscript Thomas Schmitt
2020-03-25 7:27 ` Michael Chang
2020-03-25 11:13 ` Thomas Schmitt
2020-03-26 3:08 ` Michael Chang [this message]
2020-03-25 15:35 ` PGNet Dev
2020-03-25 15:52 ` Paul Menzel
2020-03-25 15:54 ` PGNet Dev
2020-03-25 16:08 ` Paul Menzel
2020-03-26 3:29 ` Michael Chang
2020-03-26 4:05 ` PGNet Dev
2020-03-25 18:35 ` Daniel Kiper
2020-03-26 4:13 ` Michael Chang
2020-03-26 4:24 ` Michael Chang
-- strict thread matches above, loose matches on Subject: below --
2020-03-20 8:24 disk/mdraid1x_linux.c:181:15: warning: array subscript <unknown> is outside array bounds of ‘grub_uint16_t[0]’ {aka ‘short unsigned int[0]’} [-Warray-bounds] Paul Menzel
2020-03-20 13:05 ` disk/mdraid1x_linux.c:181:15: warning: array subscript Thomas Schmitt
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=20200326030854.GA4258@mercury \
--to=mchang@suse.com \
--cc=grub-devel@gnu.org \
--cc=pmenzel@molgen.mpg.de \
/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.