* fdtdump.c: Compile error with GCC 11
@ 2021-01-04 8:39 Sebastian Huber
[not found] ` <db5d86de-fa1b-9d44-1188-edb81578bc00-L1vi/lXTdtsBbLBgBO8hYIQuADTiUCJX@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Sebastian Huber @ 2021-01-04 8:39 UTC (permalink / raw)
To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA
Hello,
I get a compile error with GCC 11 in fdtdump.c:
In file included from fdtdump.c:14:
fdtdump.c: In function ‘main’:
libfdt/libfdt.h:256:28: error: array subscript ‘struct fdt_header[0]’ is
partly outside array bounds of ‘unsigned char[4]’ [-Werror=array-bounds]
256 | fdth->name = cpu_to_fdt32(val); \
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
libfdt/libfdt.h:258:1: note: in expansion of macro ‘fdt_set_hdr_’
258 | fdt_set_hdr_(magic);
| ^~~~~~~~~~~~
fdtdump.c:216:31: note: while referencing ‘smagic’
216 | unsigned char smagic[FDT_MAGIC_SIZE];
| ^~~~~~
cc1: all warnings being treated as errors
--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber-L1vi/lXTdtsBbLBgBO8hYIQuADTiUCJX@public.gmane.org
phone: +49-89-18 94 741 - 16
fax: +49-89-18 94 741 - 08
Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
^ permalink raw reply [flat|nested] 4+ messages in thread[parent not found: <db5d86de-fa1b-9d44-1188-edb81578bc00-L1vi/lXTdtsBbLBgBO8hYIQuADTiUCJX@public.gmane.org>]
* Re: fdtdump.c: Compile error with GCC 11 [not found] ` <db5d86de-fa1b-9d44-1188-edb81578bc00-L1vi/lXTdtsBbLBgBO8hYIQuADTiUCJX@public.gmane.org> @ 2021-01-06 3:54 ` David Gibson [not found] ` <20210106035431.GB3209-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org> 0 siblings, 1 reply; 4+ messages in thread From: David Gibson @ 2021-01-06 3:54 UTC (permalink / raw) To: Sebastian Huber; +Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 2385 bytes --] On Mon, Jan 04, 2021 at 09:39:00AM +0100, Sebastian Huber wrote: > Hello, > > I get a compile error with GCC 11 in fdtdump.c: > > In file included from fdtdump.c:14: > fdtdump.c: In function ‘main’: > libfdt/libfdt.h:256:28: error: array subscript ‘struct fdt_header[0]’ is > partly outside array bounds of ‘unsigned char[4]’ [-Werror=array-bounds] > 256 | fdth->name = cpu_to_fdt32(val); \ > | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~ > libfdt/libfdt.h:258:1: note: in expansion of macro ‘fdt_set_hdr_’ > 258 | fdt_set_hdr_(magic); > | ^~~~~~~~~~~~ > fdtdump.c:216:31: note: while referencing ‘smagic’ > 216 | unsigned char smagic[FDT_MAGIC_SIZE]; > | ^~~~~~ > cc1: all warnings being treated as errors Ah, I think I see what's going wrong here. I don't have easy access to gcc 11 to test with, so can you give this draft patch a test: From 6307635b052b55cba6970ae3fb70f33259c572a4 Mon Sep 17 00:00:00 2001 From: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org> Date: Wed, 6 Jan 2021 14:52:26 +1100 Subject: [PATCH] fdtdump: Fix gcc11 warning In one place, fdtdump abuses fdt_set_magic(), passing it just a small char array instead of the full fdt header it expects. That's relying on the fact that in fact fdt_set_magic() will only actually access the first 4 bytes of the buffer. This trips a new warning in GCC 11 - and it's entirely possible it was always UB. So, don't do that. Signed-off-by: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org> --- fdtdump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdtdump.c b/fdtdump.c index 9613bef..d9fb374 100644 --- a/fdtdump.c +++ b/fdtdump.c @@ -217,7 +217,7 @@ int main(int argc, char *argv[]) char *p = buf; char *endp = buf + len; - fdt_set_magic(smagic, FDT_MAGIC); + fdt32_st(smagic, FDT_MAGIC); /* poor man's memmem */ while ((endp - p) >= FDT_MAGIC_SIZE) { -- 2.29.2 -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply related [flat|nested] 4+ messages in thread
[parent not found: <20210106035431.GB3209-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org>]
* Re: fdtdump.c: Compile error with GCC 11 [not found] ` <20210106035431.GB3209-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org> @ 2021-01-15 5:22 ` Sebastian Huber [not found] ` <8822ec89-7782-7608-cae5-e62770e28771-L1vi/lXTdtsBbLBgBO8hYIQuADTiUCJX@public.gmane.org> 0 siblings, 1 reply; 4+ messages in thread From: Sebastian Huber @ 2021-01-15 5:22 UTC (permalink / raw) To: David Gibson; +Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA On 06/01/2021 04:54, David Gibson wrote: > Ah, I think I see what's going wrong here. I don't have easy access > to gcc 11 to test with, so can you give this draft patch a test: Sorry for the delay. This patch fixes the dtc build problem with GCC 11. There were no other issues. -- embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.huber-L1vi/lXTdtsBbLBgBO8hYIQuADTiUCJX@public.gmane.org phone: +49-89-18 94 741 - 16 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht München Registernummer: HRB 157899 Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler Unsere Datenschutzerklärung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <8822ec89-7782-7608-cae5-e62770e28771-L1vi/lXTdtsBbLBgBO8hYIQuADTiUCJX@public.gmane.org>]
* Re: fdtdump.c: Compile error with GCC 11 [not found] ` <8822ec89-7782-7608-cae5-e62770e28771-L1vi/lXTdtsBbLBgBO8hYIQuADTiUCJX@public.gmane.org> @ 2021-01-18 6:50 ` David Gibson 0 siblings, 0 replies; 4+ messages in thread From: David Gibson @ 2021-01-18 6:50 UTC (permalink / raw) To: Sebastian Huber; +Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 591 bytes --] On Fri, Jan 15, 2021 at 06:22:19AM +0100, Sebastian Huber wrote: > On 06/01/2021 04:54, David Gibson wrote: > > > Ah, I think I see what's going wrong here. I don't have easy access > > to gcc 11 to test with, so can you give this draft patch a test: > Sorry for the delay. This patch fixes the dtc build problem with GCC 11. > There were no other issues. Thanks, fix applied. > -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-01-18 6:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-04 8:39 fdtdump.c: Compile error with GCC 11 Sebastian Huber
[not found] ` <db5d86de-fa1b-9d44-1188-edb81578bc00-L1vi/lXTdtsBbLBgBO8hYIQuADTiUCJX@public.gmane.org>
2021-01-06 3:54 ` David Gibson
[not found] ` <20210106035431.GB3209-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org>
2021-01-15 5:22 ` Sebastian Huber
[not found] ` <8822ec89-7782-7608-cae5-e62770e28771-L1vi/lXTdtsBbLBgBO8hYIQuADTiUCJX@public.gmane.org>
2021-01-18 6:50 ` David Gibson
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).