Re: [PATCH] media: rc: rc-ir-raw: drop useless decrements in ir_raw_gen_{manchester,pl}()

Sean Young <[email protected]>
Newsgroups org.kernel.vger.linux-media
Message-ID <[email protected]>
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 <[email protected]>
> ---
> 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
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.