On Wed, Mar 23, 2022 at 04:47:51PM +1100, Daniel Axtens wrote:
> > s/struct grub_mm_region/grub_mm_region_t/
> > s/struct grub_mm_header/grub_mm_header_t/
>
> The problem is that grub_mm_{region,header}_t is a pointer type, not a
> struct type. So sizeof (grub_mm_region_t) == sizeof(void *). You also
> can't do sizeof (*grub_mm_region_t), because you can't dereference a
> type. If there's a better way to express this I am open to it, but for
> now I will stick with the struct type...

OK.

> >> +                 sizeof(struct grub_mm_header)) == 0);
> >
> > I think this check is insufficient. The GRUB_MM_ALIGN should be checked
> > somehow too. E.g. if sizeof(struct grub_mm_region) == 16,
> > sizeof(struct grub_mm_header) == 8 and GRUB_MM_ALIGN == 32 then assert
> > above will pass but the GRUB will blow up later. Of course numbers are not
> > real but I chose them to show the problem. Hmmm... If we could choose
> > grub_mm_region_t and grub_mm_header_t sizes properly then probably we
> > could drop GRUB_MM_ALIGN...
> >
>
> I have added that sizeof(struct header) == GRUB_MM_ALIGN. GRUB_MM_ALIGN
> is supposed to align you to a cell, and a header is supposed to be 1
> cell.

Cool!

> We probably _could_ do away with the constant but I think that requires
> a bit more close thought.

Yeah, I think additional GRUB_MM_ALIGN check is enough right now.
It does not make sense to spent more time on this and block the
other series any longer.

Thanks,

Daniel

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to