From 7e3a795cbeea94b3324aa926f2b11904cb169acc Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Tue, 2 Jul 2024 22:02:38 -0700 Subject: [PATCH] Do not override 'const' qualifier This has worked so far but with fortified system headers from Glibc 2.40+ and clang compiler it ends up in compile errors | In file included from /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/python3-inflate64/1.0.0/recipe-sysroot/usr/include/string.h:548: | /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/python3-inflate64/1.0.0/recipe-sysroot/usr/include/bits/string_fortified.h:77:66: error: pass_object_size attribute only applies to constant pointer arguments | 77 | __NTH (strcpy (__fortify_clang_overload_arg (char *, __restrict, __dest), | | ^ | /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/python3-inflate64/1.0.0/recipe-sysroot/usr/include/bits/string_fortified.h:86:66: error: pass_object_size attribute only applies to constant pointer arguments | 86 | __NTH (stpcpy (__fortify_clang_overload_arg (char *, __restrict, __dest), | | ^ | /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/python3-inflate64/1.0.0/recipe-sysroot/usr/include/bits/string_fortified.h:96:67: error: pass_object_size attribute only applies to constant pointer arguments | 96 | __NTH (strncpy (__fortify_clang_overload_arg (char *, __restrict, __dest), | | ^ | /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/python3-inflate64/1.0.0/recipe-sysroot/usr/include/bits/string_fortified.h:107:56: error: pass_object_size attribute only applies to constant pointer arguments | 107 | __NTH (stpncpy (__fortify_clang_overload_arg (char *, ,__dest), | | ^ | /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/python3-inflate64/1.0.0/recipe-sysroot/usr/include/bits/string_fortified.h:136:66: error: pass_object_size attribute only applies to constant pointer arguments | 136 | __NTH (strcat (__fortify_clang_overload_arg (char *, __restrict, __dest), | | ^ | /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/python3-inflate64/1.0.0/recipe-sysroot/usr/include/bits/string_fortified.h:145:67: error: pass_object_size attribute only applies to constant pointer arguments | 145 | __NTH (strncat (__fortify_clang_overload_arg (char *, __restrict, __dest), | | ^ | /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/python3-inflate64/1.0.0/recipe-sysroot/usr/include/bits/string_fortified.h:161:67: error: pass_object_size attribute only applies to constant pointer arguments | 161 | __NTH (strlcpy (__fortify_clang_overload_arg (char *, __restrict, __dest), Therefore adjust needed places to use const qualifier Upstream-Status: Submitted [https://codeberg.org/miurahr/inflate64/pulls/13] Signed-off-by: Khem Raj --- src/lib/deflate.h | 2 +- src/lib/deflate_tree.c | 4 ++-- src/lib/inflate64_config.h | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/lib/deflate.h b/src/lib/deflate.h index 72a324f..c780be9 100644 --- a/src/lib/deflate.h +++ b/src/lib/deflate.h @@ -288,6 +288,6 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, char FAR *buf, extern const unsigned char ZLIB_INTERNAL _dist_code[]; #endif #endif -extern uch ZLIB_INTERNAL length_code[]; +extern const uch ZLIB_INTERNAL length_code[]; #endif /* DEFLATE_H */ diff --git a/src/lib/deflate_tree.c b/src/lib/deflate_tree.c index 5a66139..cdee934 100644 --- a/src/lib/deflate_tree.c +++ b/src/lib/deflate_tree.c @@ -78,10 +78,10 @@ local const uch bl_order[BL_CODES] #define DIST_CODE_LEN 768 /* see definition of array dist_code below */ -local int base_length[LENGTH_CODES]; +local const int base_length[LENGTH_CODES]; /* First normalized length for each code (0 = MIN_MATCH) */ -uch length_code[BASE_MATCH-MIN_MATCH+1]; +const uch length_code[BASE_MATCH-MIN_MATCH+1]; /* length code for each normalized match length (0 == MIN_MATCH) */ #if defined(GEN_TREES_H) || !defined(STDC) diff --git a/src/lib/inflate64_config.h b/src/lib/inflate64_config.h index 16cfd12..ade7300 100644 --- a/src/lib/inflate64_config.h +++ b/src/lib/inflate64_config.h @@ -53,9 +53,6 @@ # define FAR #endif -#ifndef const -# define const -#endif #define z_const const typedef unsigned char uch;