All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sandbox: p2sb: Silence compiler warning
@ 2020-02-08 14:53 Simon Glass
  2020-02-08 15:21 ` Bin Meng
  0 siblings, 1 reply; 7+ messages in thread
From: Simon Glass @ 2020-02-08 14:53 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Simon Glass <sjg@chromium.org>
---

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

diff --git a/drivers/misc/p2sb_emul.c b/drivers/misc/p2sb_emul.c
index c3795c59c0..6c71092f18 100644
--- a/drivers/misc/p2sb_emul.c
+++ b/drivers/misc/p2sb_emul.c
@@ -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;
-- 
2.25.0.341.g760bfbb309-goog

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH] sandbox: p2sb: Silence compiler warning
  2020-02-08 14:53 [PATCH] sandbox: p2sb: Silence compiler warning Simon Glass
@ 2020-02-08 15:21 ` Bin Meng
  2020-02-10 18:27   ` Stephen Warren
  0 siblings, 1 reply; 7+ messages in thread
From: Bin Meng @ 2020-02-08 15:21 UTC (permalink / raw)
  To: u-boot

On Sat, Feb 8, 2020 at 10:53 PM Simon Glass <sjg@chromium.org> wrote:
>
> 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?

>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  drivers/misc/p2sb_emul.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] sandbox: p2sb: Silence compiler warning
  2020-02-08 15:21 ` Bin Meng
@ 2020-02-10 18:27   ` Stephen Warren
  2020-02-10 19:02     ` Tom Rini
  2020-02-10 19:03     ` Simon Glass
  0 siblings, 2 replies; 7+ messages in thread
From: Stephen Warren @ 2020-02-10 18:27 UTC (permalink / raw)
  To: u-boot

On 2/8/20 8:21 AM, Bin Meng wrote:
> On Sat, Feb 8, 2020 at 10:53 PM Simon Glass <sjg@chromium.org> wrote:
>>
>> 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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] sandbox: p2sb: Silence compiler warning
  2020-02-10 18:27   ` Stephen Warren
@ 2020-02-10 19:02     ` Tom Rini
  2020-02-10 19:03     ` Simon Glass
  1 sibling, 0 replies; 7+ messages in thread
From: Tom Rini @ 2020-02-10 19:02 UTC (permalink / raw)
  To: u-boot

On Mon, Feb 10, 2020 at 11:27:58AM -0700, Stephen Warren wrote:
> On 2/8/20 8:21 AM, Bin Meng wrote:
> > On Sat, Feb 8, 2020 at 10:53 PM Simon Glass <sjg@chromium.org> wrote:
> > > 
> > > 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.

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.

-- 
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>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] sandbox: p2sb: Silence compiler warning
  2020-02-10 18:27   ` Stephen Warren
  2020-02-10 19:02     ` Tom Rini
@ 2020-02-10 19:03     ` Simon Glass
  2020-02-10 19:08       ` Tom Rini
  2020-03-03  2:46       ` sjg at google.com
  1 sibling, 2 replies; 7+ messages in thread
From: Simon Glass @ 2020-02-10 19:03 UTC (permalink / raw)
  To: u-boot

Hi Stephen.

On Mon, 10 Feb 2020 at 11:28, Stephen Warren <swarren@wwwdotorg.org> wrote:
>
> On 2/8/20 8:21 AM, Bin Meng wrote:
> > On Sat, Feb 8, 2020 at 10:53 PM Simon Glass <sjg@chromium.org> wrote:
> >>
> >> 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.

>
> 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] sandbox: p2sb: Silence compiler warning
  2020-02-10 19:03     ` Simon Glass
@ 2020-02-10 19:08       ` Tom Rini
  2020-03-03  2:46       ` sjg at google.com
  1 sibling, 0 replies; 7+ messages in thread
From: Tom Rini @ 2020-02-10 19:08 UTC (permalink / raw)
  To: u-boot

On Mon, Feb 10, 2020 at 12:03:26PM -0700, Simon Glass wrote:
> Hi Stephen.
> 
> On Mon, 10 Feb 2020 at 11:28, Stephen Warren <swarren@wwwdotorg.org> wrote:
> >
> > On 2/8/20 8:21 AM, Bin Meng wrote:
> > > On Sat, Feb 8, 2020 at 10:53 PM Simon Glass <sjg@chromium.org> wrote:
> > >>
> > >> 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.
> 
> >
> > 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.

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.

-- 
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>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] sandbox: p2sb: Silence compiler warning
  2020-02-10 19:03     ` Simon Glass
  2020-02-10 19:08       ` Tom Rini
@ 2020-03-03  2:46       ` sjg at google.com
  1 sibling, 0 replies; 7+ messages in thread
From: sjg at google.com @ 2020-03-03  2:46 UTC (permalink / raw)
  To: u-boot

On Mon, Feb 10, 2020 at 12:03:26PM -0700, Simon Glass wrote:
> Hi Stephen.
>
> On Mon, 10 Feb 2020 at 11:28, Stephen Warren <swarren@wwwdotorg.org> wrote:
> >
> > On 2/8/20 8:21 AM, Bin Meng wrote:
> > > On Sat, Feb 8, 2020 at 10:53 PM Simon Glass <sjg@chromium.org> wrote:
> > >>
> > >> 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.
>
> >
> > 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.

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.

-- 
Tom

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-03-03  2:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-08 14:53 [PATCH] sandbox: p2sb: Silence compiler warning Simon Glass
2020-02-08 15:21 ` Bin Meng
2020-02-10 18:27   ` Stephen Warren
2020-02-10 19:02     ` Tom Rini
2020-02-10 19:03     ` Simon Glass
2020-02-10 19:08       ` Tom Rini
2020-03-03  2:46       ` sjg at google.com

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.