Linux-mtd Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] jffs2: remove redundant check on outpos > pos
@ 2024-10-29 22:20 Colin Ian King
  2024-10-30  4:45 ` Zhihao Cheng
  0 siblings, 1 reply; 3+ messages in thread
From: Colin Ian King @ 2024-10-29 22:20 UTC (permalink / raw)
  To: David Woodhouse, Richard Weinberger, linux-mtd
  Cc: kernel-janitors, linux-kernel

The check for outpos > pos is always false because outpos is zero
and pos is at least zero; outpos can never be greater than pos.
The check is redundant and can be removed.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
 fs/jffs2/compr_rubin.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/fs/jffs2/compr_rubin.c b/fs/jffs2/compr_rubin.c
index 556de100ebd5..9854253d0108 100644
--- a/fs/jffs2/compr_rubin.c
+++ b/fs/jffs2/compr_rubin.c
@@ -276,11 +276,6 @@ static int rubin_do_compress(int bit_divider, int *bits, unsigned char *data_in,
 
 	end_rubin(&rs);
 
-	if (outpos > pos) {
-		/* We failed */
-		return -1;
-	}
-
 	/* Tell the caller how much we managed to compress,
 	 * and how much space it took */
 
-- 
2.39.5


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] jffs2: remove redundant check on outpos > pos
  2024-10-29 22:20 [PATCH] jffs2: remove redundant check on outpos > pos Colin Ian King
@ 2024-10-30  4:45 ` Zhihao Cheng
  2024-10-30  7:43   ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Zhihao Cheng @ 2024-10-30  4:45 UTC (permalink / raw)
  To: Colin Ian King, David Woodhouse, Richard Weinberger, linux-mtd
  Cc: kernel-janitors, linux-kernel

在 2024/10/30 6:20, Colin Ian King 写道:
> The check for outpos > pos is always false because outpos is zero
> and pos is at least zero; outpos can never be greater than pos.
> The check is redundant and can be removed.
> 
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
>   fs/jffs2/compr_rubin.c | 5 -----
>   1 file changed, 5 deletions(-)
> 
> diff --git a/fs/jffs2/compr_rubin.c b/fs/jffs2/compr_rubin.c
> index 556de100ebd5..9854253d0108 100644
> --- a/fs/jffs2/compr_rubin.c
> +++ b/fs/jffs2/compr_rubin.c
> @@ -276,11 +276,6 @@ static int rubin_do_compress(int bit_divider, int *bits, unsigned char *data_in,
>   
>   	end_rubin(&rs);
>   

Maybe this check could detect the overflow of 'pos', I guess.
> -	if (outpos > pos) {
> -		/* We failed */
> -		return -1;
> -	}
> -
>   	/* Tell the caller how much we managed to compress,
>   	 * and how much space it took */
>   
> 


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] jffs2: remove redundant check on outpos > pos
  2024-10-30  4:45 ` Zhihao Cheng
@ 2024-10-30  7:43   ` Dan Carpenter
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2024-10-30  7:43 UTC (permalink / raw)
  To: Zhihao Cheng
  Cc: Colin Ian King, David Woodhouse, Richard Weinberger, linux-mtd,
	kernel-janitors, linux-kernel

On Wed, Oct 30, 2024 at 12:45:42PM +0800, Zhihao Cheng wrote:
> 在 2024/10/30 6:20, Colin Ian King 写道:
> > The check for outpos > pos is always false because outpos is zero
> > and pos is at least zero; outpos can never be greater than pos.
> > The check is redundant and can be removed.
> > 
> > Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> > ---
> >   fs/jffs2/compr_rubin.c | 5 -----
> >   1 file changed, 5 deletions(-)
> > 
> > diff --git a/fs/jffs2/compr_rubin.c b/fs/jffs2/compr_rubin.c
> > index 556de100ebd5..9854253d0108 100644
> > --- a/fs/jffs2/compr_rubin.c
> > +++ b/fs/jffs2/compr_rubin.c
> > @@ -276,11 +276,6 @@ static int rubin_do_compress(int bit_divider, int *bits, unsigned char *data_in,
> >   	end_rubin(&rs);
> 
> Maybe this check could detect the overflow of 'pos', I guess.

"pos" is a number between 0 and 4.  It can't overflow.

regards,
dan carpenter


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

end of thread, other threads:[~2024-10-30  7:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-29 22:20 [PATCH] jffs2: remove redundant check on outpos > pos Colin Ian King
2024-10-30  4:45 ` Zhihao Cheng
2024-10-30  7:43   ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox