Skip to contentSkip to conversation

sandbox: p2sb: Silence compiler warning

PATCH New Simon Glass 5 participants 7 messages Feb 8, 2020 – Mar 3, 2020 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sandbox: p2sb: Silence compiler warning

Some compilers produce a warning about 'child' being used before init. Silence this by setting to NULL at the start.

---

 drivers/misc/p2sb_emul.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/p2sb_emul.c +1 -1
index c3795c59c0..6c71092f18 100644
@@ -214,7 +214,7 @@ static int sandbox_p2sb_emul_map_physmem(struct udevice *dev,
 					 void **ptrp)
 {
 	struct p2sb_emul_priv *priv = dev_get_priv(dev);
-	struct udevice *child;
+	struct udevice *child = NULL;  /* Silence compiler warning */
 	unsigned int offset;
 	int barnum;
 	int ret;
Signature · 1 line
2.25.0.341.g760bfbb309-goog
#1 lore raw

PATCH 1/1 sandbox: p2sb: Silence compiler warning

Quoted 3 lines · Simon Glass

Some compilers produce a warning about 'child' being used before init. Silence this by setting to NULL at the start.

Should be a compiler bug I think. Which compiler has such issue?

Quoted 7 lines

---

 drivers/misc/p2sb_emul.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#2 lore raw

PATCH 1/1 sandbox: p2sb: Silence compiler warning

Quoted 6 lines · Bin Meng
Quoted 3 lines · Simon Glass

Some compilers produce a warning about 'child' being used before init. Silence this by setting to NULL at the start.

Should be a compiler bug I think. Which compiler has such issue?

gcc 7.2.1 (Linaro build x86 -> ARM cross-compiler)

I don't believe this is a compiler bug.

For the compiler *not* to emit this warning, it would have to apply cross-function data flow analysis, which isn't something guaranteed by the C standard IIRC, since it's a very hard problem in general. So, not a compiler *bug* even if we'd like to see the compiler be smart about these things.

#3 lore raw

PATCH 1/1 sandbox: p2sb: Silence compiler warning

Quoted 8 lines · Stephen Warren
Quoted 6 lines · Bin Meng
Quoted 3 lines · Simon Glass

Some compilers produce a warning about 'child' being used before init. Silence this by setting to NULL at the start.

Should be a compiler bug I think. Which compiler has such issue?

Quoted 8 lines

gcc 7.2.1 (Linaro build x86 -> ARM cross-compiler)

I don't believe this is a compiler bug.

For the compiler *not* to emit this warning, it would have to apply cross-function data flow analysis, which isn't something guaranteed by the C standard IIRC, since it's a very hard problem in general. So, not a compiler *bug* even if we'd like to see the compiler be smart about these things.

Is that a supported by them still compiler tho? We don't see that warning with the gcc-7.3.0 from the kernel.org toolchains we use (or travis wouldn't have been clean for Simon).

I'm assuming you're using that compiler to test as it's something that otherwise fits in your test workflow.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200210/aac35b9f/attachment.sig>
#4 lore raw

PATCH 1/1 sandbox: p2sb: Silence compiler warning

In reply to Stephen Warren

Hi Stephen.

Quoted 4 lines · Stephen Warren
Quoted 2 lines · Bin Meng
Quoted 1 line · Simon Glass
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Some compilers produce a warning about 'child' being used before init. Silence this by setting to NULL at the start.

Should be a compiler bug I think. Which compiler has such issue?

gcc 7.2.1 (Linaro build x86 -> ARM cross-compiler)

I don't believe this is a compiler bug.

Well it is 'fixed' in 7.3.

Quoted 6 lines

For the compiler *not* to emit this warning, it would have to apply cross-function data flow analysis, which isn't something guaranteed by the C standard IIRC, since it's a very hard problem in general. So, not a compiler *bug* even if we'd like to see the compiler be smart about these things.

Yes it is hard. I do think it is worth avoiding these problems where we can. But in general I build with the latest kernel toolchain. I think, sadly, if we really want to solve this problem we may need a way to make buildman automatically build with multiple toolchains.

Regards,
Simon

#5 lore raw

PATCH 1/1 sandbox: p2sb: Silence compiler warning

Quoted 25 lines · Simon Glass

Hi Stephen.

Quoted 4 lines · Stephen Warren
Quoted 2 lines · Bin Meng
Quoted 1 line · Simon Glass
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Some compilers produce a warning about 'child' being used before init. Silence this by setting to NULL at the start.

Should be a compiler bug I think. Which compiler has such issue?

gcc 7.2.1 (Linaro build x86 -> ARM cross-compiler)

I don't believe this is a compiler bug.

Well it is 'fixed' in 7.3.

Quoted 6 lines

For the compiler *not* to emit this warning, it would have to apply cross-function data flow analysis, which isn't something guaranteed by the C standard IIRC, since it's a very hard problem in general. So, not a compiler *bug* even if we'd like to see the compiler be smart about these things.

Quoted 4 lines

Yes it is hard. I do think it is worth avoiding these problems where we can. But in general I build with the latest kernel toolchain. I think, sadly, if we really want to solve this problem we may need a way to make buildman automatically build with multiple toolchains.

Well, lets see what's going on here a bit more. We're at the point right now where it's painful that we're on gcc-7.3 for the most part and can't easily / universally move up to a 9.something.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200210/90743df1/attachment.sig>
#6 lore raw

PATCH 1/1 sandbox: p2sb: Silence compiler warning

Quoted 25 lines · Simon Glass

Hi Stephen.

Quoted 4 lines · Stephen Warren
Quoted 2 lines · Bin Meng
Quoted 1 line · Simon Glass
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Some compilers produce a warning about 'child' being used before init. Silence this by setting to NULL at the start.

Should be a compiler bug I think. Which compiler has such issue?

gcc 7.2.1 (Linaro build x86 -> ARM cross-compiler)

I don't believe this is a compiler bug.

Well it is 'fixed' in 7.3.

Quoted 6 lines

For the compiler *not* to emit this warning, it would have to apply cross-function data flow analysis, which isn't something guaranteed by the C standard IIRC, since it's a very hard problem in general. So, not a compiler *bug* even if we'd like to see the compiler be smart about these things.

Quoted 4 lines

Yes it is hard. I do think it is worth avoiding these problems where we can. But in general I build with the latest kernel toolchain. I think, sadly, if we really want to solve this problem we may need a way to make buildman automatically build with multiple toolchains.

Well, lets see what's going on here a bit more. We're at the point right now where it's painful that we're on gcc-7.3 for the most part and can't easily / universally move up to a 9.something.

Signature · 3 lines
Tom

Applied to u-boot-dm, thanks!