diff mbox series

btrfs: Remove useless call "zlib_inflateEnd"

Message ID 1617099421-58511-1-git-send-email-jiapeng.chong@linux.alibaba.com (mailing list archive)
State New
Headers show
Series btrfs: Remove useless call "zlib_inflateEnd" | expand

Commit Message

Jiapeng Chong March 30, 2021, 10:17 a.m. UTC
Fix the following whitescan warning:

Calling "zlib_inflateEnd(&workspace->strm)" is only useful for its
return value, which is ignored.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 fs/btrfs/zlib.c | 1 -
 1 file changed, 1 deletion(-)

Comments

David Sterba April 1, 2021, 3:16 p.m. UTC | #1
On Tue, Mar 30, 2021 at 06:17:01PM +0800, Jiapeng Chong wrote:
> Fix the following whitescan warning:
> 
> Calling "zlib_inflateEnd(&workspace->strm)" is only useful for its
> return value, which is ignored.

According to the zlib API documentation in include/linux/zlib.h

301 extern int zlib_deflateEnd (z_streamp strm);
302 /*
303      All dynamically allocated data structures for this stream are freed.
304    This function discards any unprocessed input and does not flush any
305    pending output.
306
307      deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
308    stream state was inconsistent, Z_DATA_ERROR if the stream was freed
309    prematurely (some input or output was discarded). In the error case,
310    msg may be set but then points to a static string (which must not be
311    deallocated).
312 */

The first paragraph says it could free data, so the call needs to be
there. The return value could have some meaning as it could point out to
some inconsistency in zlib internal state but just deleting is IMO
wrong.
diff mbox series

Patch

diff --git a/fs/btrfs/zlib.c b/fs/btrfs/zlib.c
index d524acf..93537cc 100644
--- a/fs/btrfs/zlib.c
+++ b/fs/btrfs/zlib.c
@@ -357,7 +357,6 @@  int zlib_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
 	else
 		ret = 0;
 done:
-	zlib_inflateEnd(&workspace->strm);
 	if (data_in)
 		kunmap(pages_in[page_in_index]);
 	if (!ret)