This did not cause real problem but is good for reproducible builds. I hit
it with recent bootinfoscript that displays embedded config; I was puzzled
by random garbage at the end.
Prezero memory buffer used to assemble core.img. This makes individual
memset redundant. Also ensure buffer is filled with zeroes in several other
places.
Also remove redundant zeroing code where we fill in the whole memory block
anyway.
gcc5 reports:
../util/mkimage.c: In function 'grub_install_get_image_target':
../util/mkimage.c:954:5: error: loop exit may only be reached after undefined behavior [-Werror=aggressive-loop-optimizations]
&& j < ARRAY_SIZE (image_targets[i].names); j++)
^
../util/mkimage.c:953:39: note: possible undefined statement is here
for (j = 0; image_targets[i].names[j]
^
Well, let's move the index 'j' test before accesing the array to:
1) make the loop obvious
2) make gcc happy
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
the function of these files exceeds what can be sanely handled in shell
in posix-comaptible way. Also writing it in C extends the functionality
to non-UNIX-like OS and minimal environments.