linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: dvb-core: remove variable n, turn for-loop to while-loop
@ 2022-10-24 14:29 Colin Ian King
  2022-10-28 15:06 ` Tommaso Merciai
  0 siblings, 1 reply; 2+ messages in thread
From: Colin Ian King @ 2022-10-24 14:29 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Cai Huoqing, linux-media
  Cc: kernel-janitors, linux-kernel

Variable n is just being incremented and it's never used
anywhere else. The variable and the increment are redundant so
remove it. This allows the for-loop to be replaced with a
while-loop.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
 drivers/media/dvb-core/dvb_demux.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-core/dvb_demux.c b/drivers/media/dvb-core/dvb_demux.c
index 83cc32ad7e12..398c86279b5b 100644
--- a/drivers/media/dvb-core/dvb_demux.c
+++ b/drivers/media/dvb-core/dvb_demux.c
@@ -233,7 +233,7 @@ static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed,
 {
 	struct dvb_demux *demux = feed->demux;
 	struct dmx_section_feed *sec = &feed->feed.sec;
-	u16 limit, seclen, n;
+	u16 limit, seclen;
 
 	if (sec->tsfeedp >= DMX_MAX_SECFEED_SIZE)
 		return 0;
@@ -262,7 +262,7 @@ static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed,
 	/* to be sure always set secbuf */
 	sec->secbuf = sec->secbuf_base + sec->secbufp;
 
-	for (n = 0; sec->secbufp + 2 < limit; n++) {
+	while (sec->secbufp + 2 < limit) {
 		seclen = section_length(sec->secbuf);
 		if (seclen <= 0 || seclen > DMX_MAX_SECTION_SIZE
 		    || seclen + sec->secbufp > limit)
-- 
2.37.3


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

* Re: [PATCH] media: dvb-core: remove variable n, turn for-loop to while-loop
  2022-10-24 14:29 [PATCH] media: dvb-core: remove variable n, turn for-loop to while-loop Colin Ian King
@ 2022-10-28 15:06 ` Tommaso Merciai
  0 siblings, 0 replies; 2+ messages in thread
From: Tommaso Merciai @ 2022-10-28 15:06 UTC (permalink / raw)
  To: Colin Ian King
  Cc: Mauro Carvalho Chehab, Cai Huoqing, linux-media, kernel-janitors,
	linux-kernel

Hi Colin,

On Mon, Oct 24, 2022 at 03:29:54PM +0100, Colin Ian King wrote:
> Variable n is just being incremented and it's never used
> anywhere else. The variable and the increment are redundant so
> remove it. This allows the for-loop to be replaced with a
> while-loop.
> 
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
>  drivers/media/dvb-core/dvb_demux.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/dvb-core/dvb_demux.c b/drivers/media/dvb-core/dvb_demux.c
> index 83cc32ad7e12..398c86279b5b 100644
> --- a/drivers/media/dvb-core/dvb_demux.c
> +++ b/drivers/media/dvb-core/dvb_demux.c
> @@ -233,7 +233,7 @@ static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed,
>  {
>  	struct dvb_demux *demux = feed->demux;
>  	struct dmx_section_feed *sec = &feed->feed.sec;
> -	u16 limit, seclen, n;
> +	u16 limit, seclen;
>  
>  	if (sec->tsfeedp >= DMX_MAX_SECFEED_SIZE)
>  		return 0;
> @@ -262,7 +262,7 @@ static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed,
>  	/* to be sure always set secbuf */
>  	sec->secbuf = sec->secbuf_base + sec->secbufp;
>  
> -	for (n = 0; sec->secbufp + 2 < limit; n++) {
> +	while (sec->secbufp + 2 < limit) {
>  		seclen = section_length(sec->secbuf);
>  		if (seclen <= 0 || seclen > DMX_MAX_SECTION_SIZE
>  		    || seclen + sec->secbufp > limit)
> -- 
> 2.37.3
> 

Looks good to me.
We save some space into function stack :)

Reviewed-by: Tommaso Merciai <tommaso.merciai@amarulasolutions.com>

Regards,
Tommaso


-- 
Tommaso Merciai
Embedded Linux Engineer
tommaso.merciai@amarulasolutions.com
__________________________________

Amarula Solutions SRL
Via Le Canevare 30, 31100 Treviso, Veneto, IT
T. +39 042 243 5310
info@amarulasolutions.com
www.amarulasolutions.com

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

end of thread, other threads:[~2022-10-28 15:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-24 14:29 [PATCH] media: dvb-core: remove variable n, turn for-loop to while-loop Colin Ian King
2022-10-28 15:06 ` Tommaso Merciai

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