]>
Commit | Line | Data |
---|---|---|
ce0431ee JR |
1 | From c9f7b4d356a453a01aa77a6bb74ca7ef49732c08 Mon Sep 17 00:00:00 2001 |
2 | From: Mike Gilbert <floppymaster@gmail.com> | |
3 | Date: Tue, 10 Jan 2017 02:39:05 -0500 | |
4 | Subject: [PATCH] build-sys: add check for gperf lookup function signature | |
5 | (#5055) | |
6 | ||
7 | gperf-3.1 generates lookup functions that take a size_t length | |
8 | parameter instead of unsigned int. Test for this at configure time. | |
9 | ||
10 | Fixes: https://github.com/systemd/systemd/issues/5039 | |
11 | --- | |
12 | configure.ac | 22 ++++++++++++++++++++++ | |
13 | src/basic/af-list.c | 2 +- | |
14 | src/basic/arphrd-list.c | 2 +- | |
15 | src/basic/cap-list.c | 2 +- | |
16 | src/basic/errno-list.c | 2 +- | |
17 | src/core/load-fragment.h | 2 +- | |
18 | src/journal/journald-server.h | 2 +- | |
19 | src/login/logind.h | 2 +- | |
20 | src/network/networkd-conf.h | 2 +- | |
21 | src/network/networkd-network.h | 2 +- | |
22 | src/nspawn/nspawn-settings.h | 2 +- | |
23 | src/resolve/dns-type.c | 2 +- | |
24 | src/resolve/resolved-conf.h | 2 +- | |
25 | src/test/test-af-list.c | 2 +- | |
26 | src/test/test-arphrd-list.c | 2 +- | |
27 | src/timesync/timesyncd-conf.h | 2 +- | |
28 | src/udev/net/link-config.h | 2 +- | |
29 | src/udev/udev-builtin-keyboard.c | 2 +- | |
30 | 19 files changed, 40 insertions(+), 18 deletions(-) | |
31 | ||
32 | diff --git a/configure.ac b/configure.ac | |
33 | index 11bd46c..d58fff5 100644 | |
34 | --- a/configure.ac | |
35 | +++ b/configure.ac | |
36 | @@ -255,6 +255,28 @@ AC_CHECK_SIZEOF(rlim_t,,[ | |
37 | #include <sys/resource.h> | |
38 | ]) | |
39 | ||
40 | +GPERF_TEST="$(echo foo,bar | ${GPERF} -L ANSI-C)" | |
41 | + | |
42 | +AC_COMPILE_IFELSE( | |
43 | + [AC_LANG_PROGRAM([ | |
44 | + #include <string.h> | |
45 | + const char * in_word_set(const char *, size_t); | |
46 | + $GPERF_TEST] | |
47 | + )], | |
48 | + [GPERF_LEN_TYPE=size_t], | |
49 | + [AC_COMPILE_IFELSE( | |
50 | + [AC_LANG_PROGRAM([ | |
51 | + #include <string.h> | |
52 | + const char * in_word_set(const char *, unsigned); | |
53 | + $GPERF_TEST] | |
54 | + )], | |
55 | + [GPERF_LEN_TYPE=unsigned], | |
56 | + [AC_MSG_ERROR([** unable to determine gperf len type])] | |
57 | + )] | |
58 | +) | |
59 | + | |
60 | +AC_DEFINE_UNQUOTED([GPERF_LEN_TYPE], [$GPERF_LEN_TYPE], [gperf len type]) | |
61 | + | |
62 | # ------------------------------------------------------------------------------ | |
63 | # we use python to build the man page index | |
64 | have_python=no | |
65 | diff --git a/src/basic/af-list.c b/src/basic/af-list.c | |
66 | index 3fac9c5..4b291d1 100644 | |
67 | --- a/src/basic/af-list.c | |
68 | +++ b/src/basic/af-list.c | |
69 | @@ -23,7 +23,7 @@ | |
70 | #include "af-list.h" | |
71 | #include "macro.h" | |
72 | ||
73 | -static const struct af_name* lookup_af(register const char *str, register unsigned int len); | |
74 | +static const struct af_name* lookup_af(register const char *str, register GPERF_LEN_TYPE len); | |
75 | ||
76 | #include "af-from-name.h" | |
77 | #include "af-to-name.h" | |
78 | diff --git a/src/basic/arphrd-list.c b/src/basic/arphrd-list.c | |
79 | index 6792d1e..2d598dc 100644 | |
80 | --- a/src/basic/arphrd-list.c | |
81 | +++ b/src/basic/arphrd-list.c | |
82 | @@ -23,7 +23,7 @@ | |
83 | #include "arphrd-list.h" | |
84 | #include "macro.h" | |
85 | ||
86 | -static const struct arphrd_name* lookup_arphrd(register const char *str, register unsigned int len); | |
87 | +static const struct arphrd_name* lookup_arphrd(register const char *str, register GPERF_LEN_TYPE len); | |
88 | ||
89 | #include "arphrd-from-name.h" | |
90 | #include "arphrd-to-name.h" | |
91 | diff --git a/src/basic/cap-list.c b/src/basic/cap-list.c | |
92 | index 3e773a0..d68cc78 100644 | |
93 | --- a/src/basic/cap-list.c | |
94 | +++ b/src/basic/cap-list.c | |
95 | @@ -26,7 +26,7 @@ | |
96 | #include "parse-util.h" | |
97 | #include "util.h" | |
98 | ||
99 | -static const struct capability_name* lookup_capability(register const char *str, register unsigned int len); | |
100 | +static const struct capability_name* lookup_capability(register const char *str, register GPERF_LEN_TYPE len); | |
101 | ||
102 | #include "cap-from-name.h" | |
103 | #include "cap-to-name.h" | |
104 | diff --git a/src/basic/errno-list.c b/src/basic/errno-list.c | |
105 | index 31b66ba..c6a01ee 100644 | |
106 | --- a/src/basic/errno-list.c | |
107 | +++ b/src/basic/errno-list.c | |
108 | @@ -23,7 +23,7 @@ | |
109 | #include "macro.h" | |
110 | ||
111 | static const struct errno_name* lookup_errno(register const char *str, | |
112 | - register unsigned int len); | |
113 | + register GPERF_LEN_TYPE len); | |
114 | ||
115 | #include "errno-from-name.h" | |
116 | #include "errno-to-name.h" | |
117 | diff --git a/src/core/load-fragment.h b/src/core/load-fragment.h | |
118 | index bbac2d8..fc27a07 100644 | |
119 | --- a/src/core/load-fragment.h | |
120 | +++ b/src/core/load-fragment.h | |
121 | @@ -120,7 +120,7 @@ int config_parse_restrict_namespaces(const char *unit, const char *filename, uns | |
122 | int config_parse_bind_paths(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); | |
123 | ||
124 | /* gperf prototypes */ | |
125 | -const struct ConfigPerfItem* load_fragment_gperf_lookup(const char *key, unsigned length); | |
126 | +const struct ConfigPerfItem* load_fragment_gperf_lookup(const char *key, GPERF_LEN_TYPE length); | |
127 | extern const char load_fragment_gperf_nulstr[]; | |
128 | ||
129 | typedef enum Disabled { | |
130 | diff --git a/src/journal/journald-server.h b/src/journal/journald-server.h | |
131 | index 99d9149..d1520c4 100644 | |
132 | --- a/src/journal/journald-server.h | |
133 | +++ b/src/journal/journald-server.h | |
134 | @@ -179,7 +179,7 @@ void server_dispatch_message(Server *s, struct iovec *iovec, unsigned n, unsigne | |
135 | void server_driver_message(Server *s, sd_id128_t message_id, const char *format, ...) _printf_(3,0) _sentinel_; | |
136 | ||
137 | /* gperf lookup function */ | |
138 | -const struct ConfigPerfItem* journald_gperf_lookup(const char *key, unsigned length); | |
139 | +const struct ConfigPerfItem* journald_gperf_lookup(const char *key, GPERF_LEN_TYPE length); | |
140 | ||
141 | int config_parse_storage(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); | |
142 | ||
143 | diff --git a/src/login/logind.h b/src/login/logind.h | |
144 | index 086fa1e..7556ee2 100644 | |
145 | --- a/src/login/logind.h | |
146 | +++ b/src/login/logind.h | |
147 | @@ -182,7 +182,7 @@ int manager_unit_is_active(Manager *manager, const char *unit); | |
148 | int manager_job_is_active(Manager *manager, const char *path); | |
149 | ||
150 | /* gperf lookup function */ | |
151 | -const struct ConfigPerfItem* logind_gperf_lookup(const char *key, unsigned length); | |
152 | +const struct ConfigPerfItem* logind_gperf_lookup(const char *key, GPERF_LEN_TYPE length); | |
153 | ||
154 | int manager_set_lid_switch_ignore(Manager *m, usec_t until); | |
155 | ||
156 | diff --git a/src/network/networkd-conf.h b/src/network/networkd-conf.h | |
157 | index 9381962..1136975 100644 | |
158 | --- a/src/network/networkd-conf.h | |
159 | +++ b/src/network/networkd-conf.h | |
160 | @@ -23,7 +23,7 @@ typedef struct Manager Manager; | |
161 | ||
162 | int manager_parse_config_file(Manager *m); | |
163 | ||
164 | -const struct ConfigPerfItem* networkd_gperf_lookup(const char *key, unsigned length); | |
165 | +const struct ConfigPerfItem* networkd_gperf_lookup(const char *key, GPERF_LEN_TYPE length); | |
166 | ||
167 | int config_parse_duid_type( | |
168 | const char *unit, | |
169 | diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h | |
170 | index 4cf784f..b7da9d2 100644 | |
171 | --- a/src/network/networkd-network.h | |
172 | +++ b/src/network/networkd-network.h | |
173 | @@ -244,7 +244,7 @@ int config_parse_ntp(const char *unit, const char *filename, unsigned line, cons | |
174 | /* Legacy IPv4LL support */ | |
175 | int config_parse_ipv4ll(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); | |
176 | ||
177 | -const struct ConfigPerfItem* network_network_gperf_lookup(const char *key, unsigned length); | |
178 | +const struct ConfigPerfItem* network_network_gperf_lookup(const char *key, GPERF_LEN_TYPE length); | |
179 | ||
180 | extern const sd_bus_vtable network_vtable[]; | |
181 | ||
182 | diff --git a/src/nspawn/nspawn-settings.h b/src/nspawn/nspawn-settings.h | |
183 | index 4bd0c64..e9ea087 100644 | |
184 | --- a/src/nspawn/nspawn-settings.h | |
185 | +++ b/src/nspawn/nspawn-settings.h | |
186 | @@ -103,7 +103,7 @@ bool settings_private_network(Settings *s); | |
187 | ||
188 | DEFINE_TRIVIAL_CLEANUP_FUNC(Settings*, settings_free); | |
189 | ||
190 | -const struct ConfigPerfItem* nspawn_gperf_lookup(const char *key, unsigned length); | |
191 | +const struct ConfigPerfItem* nspawn_gperf_lookup(const char *key, GPERF_LEN_TYPE length); | |
192 | ||
193 | int config_parse_capability(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); | |
194 | int config_parse_id128(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); | |
195 | diff --git a/src/resolve/dns-type.c b/src/resolve/dns-type.c | |
196 | index aaf5ed6..d89ae28 100644 | |
197 | --- a/src/resolve/dns-type.c | |
198 | +++ b/src/resolve/dns-type.c | |
199 | @@ -29,7 +29,7 @@ typedef const struct { | |
200 | } dns_type; | |
201 | ||
202 | static const struct dns_type_name * | |
203 | -lookup_dns_type (register const char *str, register unsigned int len); | |
204 | +lookup_dns_type (register const char *str, register GPERF_LEN_TYPE len); | |
205 | ||
206 | #include "dns_type-from-name.h" | |
207 | #include "dns_type-to-name.h" | |
208 | diff --git a/src/resolve/resolved-conf.h b/src/resolve/resolved-conf.h | |
209 | index fc425a3..8184d6c 100644 | |
210 | --- a/src/resolve/resolved-conf.h | |
211 | +++ b/src/resolve/resolved-conf.h | |
212 | @@ -41,7 +41,7 @@ int manager_parse_search_domains_and_warn(Manager *m, const char *string); | |
213 | int manager_add_dns_server_by_string(Manager *m, DnsServerType type, const char *word); | |
214 | int manager_parse_dns_server_string_and_warn(Manager *m, DnsServerType type, const char *string); | |
215 | ||
216 | -const struct ConfigPerfItem* resolved_gperf_lookup(const char *key, unsigned length); | |
217 | +const struct ConfigPerfItem* resolved_gperf_lookup(const char *key, GPERF_LEN_TYPE length); | |
218 | ||
219 | int config_parse_dns_servers(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); | |
220 | int config_parse_search_domains(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); | |
221 | diff --git a/src/test/test-af-list.c b/src/test/test-af-list.c | |
222 | index aeaa092..e247913 100644 | |
223 | --- a/src/test/test-af-list.c | |
224 | +++ b/src/test/test-af-list.c | |
225 | @@ -24,7 +24,7 @@ | |
226 | #include "string-util.h" | |
227 | #include "util.h" | |
228 | ||
229 | -static const struct af_name* lookup_af(register const char *str, register unsigned int len); | |
230 | +static const struct af_name* lookup_af(register const char *str, register GPERF_LEN_TYPE len); | |
231 | ||
232 | #include "af-from-name.h" | |
233 | #include "af-list.h" | |
234 | diff --git a/src/test/test-arphrd-list.c b/src/test/test-arphrd-list.c | |
235 | index f3989ad..8f4f342 100644 | |
236 | --- a/src/test/test-arphrd-list.c | |
237 | +++ b/src/test/test-arphrd-list.c | |
238 | @@ -24,7 +24,7 @@ | |
239 | #include "string-util.h" | |
240 | #include "util.h" | |
241 | ||
242 | -static const struct arphrd_name* lookup_arphrd(register const char *str, register unsigned int len); | |
243 | +static const struct arphrd_name* lookup_arphrd(register const char *str, register GPERF_LEN_TYPE len); | |
244 | ||
245 | #include "arphrd-from-name.h" | |
246 | #include "arphrd-list.h" | |
247 | diff --git a/src/timesync/timesyncd-conf.h b/src/timesync/timesyncd-conf.h | |
248 | index cba0724..0280697 100644 | |
249 | --- a/src/timesync/timesyncd-conf.h | |
250 | +++ b/src/timesync/timesyncd-conf.h | |
251 | @@ -22,7 +22,7 @@ | |
252 | #include "conf-parser.h" | |
253 | #include "timesyncd-manager.h" | |
254 | ||
255 | -const struct ConfigPerfItem* timesyncd_gperf_lookup(const char *key, unsigned length); | |
256 | +const struct ConfigPerfItem* timesyncd_gperf_lookup(const char *key, GPERF_LEN_TYPE length); | |
257 | ||
258 | int manager_parse_server_string(Manager *m, ServerType type, const char *string); | |
259 | ||
260 | diff --git a/src/udev/net/link-config.h b/src/udev/net/link-config.h | |
261 | index a99060d..5a25cec 100644 | |
262 | --- a/src/udev/net/link-config.h | |
263 | +++ b/src/udev/net/link-config.h | |
264 | @@ -94,7 +94,7 @@ const char *mac_policy_to_string(MACPolicy p) _const_; | |
265 | MACPolicy mac_policy_from_string(const char *p) _pure_; | |
266 | ||
267 | /* gperf lookup function */ | |
268 | -const struct ConfigPerfItem* link_config_gperf_lookup(const char *key, unsigned length); | |
269 | +const struct ConfigPerfItem* link_config_gperf_lookup(const char *key, GPERF_LEN_TYPE length); | |
270 | ||
271 | int config_parse_mac_policy(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); | |
272 | int config_parse_name_policy(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); | |
273 | diff --git a/src/udev/udev-builtin-keyboard.c b/src/udev/udev-builtin-keyboard.c | |
274 | index aa10bea..0902411 100644 | |
275 | --- a/src/udev/udev-builtin-keyboard.c | |
276 | +++ b/src/udev/udev-builtin-keyboard.c | |
277 | @@ -29,7 +29,7 @@ | |
278 | #include "string-util.h" | |
279 | #include "udev.h" | |
280 | ||
281 | -static const struct key *keyboard_lookup_key(const char *str, unsigned len); | |
282 | +static const struct key *keyboard_lookup_key(const char *str, GPERF_LEN_TYPE len); | |
283 | #include "keyboard-keys-from-name.h" | |
284 | ||
285 | static int install_force_release(struct udev_device *dev, const unsigned *release, unsigned release_count) { |