Re: disk/mdraid1x_linux.c:181:15: warning: array subscript ...
Hi, i wrote: > >(char *) _roles - (char *) sb > >+ grub_le_to_cpu32 (sb.dev_number) * sizeof(grub_uint16_t) PGNet Dev wrote: > grub-core/disk/mdraid1x_linux.c:183:6: error: cannot convert to a > pointer type My fault. I forgot the "&" before "sb". (char *) _roles - (char *) I invested time in examining the C riddle, not in testing my proposal by at least some dummy. Now this compiles for me without complaint by gcc -Wall struct { char a_array[10]; uint16_t dev_roles[0]; } sb; printf("%u\n", (unsigned int) (((char *) _roles - (char *) ) + 2 * sizeof(uint16_t))); Running this program yields 14 as result. The same as with the equivalent of the old expression printf("%u\n", (unsigned int) ((char *) _roles[2] - (char *) )); > not sure I'm reading your intent from your post, My observation is that not "dev_roles[0]" is to blame for the warning, but rather the computation which involves taking the address of an array element while not a single one is allocated. The resulting number is used as offset in a file, not in the sparsely allocated "struct grub_raid_super_1x sb". My proposal is to avoid "[...]" in the course of the computation. This should be valid for both ways to express an open ended struct: "dev_roles[0]" and "dev_roles[]". Have a nice day :) Thomas ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
Re: grub/head build with pre-release GCC10 ; fail @ "grub-core/disk/mdraid1x_linux.c:181:15: error: ..."
my bad re: patch. pebkac (looking UP might help :-/ ) with diff -ur grub.ORIG/grub-core/disk/mdraid1x_linux.c grub/grub-core/disk/mdraid1x_linux.c --- grub.ORIG/grub-core/disk/mdraid1x_linux.c 2020-03-24 09:24:08.656640265 -0700 +++ grub/grub-core/disk/mdraid1x_linux.c2020-03-24 09:58:27.638619782 -0700 @@ -179,7 +179,8 @@ if (grub_disk_read (disk, sector, (char *) _roles[grub_le_to_cpu32 (sb.dev_number)] - - (char *) , + ((char *) _roles - (char *) sb) + + grub_le_to_cpu32 (sb.dev_number) * sizeof(grub_uint16_t), sizeof (role), )) return NULL; gcc10 build returns, ... make ... grub-core/disk/mdraid1x_linux.c: In function ‘grub_mdraid_detect’: grub-core/disk/mdraid1x_linux.c:182:6: error: cannot convert to a pointer type 182 | ((char *) _roles - (char *) sb) | ^ grub-core/disk/mdraid1x_linux.c:181:16: error: called object is not a function or function pointer 181 | (char *) _roles[grub_le_to_cpu32 (sb.dev_number)] |^~ make[2]: *** [Makefile:7059: grub-core/disk/libgrubmods_a-mdraid1x_linux.o] Error 1 make[2]: Leaving directory '/usr/local/src/grub' make[1]: *** [Makefile:11920: all-recursive] Error 1 make[1]: Leaving directory '/usr/local/src/grub' make: *** [Makefile:3772: all] Error 2 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
Re: grub/head build with pre-release GCC10 ; fail @ "grub-core/disk/mdraid1x_linux.c:181:15: error: ..."
Thomas, On 3/24/20 7:51 AM, Paul Menzel wrote: > Dear PGNet Dev, > > > Already reported and analyzed [1]. It’d be nice, if you could verify Thomas’ > analysis. not sure I'm reading your intent from your post, > ... > I think that the following expression produces the same number without > virtual access to a virtual array member: > >(char *) _roles - (char *) sb >+ grub_le_to_cpu32 (sb.dev_number) * sizeof(grub_uint16_t) > ... with this, diff -ur grub.ORIG/grub-core/disk/mdraid1x_linux.c grub/grub-core/disk/mdraid1x_linux.c --- grub.ORIG/grub-core/disk/mdraid1x_linux.c 2020-03-24 09:24:08.656640265 -0700 +++ grub/grub-core/disk/mdraid1x_linux.c2020-03-24 09:25:20.615871693 -0700 @@ -178,8 +178,9 @@ return NULL; if (grub_disk_read (disk, sector, - (char *) _roles[grub_le_to_cpu32 (sb.dev_number)] - - (char *) , + (char *) _roles + - (char *) sb + + grub_le_to_cpu32 (sb.dev_number) * sizeof(grub_uint16_t), sizeof (role), )) return NULL; I'm seeing, ... gcc -DHAVE_CONFIG_H -I. -Wall -W -DGRUB_UTIL=1 -D_FILE_OFFSET_BITS=64 -I./include -DGRUB_FILE=\"grub-core/disk/mdraid1x_linux.c\" -I. -I. -I. -I. -I./include -I./include -I./grub-core/lib/libgcrypt-grub/src/ -I./grub-core/lib/minilzo -I./grub-core/lib/xzembed -I./grub-core/lib/zstd -DMINILZO_HAVE_CONFIG_H -O3 -Wall -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -march=native -mtune=native -D_FORTIFY_SOURCE=2 -D_FILE_OFFSET_BITS=64 -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wcast-align -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -Werror -fno-builtin -Wno-undef -O3 -Wall -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -march=native -mtune=native -MT grub-core/disk/libgrubmods_a-mdraid1x_linux.o -MD -MP -MF grub-core/disk/.deps-util/libgrubmods_a-mdraid1x_linux.Tpo -c -o grub-core/disk/libgrubmods_a-mdraid1x_linux.o `test -f 'grub-core/disk/mdraid1x_linux.c' || echo './'`grub-core/disk/mdraid1x_linux.c grub-core/disk/mdraid1x_linux.c: In function ‘grub_mdraid_detect’: grub-core/disk/mdraid1x_linux.c:183:6: error: cannot convert to a pointer type 183 | + grub_le_to_cpu32 (sb.dev_number) * sizeof(grub_uint16_t), | ^ make[2]: *** [Makefile:7059: grub-core/disk/libgrubmods_a-mdraid1x_linux.o] Error 1 my patch attempt wrong? or still needs tweaks? ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
Re: grub/head build with pre-release GCC10 ; fail @ "grub-core/disk/mdraid1x_linux.c:181:15: error: ..."
Dear PGNet Dev, Already reported and analyzed [1]. It’d be nice, if you could verify Thomas’ analysis. Kind regards, Paul [1]: https://lists.gnu.org/archive/html/grub-devel/2020-03/msg00206.html ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH] Fix GRUB i386-pc build with Ubuntu gcc
With recent versions of gcc on Ubuntu a very large lzma_decompress.img file is output. (e.g. 134479600 bytes instead of 2864.) This causes grub-mkimage to fail with: "error: Decompressor is too big." This seems to be caused by a section .note.gnu.property that is placed at an offset such that objcopy needs to pad the img file with zeros. This issue is present on: Ubuntu 19.10 with gcc (Ubuntu 8.3.0-26ubuntu1~19.10) 8.3.0 Ubuntu 19.10 with gcc (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008 This issue is not present on: Ubuntu 19.10 with gcc (Ubuntu 7.5.0-3ubuntu1~19.10) 7.5.0 RHEL 8.0 with gcc 8.3.1 20190507 (Red Hat 8.3.1-4) The issue can be fixed by removing the section using objcopy as shown in this patch: Signed-off-by: Simon Hardy --- gentpl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gentpl.py b/gentpl.py index 387588c05..c86550d4f 100644 --- a/gentpl.py +++ b/gentpl.py @@ -766,7 +766,7 @@ def image(defn, platform): if test x$(TARGET_APPLE_LINKER) = x1; then \ $(MACHO2IMG) $< $@; \ else \ - $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version -R .ARM.exidx $< $@; \ + $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version -R .note.gnu.property -R .ARM.exidx $< $@; \ fi """) -- 2.25.0 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel