Skip to contentSkip to conversation

Fix logically dead code

PATCH Superseded Advait Dhamorikar 4 participants 4 messages Oct 4, 2024 – Oct 5, 2024

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix logically dead code

The if condition in collect_sample: can never be satisfied because of a logical contradiction.

Fixes 94ae8c3fee94 ("smb: client: compress: LZ77 code improvements cleanup")
---
 fs/smb/client/compress.c | 4 ----
 1 file changed, 4 deletions(-)
fs/smb/client/compress.c +0 -4
index 63b5a55b7a57..766b4de13da7 100644
@@ -166,7 +166,6 @@ static int collect_sample(const struct iov_iter *iter, ssize_t max, u8 *sample)
 	loff_t start = iter->xarray_start + iter->iov_offset;
 	pgoff_t last, index = start / PAGE_SIZE;
 	size_t len, off, foff;
-	ssize_t ret = 0;
 	void *p;
 	int s = 0;
 
@@ -193,9 +192,6 @@ static int collect_sample(const struct iov_iter *iter, ssize_t max, u8 *sample)
 				memcpy(&sample[s], p, len2);
 				kunmap_local(p);
 
-				if (ret < 0)
-					return ret;
-
 				s += len2;
 
 				if (len2 < SZ_2K || s >= max - SZ_2K)
Signature · 1 line
2.34.1
#1 lore raw
Quoted 2 lines · Advait Dhamorikar

The if condition in collect_sample: can never be satisfied because of a logical contradiction.

Add a better change log explaining how you found the problem.

Also your short log is missing subsystem information. Check submitting patches document for details on how to write shot logs and change logs.

Quoted 20 lines
Fixes 94ae8c3fee94 ("smb: client: compress: LZ77 code improvements cleanup")
---
  fs/smb/client/compress.c | 4 ----
  1 file changed, 4 deletions(-)
fs/smb/client/compress.c +0 -1
index 63b5a55b7a57..766b4de13da7 100644
@@ -166,7 +166,6 @@ static int collect_sample(const struct iov_iter *iter, ssize_t max, u8 *sample)
  	loff_t start = iter->xarray_start + iter->iov_offset;
  	pgoff_t last, index = start / PAGE_SIZE;
  	size_t len, off, foff;
-	ssize_t ret = 0;
  	void *p;
  	int s = 0;
 

fs/smb/client/compress.c static int collect_sample(const struct iov_iter *iter, ssize_t max, u8 *sample) · line 198

Quoted 6 lines
fs/smb/client/compress.c +0 -3
@@ -193,9 +192,6 @@ static int collect_sample(const struct iov_iter *iter, ssize_t max, u8 *sample)
  				memcpy(&sample[s], p, len2);
  				kunmap_local(p);
 
-				if (ret < 0)
-					return ret;
-

The change itself looks good to me - unless the intent is to check the return from kunmap_local() and take action based on it instead of removing the conditional that checks the ret value.

fs/smb/client/compress.c static int collect_sample(const struct iov_iter *iter, ssize_t max, u8 *sample) · line 197

Quoted 3 lines
fs/smb/client/compress.c +0 -0
  				s += len2;
 
  				if (len2 < SZ_2K || s >= max - SZ_2K)

thanks,
-- Shuah

#2 lore raw

Le 04/10/2024 à 20:00, Shuah Khan a écrit :

Quoted 32 lines · Advait Dhamorikar
Quoted 2 lines

The if condition in collect_sample: can never be satisfied because of a logical contradiction.

Add a better change log explaining how you found the problem.

Also your short log is missing subsystem information. Check submitting patches document for details on how to write shot logs and change logs.

Quoted 22 lines
Fixes 94ae8c3fee94 ("smb: client: compress: LZ77 code improvements cleanup")

---
  fs/smb/client/compress.c | 4 ----

  1 file changed, 4 deletions(-)
fs/smb/client/compress.c +0 -1
index 63b5a55b7a57..766b4de13da7 100644
@@ -166,7 +166,6 @@ static int collect_sample(const struct iov_iter 
 *iter, ssize_t max, u8 *sample)
       loff_t start = iter->xarray_start + iter->iov_offset;
       pgoff_t last, index = start / PAGE_SIZE;
       size_t len, off, foff;
-    ssize_t ret = 0;
       void *p;
       int s = 0;
@@ -193,9 +192,6 @@ static int collect_sample(const struct iov_iter 
 *iter, ssize_t max, u8 *sample)
                   memcpy(&sample[s], p, len2);
Quoted 8 lines

fs/smb/client/compress.c static int collect_sample(const struct iov_iter *iter, ssize_t max, u8 *sample) · line 198

Quoted 4 lines
fs/smb/client/compress.c +0 -3
                   kunmap_local(p);
-                if (ret < 0)
-                    return ret;
-

The change itself looks good to me - unless the intent is to check the return from kunmap_local() and take action based on it instead of removing the conditional that checks the ret value.

IIUC, kunmap_local() does not return anything.

CJ

Quoted 8 lines

fs/smb/client/compress.c static int collect_sample(const struct iov_iter *iter, ssize_t max, u8 *sample) · line 197

Quoted 3 lines
fs/smb/client/compress.c +0 -0
                   s += len2;
                   if (len2 < SZ_2K || s >= max - SZ_2K)

thanks,
-- Shuah