kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] drm/amd/display: remove redundant assignment to status
@ 2019-05-30 16:12 Colin King
  2019-05-31 20:19 ` Harry Wentland
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Colin King @ 2019-05-30 16:12 UTC (permalink / raw)
  To: Anthony Koo, Harry Wentland, Leo Li, Alex Deucher,
	Christian König, David Zhou, David Airlie, Daniel Vetter,
	amd-gfx, dri-devel
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The variable status is initialized with a value that is never read
and status is reassigned several statements later. This initialization
is redundant and can be removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
index 65d6caedbd82..cf6166a1be53 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
@@ -2367,7 +2367,7 @@ static bool retrieve_link_cap(struct dc_link *link)
 	union down_stream_port_count down_strm_port_count;
 	union edp_configuration_cap edp_config_cap;
 	union dp_downstream_port_present ds_port = { 0 };
-	enum dc_status status = DC_ERROR_UNEXPECTED;
+	enum dc_status status;
 	uint32_t read_dpcd_retry_cnt = 3;
 	int i;
 	struct dp_sink_hw_fw_revision dp_hw_fw_revision;
-- 
2.20.1

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

* Re: [PATCH][next] drm/amd/display: remove redundant assignment to status
  2019-05-30 16:12 [PATCH][next] drm/amd/display: remove redundant assignment to status Colin King
@ 2019-05-31 20:19 ` Harry Wentland
       [not found]   ` <a190bcd5-cda8-84c6-093a-98438a605032-5C7GfCeVMHo@public.gmane.org>
  2019-11-08 16:29 ` [PATCH][next] drm/amd/display: remove redundant variable status Colin King
  2020-04-23 14:17 ` [PATCH][next] drm/amd/display: remove redundant assignment to variable ret Colin King
  2 siblings, 1 reply; 7+ messages in thread
From: Harry Wentland @ 2019-05-31 20:19 UTC (permalink / raw)
  To: Colin King, Koo, Anthony, Wentland, Harry, Li, Sun peng (Leo),
	Deucher, Alexander, Koenig, Christian, Zhou, David(ChunMing),
	David Airlie, Daniel Vetter, amd-gfx@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org
  Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org

T24gMjAxOS0wNS0zMCAxMjoxMiBwLm0uLCBDb2xpbiBLaW5nIHdyb3RlOg0KPiBGcm9tOiBDb2xp
biBJYW4gS2luZyA8Y29saW4ua2luZ0BjYW5vbmljYWwuY29tPg0KPiANCj4gVGhlIHZhcmlhYmxl
IHN0YXR1cyBpcyBpbml0aWFsaXplZCB3aXRoIGEgdmFsdWUgdGhhdCBpcyBuZXZlciByZWFkDQo+
IGFuZCBzdGF0dXMgaXMgcmVhc3NpZ25lZCBzZXZlcmFsIHN0YXRlbWVudHMgbGF0ZXIuIFRoaXMg
aW5pdGlhbGl6YXRpb24NCj4gaXMgcmVkdW5kYW50IGFuZCBjYW4gYmUgcmVtb3ZlZC4NCj4gDQo+
IEFkZHJlc3Nlcy1Db3Zlcml0eTogKCJVbnVzZWQgdmFsdWUiKQ0KPiBTaWduZWQtb2ZmLWJ5OiBD
b2xpbiBJYW4gS2luZyA8Y29saW4ua2luZ0BjYW5vbmljYWwuY29tPg0KPiAtLS0NCj4gIGRyaXZl
cnMvZ3B1L2RybS9hbWQvZGlzcGxheS9kYy9jb3JlL2RjX2xpbmtfZHAuYyB8IDIgKy0NCj4gIDEg
ZmlsZSBjaGFuZ2VkLCAxIGluc2VydGlvbigrKSwgMSBkZWxldGlvbigtKQ0KPiANCj4gZGlmZiAt
LWdpdCBhL2RyaXZlcnMvZ3B1L2RybS9hbWQvZGlzcGxheS9kYy9j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19md19yZXZpc2lvbiBkcF9od19md19yZXZpc2lvbjsNCj4gDQo

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

* Re: [PATCH][next] drm/amd/display: remove redundant assignment to status
       [not found]   ` <a190bcd5-cda8-84c6-093a-98438a605032-5C7GfCeVMHo@public.gmane.org>
