1From 7e3a795cbeea94b3324aa926f2b11904cb169acc Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 2 Jul 2024 22:02:38 -0700
4Subject: [PATCH] Do not override 'const' qualifier
5
6This has worked so far but with fortified system headers from
7Glibc 2.40+ and clang compiler it ends up in compile errors
8
9| 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:
10| /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
11|    77 | __NTH (strcpy (__fortify_clang_overload_arg (char *, __restrict, __dest),
12|       |                                                                  ^
13| /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
14|    86 | __NTH (stpcpy (__fortify_clang_overload_arg (char *, __restrict, __dest),
15|       |                                                                  ^
16| /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
17|    96 | __NTH (strncpy (__fortify_clang_overload_arg (char *, __restrict, __dest),
18|       |                                                                   ^
19| /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
20|   107 | __NTH (stpncpy (__fortify_clang_overload_arg (char *, ,__dest),
21|       |                                                        ^
22| /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
23|   136 | __NTH (strcat (__fortify_clang_overload_arg (char *, __restrict, __dest),
24|       |                                                                  ^
25| /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
26|   145 | __NTH (strncat (__fortify_clang_overload_arg (char *, __restrict, __dest),
27|       |                                                                   ^
28| /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
29|   161 | __NTH (strlcpy (__fortify_clang_overload_arg (char *, __restrict, __dest),
30
31Therefore adjust needed places to use const qualifier
32
33Upstream-Status: Submitted [https://codeberg.org/miurahr/inflate64/pulls/13]
34Signed-off-by: Khem Raj <raj.khem@gmail.com>
35---
36 src/lib/deflate.h          | 2 +-
37 src/lib/deflate_tree.c     | 4 ++--
38 src/lib/inflate64_config.h | 3 ---
39 3 files changed, 3 insertions(+), 6 deletions(-)
40
41diff --git a/src/lib/deflate.h b/src/lib/deflate.h
42index 72a324f..c780be9 100644
43--- a/src/lib/deflate.h
44+++ b/src/lib/deflate.h
45@@ -288,6 +288,6 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, char FAR *buf,
46   extern const unsigned char ZLIB_INTERNAL _dist_code[];
47 #endif
48 #endif
49-extern uch ZLIB_INTERNAL length_code[];
50+extern const uch ZLIB_INTERNAL length_code[];
51
52 #endif /* DEFLATE_H */
53diff --git a/src/lib/deflate_tree.c b/src/lib/deflate_tree.c
54index 5a66139..cdee934 100644
55--- a/src/lib/deflate_tree.c
56+++ b/src/lib/deflate_tree.c
57@@ -78,10 +78,10 @@ local const uch bl_order[BL_CODES]
58
59 #define DIST_CODE_LEN  768 /* see definition of array dist_code below */
60
61-local int base_length[LENGTH_CODES];
62+local const int base_length[LENGTH_CODES];
63 /* First normalized length for each code (0 = MIN_MATCH) */
64
65-uch length_code[BASE_MATCH-MIN_MATCH+1];
66+const uch length_code[BASE_MATCH-MIN_MATCH+1];
67 /* length code for each normalized match length (0 == MIN_MATCH) */
68
69 #if defined(GEN_TREES_H) || !defined(STDC)
70diff --git a/src/lib/inflate64_config.h b/src/lib/inflate64_config.h
71index 16cfd12..ade7300 100644
72--- a/src/lib/inflate64_config.h
73+++ b/src/lib/inflate64_config.h
74@@ -53,9 +53,6 @@
75 #  define FAR
76 #endif
77
78-#ifndef const
79-#  define const
80-#endif
81 #define z_const const
82
83 typedef unsigned char  uch;
84