[PATCH] erofs-utils: lib: suppress a false-positive warning in kite-deflate

Gao Xiang hsiangkao at linux.alibaba.com
Tue Sep 12 13:27:01 AEST 2023


`gcc (Debian 13.2.0-2) 13.2.0` gives the following report:

kite_deflate.c: In function 'kite_deflate_writeblock':
kite_deflate.c:428:57: warning: 'distLevels' may be used uninitialized
[-Wmaybe-uninitialized]
428 |                                   fixed ? 5 :
    distLevels[distSlot]);
|                                                         ^
kite_deflate.c:393:34: note: 'distLevels' was declared here
  393 |         const u8 *litLenLevels, *distLevels;

Actually, distLevels won't be used in the static-huffman mode.

Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
 lib/kite_deflate.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/kite_deflate.c b/lib/kite_deflate.c
index 91019e3..8667954 100644
--- a/lib/kite_deflate.c
+++ b/lib/kite_deflate.c
@@ -405,6 +405,7 @@ static void kite_deflate_writeblock(struct kite_deflate *s, bool fixed)
 		distCodes = kstaticHuff_distCodes;
 
 		litLenLevels = kstaticHuff_litLenLevels;
+		distLevels = NULL;
 	}
 
 	for (i = 0; i < s->symbols; ++i) {
-- 
2.40.1



More information about the Linux-erofs mailing list