linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/i915/perf: remove redundant variable 'taken'
@ 2022-10-07 19:53 Colin Ian King
  2022-10-08 11:55 ` Christophe JAILLET
  0 siblings, 1 reply; 3+ messages in thread
From: Colin Ian King @ 2022-10-07 19:53 UTC (permalink / raw)
  To: Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
	David Airlie, Daniel Vetter, intel-gfx, dri-devel
  Cc: kernel-janitors, linux-kernel

The assignment to variable taken is redundant and so it can be
removed as well as the variable too.

Cleans up clang-scan build warnings:
warning: Although the value stored to 'taken' is used in the enclosing
expression, the value is never actually read from 'taken'
[deadcode.DeadStores]

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
 drivers/gpu/drm/i915/i915_perf.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
index 0defbb43ceea..15816df916c7 100644
--- a/drivers/gpu/drm/i915/i915_perf.c
+++ b/drivers/gpu/drm/i915/i915_perf.c
@@ -656,7 +656,6 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream,
 	size_t start_offset = *offset;
 	unsigned long flags;
 	u32 head, tail;
-	u32 taken;
 	int ret = 0;
 
 	if (drm_WARN_ON(&uncore->i915->drm, !stream->enabled))
@@ -692,7 +691,7 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream,
 
 
 	for (/* none */;
-	     (taken = OA_TAKEN(tail, head));
+	     OA_TAKEN(tail, head);
 	     head = (head + report_size) & mask) {
 		u8 *report = oa_buf_base + head;
 		u32 *report32 = (void *)report;
@@ -950,7 +949,6 @@ static int gen7_append_oa_reports(struct i915_perf_stream *stream,
 	size_t start_offset = *offset;
 	unsigned long flags;
 	u32 head, tail;
-	u32 taken;
 	int ret = 0;
 
 	if (drm_WARN_ON(&uncore->i915->drm, !stream->enabled))
@@ -984,7 +982,7 @@ static int gen7_append_oa_reports(struct i915_perf_stream *stream,
 
 
 	for (/* none */;
-	     (taken = OA_TAKEN(tail, head));
+	     OA_TAKEN(tail, head);
 	     head = (head + report_size) & mask) {
 		u8 *report = oa_buf_base + head;
 		u32 *report32 = (void *)report;
-- 
2.37.3


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

* Re: [PATCH] drm/i915/perf: remove redundant variable 'taken'
  2022-10-07 19:53 [PATCH] drm/i915/perf: remove redundant variable 'taken' Colin Ian King
@ 2022-10-08 11:55 ` Christophe JAILLET
  2022-10-10  8:14   ` Tvrtko Ursulin
  0 siblings, 1 reply; 3+ messages in thread
From: Christophe JAILLET @ 2022-10-08 11:55 UTC (permalink / raw)
  To: Colin Ian King, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
	Tvrtko Ursulin, David Airlie, Daniel Vetter, intel-gfx,
	dri-devel
  Cc: kernel-janitors, linux-kernel

Le 07/10/2022 à 21:53, Colin Ian King a écrit :
> The assignment to variable taken is redundant and so it can be
> removed as well as the variable too.
> 
> Cleans up clang-scan build warnings:
> warning: Although the value stored to 'taken' is used in the enclosing
> expression, the value is never actually read from 'taken'
> [deadcode.DeadStores]

Hi,

#define OA_TAKEN(tail, head)	((tail - head) & (OA_BUFFER_SIZE - 1))

So if the result is not used, maybe calling OA_TAKEN() can be removed as 
well?
It looks like a no-op in such a case.

CJ

> 
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
>   drivers/gpu/drm/i915/i915_perf.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
> index 0defbb43ceea..15816df916c7 100644
> --- a/drivers/gpu/drm/i915/i915_perf.c
> +++ b/drivers/gpu/drm/i915/i915_perf.c
> @@ -656,7 +656,6 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream,
>   	size_t start_offset = *offset;
>   	unsigned long flags;
>   	u32 head, tail;
> -	u32 taken;
>   	int ret = 0;
>   
>   	if (drm_WARN_ON(&uncore->i915->drm, !stream->enabled))
> @@ -692,7 +691,7 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream,
>   
>   
>   	for (/* none */;
> -	     (taken = OA_TAKEN(tail, head));
> +	     OA_TAKEN(tail, head);
>   	     head = (head + report_size) & mask) {
>   		u8 *report = oa_buf_base + head;
>   		u32 *report32 = (void *)report;
> @@ -950,7 +949,6 @@ static int gen7_append_oa_reports(struct i915_perf_stream *stream,
>   	size_t start_offset = *offset;
>   	unsigned long flags;
>   	u32 head, tail;
> -	u32 taken;
>   	int ret = 0;
>   
>   	if (drm_WARN_ON(&uncore->i915->drm, !stream->enabled))
> @@ -984,7 +982,7 @@ static int gen7_append_oa_reports(struct i915_perf_stream *stream,
>   
>   
>   	for (/* none */;
> -	     (taken = OA_TAKEN(tail, head));
> +	     OA_TAKEN(tail, head);
>   	     head = (head + report_size) & mask) {
>   		u8 *report = oa_buf_base + head;
>   		u32 *report32 = (void *)report;


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

* Re: [PATCH] drm/i915/perf: remove redundant variable 'taken'
  2022-10-08 11:55 ` Christophe JAILLET
