2018-09-18 07:38:26

by zhong jiang

[permalink] [raw]
Subject: [PATCH] drm: sun4i: Fix a uninitialized variable warning.

Fix the following compile warning:

drivers/gpu/drm/sun4i/sun4i_tcon.c:1088: warning: 'has_lvds_alt' may be used uninitialized in this function [-Wmaybe-uninitialized]
bool has_lvds_rst, has_lvds_alt, can_lvds;

Signed-off-by: zhong jiang <[email protected]>
---
drivers/gpu/drm/sun4i/sun4i_tcon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c
index c78cd35..563cc8f 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
@@ -1086,7 +1086,7 @@ static int sun4i_tcon_bind(struct device *dev, struct device *master,
struct device_node *remote;
struct sun4i_tcon *tcon;
struct reset_control *edp_rstc;
- bool has_lvds_rst, has_lvds_alt, can_lvds;
+ bool has_lvds_rst, has_lvds_alt = false, can_lvds;
int ret;

engine = sun4i_tcon_find_engine(drv, dev->of_node);
--
1.7.12.4



2018-09-19 08:48:32

by Maxime Ripard

[permalink] [raw]
Subject: Re: [PATCH] drm: sun4i: Fix a uninitialized variable warning.

On Tue, Sep 18, 2018 at 03:25:20PM +0800, zhong jiang wrote:
> Fix the following compile warning:
>
> drivers/gpu/drm/sun4i/sun4i_tcon.c:1088: warning: 'has_lvds_alt' may be used uninitialized in this function [-Wmaybe-uninitialized]
> bool has_lvds_rst, has_lvds_alt, can_lvds;
>
> Signed-off-by: zhong jiang <[email protected]>

I can't see any code path that would lead to an uninitialized usage of
that variable.

Which compiler produced that warning? I tried building it today with
gcc 8.1.1, and I don't see that warning either.

Maxime

--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


Attachments:
(No filename) (655.00 B)
signature.asc (849.00 B)
Download all attachments

2018-09-19 09:03:52

by zhong jiang

[permalink] [raw]
Subject: Re: [PATCH] drm: sun4i: Fix a uninitialized variable warning.

On 2018/9/19 16:47, Maxime Ripard wrote:
> On Tue, Sep 18, 2018 at 03:25:20PM +0800, zhong jiang wrote:
>> Fix the following compile warning:
>>
>> drivers/gpu/drm/sun4i/sun4i_tcon.c:1088: warning: 'has_lvds_alt' may be used uninitialized in this function [-Wmaybe-uninitialized]
>> bool has_lvds_rst, has_lvds_alt, can_lvds;
>>
>> Signed-off-by: zhong jiang <[email protected]>
> I can't see any code path that would lead to an uninitialized usage of
> that variable.
>
> Which compiler produced that warning? I tried building it today with
> gcc 8.1.1, and I don't see that warning either.
>
> Maxime
>
I indeed hit the issue. the gcc version is
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609

Thanks,
zhong jiang


2018-09-21 14:27:55

by Maxime Ripard

[permalink] [raw]
Subject: Re: [PATCH] drm: sun4i: Fix a uninitialized variable warning.

On Wed, Sep 19, 2018 at 05:01:32PM +0800, zhong jiang wrote:
> On 2018/9/19 16:47, Maxime Ripard wrote:
> > On Tue, Sep 18, 2018 at 03:25:20PM +0800, zhong jiang wrote:
> >> Fix the following compile warning:
> >>
> >> drivers/gpu/drm/sun4i/sun4i_tcon.c:1088: warning: 'has_lvds_alt' may be used uninitialized in this function [-Wmaybe-uninitialized]
> >> bool has_lvds_rst, has_lvds_alt, can_lvds;
> >>
> >> Signed-off-by: zhong jiang <[email protected]>
> > I can't see any code path that would lead to an uninitialized usage of
> > that variable.
> >
> > Which compiler produced that warning? I tried building it today with
> > gcc 8.1.1, and I don't see that warning either.
>
> I indeed hit the issue. the gcc version is
> gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609

I've tested with 4.* gcc, and it didn't report any error. It seems to
be a false positive for this particular version, so there's no need to
merge that patch. If more people are affected, we'll obviously do
something about it though.

Thanks!
Maxime

--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


Attachments:
(No filename) (1.12 kB)
signature.asc (849.00 B)
Download all attachments

2018-09-21 14:51:02

by zhong jiang

[permalink] [raw]
Subject: Re: [PATCH] drm: sun4i: Fix a uninitialized variable warning.

On 2018/9/21 22:26, Maxime Ripard wrote:
> On Wed, Sep 19, 2018 at 05:01:32PM +0800, zhong jiang wrote:
>> On 2018/9/19 16:47, Maxime Ripard wrote:
>>> On Tue, Sep 18, 2018 at 03:25:20PM +0800, zhong jiang wrote:
>>>> Fix the following compile warning:
>>>>
>>>> drivers/gpu/drm/sun4i/sun4i_tcon.c:1088: warning: 'has_lvds_alt' may be used uninitialized in this function [-Wmaybe-uninitialized]
>>>> bool has_lvds_rst, has_lvds_alt, can_lvds;
>>>>
>>>> Signed-off-by: zhong jiang <[email protected]>
>>> I can't see any code path that would lead to an uninitialized usage of
>>> that variable.
>>>
>>> Which compiler produced that warning? I tried building it today with
>>> gcc 8.1.1, and I don't see that warning either.
>> I indeed hit the issue. the gcc version is
>> gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
> I've tested with 4.* gcc, and it didn't report any error. It seems to
> be a false positive for this particular version, so there's no need to
> merge that patch. If more people are affected, we'll obviously do
> something about it though.
Yep, it rarely occur. I just happen once. Thank you for reply.

Sincerely,
zhong jiang
> Thanks!
> Maxime
>