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