@ 2019-06-06 10:30     ` Dan Carpenter
  0 siblings, 0 replies; 7+ messages in thread
From: Dan Carpenter @ 2019-06-06 10:30 UTC (permalink / raw)
  To: Harry Wentland
  Cc: Zhou, David(ChunMing), Li, Sun peng (Leo), Wentland, Harry,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	David Airlie,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	Daniel Vetter, Deucher, Alexander, Colin King, Koo, Anthony,
	Koenig, Christian

On Fri, May 31, 2019 at 08:19:03PM +0000, Harry Wentland wrote:
> On 2019-05-30 12:12 p.m., Colin King wrote:
> > From: Colin Ian King <colin.king@canonical.com>
> > 
> > The variable status is initialized with a value that is never read
> > and status is reassigned several statements later. This initialization
> > is redundant and can be removed.
> > 
> > Addresses-Coverity: ("Unused value")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> >  drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
> > index 65d6caedbd82..cf6166a1be53 100644
> > --- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
> > +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
> > @@ -2367,7 +2367,7 @@ static bool retrieve_link_cap(struct dc_link *link)
> >  	union down_stream_port_count down_strm_port_count;
> >  	union edp_configuration_cap edp_config_cap;
> >  	union dp_downstream_port_present ds_port = { 0 };
> > -	enum dc_status status = DC_ERROR_UNEXPECTED;
> > +	enum dc_status status;
> 
> Not sure this improves the situation.
> 
> I'd prefer to have a default here in case someone changes the code below
> and forgets to set the status.

The dead code confuses human readers, because people naturally assume it
is not dead.

GCC has a feature to warn about uninitialized variables and we're
randomly initializing status to a bogus value to disable static
analysis...

regards,
dan carpenter

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

* [PATCH][next] drm/amd/display: remove redundant variable status
  2019-05-30 16:12 [PATCH][next] drm/amd/display: remove redundant assignment to status Colin King
  2019-05-31 20:19 ` Harry Wentland
@ 2019-11-08 16:29 ` Colin King
       [not found]   ` <20191108162945.180624-1-colin.king-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
  2020-04-23 14:17 ` [PATCH][next] drm/amd/display: remove redundant assignment to variable ret Colin King
  2 siblings, 1 reply; 7+ messages in thread
From: Colin King @ 2019-11-08 16:29 UTC (permalink / raw)
  To: Leo Li, Alex Deucher, Christian König, David Zhou,
	David Airlie, Daniel Vetter, amd-gfx, dri-devel
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Variable status is redundant, it is being initialized with a value
that is over-written later and this is being returned immediately
after the assignment.  Clean up the code by removing status and
just returning the value returned from the call to function
dc->hwss.dmdata_status_done.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
index 371d49e9b745..88a84bfaea6f 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
@@ -565,7 +565,6 @@ bool dc_stream_get_scanoutpos(const struct dc_stream_state *stream,
 
 bool dc_stream_dmdata_status_done(struct dc *dc, struct dc_stream_state *stream)
 {
-	bool status = true;
 	struct pipe_ctx *pipe = NULL;
 	int i;
 
@@ -581,8 +580,7 @@ bool dc_stream_dmdata_status_done(struct dc *dc, struct dc_stream_state *stream)
 	if (i = MAX_PIPES)
 		return true;
 
-	status = dc->hwss.dmdata_status_done(pipe);
-	return status;
+	return dc->hwss.dmdata_status_done(pipe);
 }
 
 bool dc_stream_set_dynamic_metadata(struct dc *dc,
-- 
2.20.1

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

* Re: [PATCH][next] drm/amd/display: remove redundant variable status
       [not found]   ` <20191108162945.180624-1-colin.king-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
