* [PATCH] media: rc: rc-ir-raw: drop useless decrements in ir_raw_gen_{manchester,pl}()
@ 2026-08-18 20:38 Sergey Shtylyov
2026-08-18 20:54 ` Sergey Shtylyov
2026-08-19 7:31 ` Sean Young
0 siblings, 2 replies; 4+ messages in thread
From: Sergey Shtylyov @ 2026-08-18 20:38 UTC (permalink / raw)
To: Sean Young, Mauro Carvalho Chehab, linux-media; +Cc: Sergey Shtylyov
In ir_raw_gen_{manchester,pl}(), the paremeter max is usually decremented
while checking it for 0 but sometimes that action seems fruitless as max
isn't used afterwards -- drop the useless decrement operators...
Found by Linux Verification Center (linuxtesting.org) with the Svace static
analysis tool.
Signed-off-by: Sergey Shtylyov <s.shtylyov@auroraos.dev>
---
The patch is against the next branch of the linuxtv.org/media.git repo...
drivers/media/rc/rc-ir-raw.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/rc/rc-ir-raw.c b/drivers/media/rc/rc-ir-raw.c
index ba24c2f22d39..ed494be8896f 100644
--- a/drivers/media/rc/rc-ir-raw.c
+++ b/drivers/media/rc/rc-ir-raw.c
@@ -362,7 +362,7 @@ int ir_raw_gen_manchester(struct ir_raw_event **ev, unsigned int max,
if (timings->trailer_space) {
if (!(*ev)->pulse)
(*ev)->duration += timings->trailer_space;
- else if (!max--)
+ else if (!max)
goto nobufs;
else
init_ir_raw_event_duration(++(*ev), 0,
@@ -491,7 +491,7 @@ int ir_raw_gen_pl(struct ir_raw_event **ev, unsigned int max,
}
}
- if (!max--)
+ if (!max)
return ret;
init_ir_raw_event_duration((*ev)++, 0, timings->trailer_space);
--
2.55.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] media: rc: rc-ir-raw: drop useless decrements in ir_raw_gen_{manchester,pl}()
2026-08-18 20:38 [PATCH] media: rc: rc-ir-raw: drop useless decrements in ir_raw_gen_{manchester,pl}() Sergey Shtylyov
@ 2026-08-18 20:54 ` Sergey Shtylyov
2026-08-19 7:31 ` Sean Young
1 sibling, 0 replies; 4+ messages in thread
From: Sergey Shtylyov @ 2026-08-18 20:54 UTC (permalink / raw)
To: Sean Young, Mauro Carvalho Chehab, linux-media
On 8/18/26 11:38 PM, Sergey Shtylyov wrote:
> In ir_raw_gen_{manchester,pl}(), the paremeter max is usually decremented
Oops, s/paremeter/parameter/... :-)
> while checking it for 0 but sometimes that action seems fruitless as max
> isn't used afterwards -- drop the useless decrement operators...
>
> Found by Linux Verification Center (linuxtesting.org) with the Svace static
> analysis tool.
>
> Signed-off-by: Sergey Shtylyov <s.shtylyov@auroraos.dev>[...]
MBR, Sergey
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] media: rc: rc-ir-raw: drop useless decrements in ir_raw_gen_{manchester,pl}()
2026-08-18 20:38 [PATCH] media: rc: rc-ir-raw: drop useless decrements in ir_raw_gen_{manchester,pl}() Sergey Shtylyov
2026-08-18 20:54 ` Sergey Shtylyov
@ 2026-08-19 7:31 ` Sean Young
2026-08-19 15:17 ` Sergey Shtylyov
1 sibling, 1 reply; 4+ messages in thread
From: Sean Young @ 2026-08-19 7:31 UTC (permalink / raw)
To: Sergey Shtylyov; +Cc: Mauro Carvalho Chehab, linux-media
On Tue, Aug 18, 2026 at 11:38:30PM +0300, Sergey Shtylyov wrote:
> In ir_raw_gen_{manchester,pl}(), the paremeter max is usually decremented
> while checking it for 0 but sometimes that action seems fruitless as max
> isn't used afterwards -- drop the useless decrement operators...
>
> Found by Linux Verification Center (linuxtesting.org) with the Svace static
> analysis tool.
>
> Signed-off-by: Sergey Shtylyov <s.shtylyov@auroraos.dev>
> ---
> The patch is against the next branch of the linuxtv.org/media.git repo...
>
> drivers/media/rc/rc-ir-raw.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/rc/rc-ir-raw.c b/drivers/media/rc/rc-ir-raw.c
> index ba24c2f22d39..ed494be8896f 100644
> --- a/drivers/media/rc/rc-ir-raw.c
> +++ b/drivers/media/rc/rc-ir-raw.c
> @@ -362,7 +362,7 @@ int ir_raw_gen_manchester(struct ir_raw_event **ev, unsigned int max,
> if (timings->trailer_space) {
> if (!(*ev)->pulse)
> (*ev)->duration += timings->trailer_space;
> - else if (!max--)
> + else if (!max)
> goto nobufs;
> else
> init_ir_raw_event_duration(++(*ev), 0,
> @@ -491,7 +491,7 @@ int ir_raw_gen_pl(struct ir_raw_event **ev, unsigned int max,
> }
> }
>
> - if (!max--)
> + if (!max)
This patch is technically correct, but won't make any difference to
generated code. The decremented value of max will have zero users in the
SSA tree, and will be droppped.
Changing this is purely cosmetic change to the code.
Sean
> return ret;
>
> init_ir_raw_event_duration((*ev)++, 0, timings->trailer_space);
> --
> 2.55.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] media: rc: rc-ir-raw: drop useless decrements in ir_raw_gen_{manchester,pl}()
2026-08-19 7:31 ` Sean Young
@ 2026-08-19 15:17 ` Sergey Shtylyov
0 siblings, 0 replies; 4+ messages in thread
From: Sergey Shtylyov @ 2026-08-19 15:17 UTC (permalink / raw)
To: Sean Young; +Cc: Mauro Carvalho Chehab, linux-media
On 8/19/26 10:31 AM, Sean Young wrote:
[...]
>> In ir_raw_gen_{manchester,pl}(), the paremeter max is usually decremented
>> while checking it for 0 but sometimes that action seems fruitless as max
>> isn't used afterwards -- drop the useless decrement operators...
>>
>> Found by Linux Verification Center (linuxtesting.org) with the Svace static
>> analysis tool.
>>
>> Signed-off-by: Sergey Shtylyov <s.shtylyov@auroraos.dev>
>> ---
>> The patch is against the next branch of the linuxtv.org/media.git repo...
>>
>> drivers/media/rc/rc-ir-raw.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/media/rc/rc-ir-raw.c b/drivers/media/rc/rc-ir-raw.c
>> index ba24c2f22d39..ed494be8896f 100644
>> --- a/drivers/media/rc/rc-ir-raw.c
>> +++ b/drivers/media/rc/rc-ir-raw.c
>> @@ -362,7 +362,7 @@ int ir_raw_gen_manchester(struct ir_raw_event **ev, unsigned int max,
>> if (timings->trailer_space) {
>> if (!(*ev)->pulse)
>> (*ev)->duration += timings->trailer_space;
>> - else if (!max--)
>> + else if (!max)
>> goto nobufs;
>> else
>> init_ir_raw_event_duration(++(*ev), 0,
>> @@ -491,7 +491,7 @@ int ir_raw_gen_pl(struct ir_raw_event **ev, unsigned int max,
>> }
>> }
>>
>> - if (!max--)
>> + if (!max)
>
> This patch is technically correct, but won't make any difference to
> generated code. The decremented value of max will have zero users in the
After looking at the .lst file (that wasn't easy), you're correct...
> SSA tree, and will be droppped.
Had to google SSA tree... :-)
> Changing this is purely cosmetic change to the code.
Makes the code a bit clearer, no?
> Sean
[...]
MBR, Sergey
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-08-19 15:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-18 20:38 [PATCH] media: rc: rc-ir-raw: drop useless decrements in ir_raw_gen_{manchester,pl}() Sergey Shtylyov
2026-08-18 20:54 ` Sergey Shtylyov
2026-08-19 7:31 ` Sean Young
2026-08-19 15:17 ` Sergey Shtylyov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox