Skip to contentSkip to conversation

smb/client: Fix logically dead code

PATCH Applied Advait Dhamorikar 2 participants 2 messages Oct 7, 2024

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

PATCH v2 1/1 smb/client: Fix logically dead code

The if condition in collect_sample: can never be satisfied because of a logical contradiction. The indicated dead code may have performed some action; that action will never occur.

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

---
v1->v2: update short log and changelog

 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
Applied
#1 lore raw

Merged into cifs-2.6.git for-next

(also FYI - a similar patch was submitted soon after this one by Colin, but was duplicate)

Quoted 38 lines · Advait Dhamorikar

The if condition in collect_sample: can never be satisfied because of a logical contradiction. The indicated dead code may have performed some action; that action will never occur.

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

---
v1->v2: update short log and changelog

 fs/smb/client/compress.c | 4 ----
 1 file changed, 4 deletions(-)
fs/smb/client/compress.c +0 -5
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)
--

2.34.1

Signature · 3 lines
Thanks,

Steve