@ 2019-11-08 16:34     ` Alex Deucher
  0 siblings, 0 replies; 7+ messages in thread
From: Alex Deucher @ 2019-11-08 16:34 UTC (permalink / raw)
  To: Colin King
  Cc: David Zhou, Leo Li, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, LKML,
	amd-gfx list, David Airlie, Maling list - DRI developers,
	Daniel Vetter, Alex Deucher, Christian König

On Fri, Nov 8, 2019 at 11:29 AM Colin King <colin.king@canonical.com> wrote:
>
> From: Colin Ian King <colin.king@canonical.com>
>
> Variable status is redundant, it is being initialized with a value
> that is over-written later and this is being returned immediately
> after the assignment.  Clean up the code by removing status and
> just returning the value returned from the call to function
> dc->hwss.dmdata_status_done.
>
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied.  thanks!

Alex

> ---
>  drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
> index 371d49e9b745..88a84bfaea6f 100644
> --- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
> +++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
> @@ -565,7 +565,6 @@ bool dc_stream_get_scanoutpos(const struct dc_stream_state *stream,
>
>  bool dc_stream_dmdata_status_done(struct dc *dc, struct dc_stream_state *stream)
>  {
> -       bool status = true;
>         struct pipe_ctx *pipe = NULL;
>         int i;
>
> @@ -581,8 +580,7 @@ bool dc_stream_dmdata_status_done(struct dc *dc, struct dc_stream_state *stream)
>         if (i = MAX_PIPES)
>                 return true;
>
> -       status = dc->hwss.dmdata_status_done(pipe);
> -       return status;
> +       return dc->hwss.dmdata_status_done(pipe);
>  }
>
>  bool dc_stream_set_dynamic_metadata(struct dc *dc,
> --
> 2.20.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH][next] drm/amd/display: remove redundant assignment to variable ret
  2019-05-30 16:12 [PATCH][next] drm/amd/display: remove redundant assignment to status Colin King
  2019-05-31 20:19 ` Harry Wentland
  2019-11-08 16:29 ` [PATCH][next] drm/amd/display: remove redundant variable status Colin King
@ 2020-04-23 14:17 ` Colin King
  2020-04-23 19:31   ` Alex Deucher
  2 siblings, 1 reply; 7+ messages in thread
From: Colin King @ 2020-04-23 14:17 UTC (permalink / raw)
  To: Harry Wentland, Leo Li, Alex Deucher, Christian König,
	David Zhou, David Airlie, Daniel Vetter, Wenjing Liu, amd-gfx,
	dri-devel
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The variable ret is being initialized with a value that is never read
and it is being updated later with a new value. The initialization is
redundant and can be removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
index d5b306384d79..9ef9e50a34fa 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
@@ -4231,7 +4231,7 @@ void dpcd_set_source_specific_data(struct dc_link *link)
 {
 	const uint32_t post_oui_delay = 30; // 30ms
 	uint8_t dspc = 0;
-	enum dc_status ret = DC_ERROR_UNEXPECTED;
+	enum dc_status ret;
 
 	ret = core_link_read_dpcd(link, DP_DOWN_STREAM_PORT_COUNT, &dspc,
 				  sizeof(dspc));
-- 
2.25.1

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

* Re: [PATCH][next] drm/amd/display: remove redundant assignment to variable ret
  2020-04-23 14:17 ` [PATCH][next] drm/amd/display: remove redundant assignment to variable ret Colin King
@ 2020-04-23 19:31   ` Alex Deucher
  0 siblings, 0 replies; 7+ messages in thread
From: Alex Deucher @ 2020-04-23 19:31 UTC (permalink / raw)
  To: Colin King
  Cc: David Zhou, Leo Li, kernel-janitors, Wenjing Liu, LKML,
	amd-gfx list, David Airlie, Maling list - DRI developers,
	Daniel Vetter, Alex Deucher, Harry Wentland, Christian König

On Thu, Apr 23, 2020 at 10:18 AM Colin King <colin.king@canonical.com> wrote:
>
> From: Colin Ian King <colin.king@canonical.com>
>
> The variable ret is being initialized with a value that is never read
> and it is being updated later with a new value. The initialization is
> redundant and can be removed.
>
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied.  Thanks!

Alex

> ---
>  drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
> index d5b306384d79..9ef9e50a34fa 100644
> --- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
> +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
> @@ -4231,7 +4231,7 @@ void dpcd_set_source_specific_data(struct dc_link *link)
>  {
>         const uint32_t post_oui_delay = 30; // 30ms
>         uint8_t dspc = 0;
> -       enum dc_status ret = DC_ERROR_UNEXPECTED;
> +       enum dc_status ret;
>
>         ret = core_link_read_dpcd(link, DP_DOWN_STREAM_PORT_COUNT, &dspc,
>                                   sizeof(dspc));
> --
> 2.25.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2020-04-23 19:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-30 16:12 [PATCH][next] drm/amd/display: remove redundant assignment to status Colin King
2019-05-31 20:19 ` Harry Wentland
     [not found]   ` <a190bcd5-cda8-84c6-093a-98438a605032-5C7GfCeVMHo@public.gmane.org>
2019-06-06 10:30     ` Dan Carpenter
2019-11-08 16:29 ` [PATCH][next] drm/amd/display: remove redundant variable status Colin King
     [not found]   ` <20191108162945.180624-1-colin.king-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2019-11-08 16:34     ` Alex Deucher
2020-04-23 14:17 ` [PATCH][next] drm/amd/display: remove redundant assignment to variable ret Colin King
2020-04-23 19:31   ` Alex Deucher

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