diff options
| author | Enzo Matsumiya <ematsumiya@suse.de> | 2025-12-01 12:09:49 -0300 |
|---|---|---|
| committer | Enzo Matsumiya <ematsumiya@suse.de> | 2025-12-01 12:09:49 -0300 |
| commit | 9607329b3a7cbfe1a4b892141a924f41d60a5e50 (patch) | |
| tree | 8a9d11f0e1aac708957e531eedc7465877ee5343 | |
| parent | 7d0a66e4bb9081d75c82ec4957c50034cb0ea449 (diff) | |
| download | linux-9607329b3a7cbfe1a4b892141a924f41d60a5e50.tar.gz linux-9607329b3a7cbfe1a4b892141a924f41d60a5e50.tar.bz2 linux-9607329b3a7cbfe1a4b892141a924f41d60a5e50.zip | |
smb: client: compress: fix LZ77 match len count
cur is incremented unconditionally when not matching wnd.
Move increments to inside the loop.
Signed-off-by: Enzo Matsumiya <ematsumiya@suse.de>
| -rw-r--r-- | fs/smb/client/compress/lz77.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/smb/client/compress/lz77.c b/fs/smb/client/compress/lz77.c index 96e8a8057a77..e32a9bd9a94f 100644 --- a/fs/smb/client/compress/lz77.c +++ b/fs/smb/client/compress/lz77.c @@ -51,11 +51,11 @@ static __always_inline void lz77_write32(u32 *ptr, u32 v) static __always_inline u32 lz77_match_len(const void *wnd, const void *cur, const void *end) { const void *start = cur; - u64 diff; /* Safe for a do/while because otherwise we wouldn't reach here from the main loop. */ do { - diff = lz77_read64(cur) ^ lz77_read64(wnd); + const u64 diff = lz77_read64(cur) ^ lz77_read64(wnd); + if (!diff) { cur += LZ77_STEP_SIZE; wnd += LZ77_STEP_SIZE; @@ -69,8 +69,10 @@ static __always_inline u32 lz77_match_len(const void *wnd, const void *cur, cons return (cur - start); } while (likely(cur + LZ77_STEP_SIZE < end)); - while (cur < end && lz77_read8(cur++) == lz77_read8(wnd++)) - ; + while (cur < end && lz77_read8(cur) == lz77_read8(wnd)) { + cur++; + wnd++; + } return (cur - start); } |
