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