mkimage: fix build regression in grub_mkimage_load_image
PATCH 1/1 mkimage: fix build regression in grub_mkimage_load_image
The grub_mkimage_load_image function (commit 7542af6, mkimage: refactor a bunch of section data into a struct.) introduces a build regression on SPARC:
cc1: warnings being treated as errors
In file included from util/grub-mkimage32.c:23:
util/grub-mkimagexx.c: In function 'grub_mkimage_load_image32':
util/grub-mkimagexx.c:1968: error: missing initializer util/grub-mkimagexx.c:1968: error: (near initialization for 'smd.sections') make[2]: *** [util/grub_mkimage-grub-mkimage32.o] Error 1
Initialize the entire section_metadata structure.
--- util/grub-mkimagexx.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
util/grub-mkimagexx.c +1 -1
@@ -1965,7 +1965,7 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, const struct grub_install_image_target_desc *image_target) {char *kernel_img, *out_img; -struct section_metadata smd = {0 , }; +struct section_metadata smd = {0 ,0 ,0 ,0 ,0 ,0 ,0 };Elf_Ehdr *e;int i;Elf_Shdr *s;
Signature · 1 line
1.7.1
Quoted 11 lines · Eric Snowberg
The
grub_mkimage_load_imagefunction (commit 7542af6, mkimage: refactor a bunch of section data into a struct.) introduces a build regression on SPARC:cc1: warnings being treated as errors
In file included fromutil/grub-mkimage32.c:23:
util/grub-mkimagexx.c: In function 'grub_mkimage_load_image32':
util/grub-mkimagexx.c:1968: error: missing initializerutil/grub-mkimagexx.c:1968: error: (near initialization for 'smd.sections') make[2]: *** [util/grub_mkimage-grub-mkimage32.o] Error 1Initialize the entire
section_metadatastructure.
I'm not against this fix.
That said, looking at the longer term: how do we have this problem still? Or: can we please add one of -std={gnu99,gnu11}[0] by default instead of continuing to "fix" things this way? The C standard has had this to say about initializer-lists for 19 years now, and even longer in drafts:
19 The initialization shall occur in initializer list order, each
initializer provided for a particular subobject overriding any previously listed initializer for the same subobject; all subobjects that are not initialized explicitly shall be initialized implicitly the same as objects that have static storage duration.
The compiler most of us use added this functionality when most of us were in grade school, and the compiler the rest of us use wasn't written yet when this part of the C standard was. I strongly suspect every compiler we care about works just fine with that if we just ask it to.
Can we eliminate having this issue instead of continuing to have to "fix" the *better* form of this code piecemeal every time someone forgets we're hobbled in this particular way?
[0] The current "master" branch seems to work just fine with -std=gnu99 or -std=gnu11, but it breaks with -std=c99 or -std=c11 due to some silly bits of how time.h works.
Signature · 1 line
Peter
Daniel Kiper
AppliedQuoted 11 lines · Peter Jones
Quoted 10 lines · Eric Snowberg
The
grub_mkimage_load_imagefunction (commit 7542af6, mkimage: refactor a bunch of section data into a struct.) introduces a build regression on SPARC:cc1: warnings being treated as errors
In file included fromutil/grub-mkimage32.c:23:
util/grub-mkimagexx.c: In function 'grub_mkimage_load_image32':
util/grub-mkimagexx.c:1968: error: missing initializerutil/grub-mkimagexx.c:1968: error: (near initialization for 'smd.sections') make[2]: *** [util/grub_mkimage-grub-mkimage32.o] Error 1
Quoted 3 lines
Quoted 1 line
Initialize the entire
section_metadatastructure.I'm not against this fix.
Applied as the quick fix. Thanks a lot!
Quoted 12 lines
That said, looking at the longer term: how do we have this problem still? Or: can we please add one of -std={gnu99,gnu11}[0] by default instead of continuing to "fix" things this way? The C standard has had this to say about initializer-lists for 19 years now, and even longer in drafts:
19 The initialization shall occur in initializer list order, each
initializer provided for a particular subobject overriding any previously listed initializer for the same subobject; all subobjects that are not initialized explicitly shall be initialized implicitly the same as objects that have static storage duration.
Quoted 8 lines
The compiler most of us use added this functionality when most of us were in grade school, and the compiler the rest of us use wasn't written yet when this part of the C standard was. I strongly suspect every compiler we care about works just fine with that if we just ask it to.
Can we eliminate having this issue instead of continuing to have to "fix" the *better* form of this code piecemeal every time someone forgets we're hobbled in this particular way?
Peter, if you could prepare a patch(es) and test it/them on i386, x86_64, ARM (CC Leif?) and SPARC (CC Eric?) then I am happy to get it/them.
Thanks,
Daniel