@ 2022-10-10  8:14   ` Tvrtko Ursulin
  0 siblings, 0 replies; 3+ messages in thread
From: Tvrtko Ursulin @ 2022-10-10  8:14 UTC (permalink / raw)
  To: Christophe JAILLET, Colin Ian King, Jani Nikula, Joonas Lahtinen,
	Rodrigo Vivi, David Airlie, Daniel Vetter, intel-gfx, dri-devel
  Cc: kernel-janitors, linux-kernel


On 08/10/2022 12:55, Christophe JAILLET wrote:
> Le 07/10/2022 à 21:53, Colin Ian King a écrit :
>> The assignment to variable taken is redundant and so it can be
>> removed as well as the variable too.
>>
>> Cleans up clang-scan build warnings:
>> warning: Although the value stored to 'taken' is used in the enclosing
>> expression, the value is never actually read from 'taken'
>> [deadcode.DeadStores]
> 
> Hi,
> 
> #define OA_TAKEN(tail, head)    ((tail - head) & (OA_BUFFER_SIZE - 1))
> 
> So if the result is not used, maybe calling OA_TAKEN() can be removed as 
> well?
> It looks like a no-op in such a case.

AFAICS result is used, just the copy/local variable is not.

For the patch:

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Thanks for the cleanup, will merge.

Regards,

Tvrtko


> 
> CJ
> 
>>
>> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
>> ---
>>   drivers/gpu/drm/i915/i915_perf.c | 6 ++----
>>   1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_perf.c 
>> b/drivers/gpu/drm/i915/i915_perf.c
>> index 0defbb43ceea..15816df916c7 100644
>> --- a/drivers/gpu/drm/i915/i915_perf.c
>> +++ b/drivers/gpu/drm/i915/i915_perf.c
>> @@ -656,7 +656,6 @@ static int gen8_append_oa_reports(struct 
>> i915_perf_stream *stream,
>>       size_t start_offset = *offset;
>>       unsigned long flags;
>>       u32 head, tail;
>> -    u32 taken;
>>       int ret = 0;
>>       if (drm_WARN_ON(&uncore->i915->drm, !stream->enabled))
>> @@ -692,7 +691,7 @@ static int gen8_append_oa_reports(struct 
>> i915_perf_stream *stream,
>>       for (/* none */;
>> -         (taken = OA_TAKEN(tail, head));
>> +         OA_TAKEN(tail, head);
>>            head = (head + report_size) & mask) {
>>           u8 *report = oa_buf_base + head;
>>           u32 *report32 = (void *)report;
>> @@ -950,7 +949,6 @@ static int gen7_append_oa_reports(struct 
>> i915_perf_stream *stream,
>>       size_t start_offset = *offset;
>>       unsigned long flags;
>>       u32 head, tail;
>> -    u32 taken;
>>       int ret = 0;
>>       if (drm_WARN_ON(&uncore->i915->drm, !stream->enabled))
>> @@ -984,7 +982,7 @@ static int gen7_append_oa_reports(struct 
>> i915_perf_stream *stream,
>>       for (/* none */;
>> -         (taken = OA_TAKEN(tail, head));
>> +         OA_TAKEN(tail, head);
>>            head = (head + report_size) & mask) {
>>           u8 *report = oa_buf_base + head;
>>           u32 *report32 = (void *)report;
> 

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

end of thread, other threads:[~2022-10-10  8:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-07 19:53 [PATCH] drm/i915/perf: remove redundant variable 'taken' Colin Ian King
2022-10-08 11:55 ` Christophe JAILLET
2022-10-10  8:14   ` Tvrtko Ursulin

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