Comment # 9 on bug 1158189 from
(In reply to Richard Biener from comment #8)
> (In reply to Michael Chang from comment #7)
> > I used this patch to calculate the pointer without taking address of indexed
> > dev_roles array and it worked fine for me.
> > 
> > > Index: grub-2.04/grub-core/disk/mdraid1x_linux.c
> > > ===================================================================
> > > --- grub-2.04.orig/grub-core/disk/mdraid1x_linux.c
> > > +++ grub-2.04/grub-core/disk/mdraid1x_linux.c
> > > @@ -178,7 +178,7 @@ grub_mdraid_detect (grub_disk_t disk,
> > >  	return NULL;
> > >  
> > >        if (grub_disk_read (disk, sector, 
> > > -			  (char *) &sb.dev_roles[grub_le_to_cpu32 (sb.dev_number)]
> > > +			  (char *) (sb.dev_roles + grub_le_to_cpu32 (sb.dev_number))
> > >  			  - (char *) &sb,
> > >  			  sizeof (role), &role))
> > >  	return NULL;
> 
> Technically it still does the same but if it works around the warning it's
> fine.

Thanks to looking into this.

Given that there is no offsetof marco defined in grub (although it is not
difficult to define one) and also it is common to use pointer math to calculate
the size/offset in many different places. I'd pick this way as the whole point
here is just to get the offset to be read from disk thus the operation that
index into array members is undue here.

> 
> > And after I encountered more errors from gcc-10 ...
> 
> *sigh*

Good news is that I seems to figure out the reason, and am working on the
patch.


You are receiving this mail because: