Skip to contentSkip to conversation

jffs2: remove redundant check on outpos > pos

PATCH In review Colin Ian King 3 participants 3 messages Oct 29, 2024 – Oct 30, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 jffs2: remove redundant check on outpos > pos

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.

---
 fs/jffs2/compr_rubin.c | 5 -----
 1 file changed, 5 deletions(-)
fs/jffs2/compr_rubin.c +0 -5
index 556de100ebd5..9854253d0108 100644
@@ -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 */
 
Signature · 1 line
2.39.5
#1 lore raw
Quoted 14 lines · 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.

---
  fs/jffs2/compr_rubin.c | 5 -----
  1 file changed, 5 deletions(-)
fs/jffs2/compr_rubin.c +0 -0
index 556de100ebd5..9854253d0108 100644

fs/jffs2/compr_rubin.c static int rubin_do_compress(int bit_divider, int *bits, unsigned char *data_in, · line 278

Quoted 3 lines
fs/jffs2/compr_rubin.c +0 -0
@@ -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.

Quoted 9 lines
fs/jffs2/compr_rubin.c +0 -5
-	if (outpos > pos) {
-		/* We failed */
-		return -1;
-	}
-
  	/* Tell the caller how much we managed to compress,
  	 * and how much space it took */
 
#2 lore raw
Quoted 10 lines · Zhihao Cheng
Quoted 9 lines · 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.

---
  fs/jffs2/compr_rubin.c | 5 -----
  1 file changed, 5 deletions(-)
Quoted 8 lines

fs/jffs2/compr_rubin.c static int rubin_do_compress(int bit_divider, int *bits, unsigned char *data_in, · line 276

Quoted 6 lines
fs/jffs2/compr_rubin.c +0 -0
index 556de100ebd5..9854253d0108 100644
@@ -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