232-0002-build-sys-add-check-for-gperf-lookup-function-signat.patch 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. From 016fb3b83b861cfe58694996076a9764dcb46475 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 2/2] build-sys: add check for gperf lookup function signature
  5. (#5055)
  6. gperf-3.1 generates lookup functions that take a size_t length
  7. parameter instead of unsigned int. Test for this at configure time.
  8. Fixes: https://github.com/systemd/systemd/issues/5039
  9. ---
  10. configure.ac | 22 ++++++++++++++++++++++
  11. src/basic/af-list.c | 2 +-
  12. src/basic/arphrd-list.c | 2 +-
  13. src/basic/cap-list.c | 2 +-
  14. src/basic/errno-list.c | 2 +-
  15. src/core/load-fragment.h | 2 +-
  16. src/journal/journald-server.h | 2 +-
  17. src/login/logind.h | 2 +-
  18. src/network/networkd-conf.h | 2 +-
  19. src/network/networkd-netdev.h | 2 +-
  20. src/network/networkd-network.h | 2 +-
  21. src/nspawn/nspawn-settings.h | 2 +-
  22. src/resolve/dns-type.c | 2 +-
  23. src/resolve/resolved-conf.h | 2 +-
  24. src/test/test-af-list.c | 2 +-
  25. src/test/test-arphrd-list.c | 2 +-
  26. src/timesync/timesyncd-conf.h | 2 +-
  27. src/udev/net/link-config.h | 2 +-
  28. src/udev/udev-builtin-keyboard.c | 2 +-
  29. 19 files changed, 40 insertions(+), 18 deletions(-)
  30. diff --git a/configure.ac b/configure.ac
  31. index 1928e65bd..5c639e32d 100644
  32. --- a/configure.ac
  33. +++ b/configure.ac
  34. @@ -258,6 +258,28 @@ AC_CHECK_SIZEOF(rlim_t,,[
  35. #include <sys/resource.h>
  36. ])
  37. +GPERF_TEST="$(echo foo,bar | ${GPERF} -L ANSI-C)"
  38. +
  39. +AC_COMPILE_IFELSE(
  40. + [AC_LANG_PROGRAM([
  41. + #include <string.h>
  42. + const char * in_word_set(const char *, size_t);
  43. + $GPERF_TEST]
  44. + )],
  45. + [GPERF_LEN_TYPE=size_t],
  46. + [AC_COMPILE_IFELSE(
  47. + [AC_LANG_PROGRAM([
  48. + #include <string.h>
  49. + const char * in_word_set(const char *, unsigned);
  50. + $GPERF_TEST]
  51. + )],
  52. + [GPERF_LEN_TYPE=unsigned],
  53. + [AC_MSG_ERROR([** unable to determine gperf len type])]
  54. + )]
  55. +)
  56. +
  57. +AC_DEFINE_UNQUOTED([GPERF_LEN_TYPE], [$GPERF_LEN_TYPE], [gperf len type])
  58. +
  59. # ------------------------------------------------------------------------------
  60. # we use python to build the man page index
  61. have_python=no
  62. diff --git a/src/basic/af-list.c b/src/basic/af-list.c
  63. index 3fac9c508..4b291d177 100644
  64. --- a/src/basic/af-list.c
  65. +++ b/src/basic/af-list.c
  66. @@ -23,7 +23,7 @@
  67. #include "af-list.h"
  68. #include "macro.h"
  69. -static const struct af_name* lookup_af(register const char *str, register unsigned int len);
  70. +static const struct af_name* lookup_af(register const char *str, register GPERF_LEN_TYPE len);
  71. #include "af-from-name.h"
  72. #include "af-to-name.h"
  73. diff --git a/src/basic/arphrd-list.c b/src/basic/arphrd-list.c
  74. index 6792d1ee3..2d598dc66 100644
  75. --- a/src/basic/arphrd-list.c
  76. +++ b/src/basic/arphrd-list.c
  77. @@ -23,7 +23,7 @@
  78. #include "arphrd-list.h"
  79. #include "macro.h"
  80. -static const struct arphrd_name* lookup_arphrd(register const char *str, register unsigned int len);
  81. +static const struct arphrd_name* lookup_arphrd(register const char *str, register GPERF_LEN_TYPE len);
  82. #include "arphrd-from-name.h"
  83. #include "arphrd-to-name.h"
  84. diff --git a/src/basic/cap-list.c b/src/basic/cap-list.c
  85. index 3e773a06f..d68cc78d0 100644
  86. --- a/src/basic/cap-list.c
  87. +++ b/src/basic/cap-list.c
  88. @@ -26,7 +26,7 @@
  89. #include "parse-util.h"
  90. #include "util.h"
  91. -static const struct capability_name* lookup_capability(register const char *str, register unsigned int len);
  92. +static const struct capability_name* lookup_capability(register const char *str, register GPERF_LEN_TYPE len);
  93. #include "cap-from-name.h"
  94. #include "cap-to-name.h"
  95. diff --git a/src/basic/errno-list.c b/src/basic/errno-list.c
  96. index 31b66bad5..c6a01eec8 100644
  97. --- a/src/basic/errno-list.c
  98. +++ b/src/basic/errno-list.c
  99. @@ -23,7 +23,7 @@
  100. #include "macro.h"
  101. static const struct errno_name* lookup_errno(register const char *str,
  102. - register unsigned int len);
  103. + register GPERF_LEN_TYPE len);
  104. #include "errno-from-name.h"
  105. #include "errno-to-name.h"
  106. diff --git a/src/core/load-fragment.h b/src/core/load-fragment.h
  107. index c05f205c3..ede6b1f73 100644
  108. --- a/src/core/load-fragment.h
  109. +++ b/src/core/load-fragment.h
  110. @@ -118,7 +118,7 @@ int config_parse_user_group(const char *unit, const char *filename, unsigned lin
  111. int config_parse_user_group_strv(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);
  112. /* gperf prototypes */
  113. -const struct ConfigPerfItem* load_fragment_gperf_lookup(const char *key, unsigned length);
  114. +const struct ConfigPerfItem* load_fragment_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
  115. extern const char load_fragment_gperf_nulstr[];
  116. typedef enum Disabled {
  117. diff --git a/src/journal/journald-server.h b/src/journal/journald-server.h
  118. index 99d91496b..d1520c45d 100644
  119. --- a/src/journal/journald-server.h
  120. +++ b/src/journal/journald-server.h
  121. @@ -179,7 +179,7 @@ void server_dispatch_message(Server *s, struct iovec *iovec, unsigned n, unsigne
  122. void server_driver_message(Server *s, sd_id128_t message_id, const char *format, ...) _printf_(3,0) _sentinel_;
  123. /* gperf lookup function */
  124. -const struct ConfigPerfItem* journald_gperf_lookup(const char *key, unsigned length);
  125. +const struct ConfigPerfItem* journald_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
  126. 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);
  127. diff --git a/src/login/logind.h b/src/login/logind.h
  128. index 086fa1eeb..7556ee2e4 100644
  129. --- a/src/login/logind.h
  130. +++ b/src/login/logind.h
  131. @@ -182,7 +182,7 @@ int manager_unit_is_active(Manager *manager, const char *unit);
  132. int manager_job_is_active(Manager *manager, const char *path);
  133. /* gperf lookup function */
  134. -const struct ConfigPerfItem* logind_gperf_lookup(const char *key, unsigned length);
  135. +const struct ConfigPerfItem* logind_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
  136. int manager_set_lid_switch_ignore(Manager *m, usec_t until);
  137. diff --git a/src/network/networkd-conf.h b/src/network/networkd-conf.h
  138. index c7bfb42a7..00ddb7672 100644
  139. --- a/src/network/networkd-conf.h
  140. +++ b/src/network/networkd-conf.h
  141. @@ -23,7 +23,7 @@
  142. int manager_parse_config_file(Manager *m);
  143. -const struct ConfigPerfItem* networkd_gperf_lookup(const char *key, unsigned length);
  144. +const struct ConfigPerfItem* networkd_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
  145. int config_parse_duid_type(
  146. const char *unit,
  147. diff --git a/src/network/networkd-netdev.h b/src/network/networkd-netdev.h
  148. index 70ff947b9..37c743121 100644
  149. --- a/src/network/networkd-netdev.h
  150. +++ b/src/network/networkd-netdev.h
  151. @@ -175,7 +175,7 @@ NetDevKind netdev_kind_from_string(const char *d) _pure_;
  152. 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);
  153. /* gperf */
  154. -const struct ConfigPerfItem* network_netdev_gperf_lookup(const char *key, unsigned length);
  155. +const struct ConfigPerfItem* network_netdev_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
  156. /* Macros which append INTERFACE= to the message */
  157. diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h
  158. index 42fc82d39..09c3b3a3a 100644
  159. --- a/src/network/networkd-network.h
  160. +++ b/src/network/networkd-network.h
  161. @@ -236,7 +236,7 @@ int config_parse_dhcp_route_table(const char *unit, const char *filename, unsign
  162. /* Legacy IPv4LL support */
  163. 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);
  164. -const struct ConfigPerfItem* network_network_gperf_lookup(const char *key, unsigned length);
  165. +const struct ConfigPerfItem* network_network_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
  166. extern const sd_bus_vtable network_vtable[];
  167. diff --git a/src/nspawn/nspawn-settings.h b/src/nspawn/nspawn-settings.h
  168. index 231e6d726..4ae34f8e2 100644
  169. --- a/src/nspawn/nspawn-settings.h
  170. +++ b/src/nspawn/nspawn-settings.h
  171. @@ -103,7 +103,7 @@ bool settings_private_network(Settings *s);
  172. DEFINE_TRIVIAL_CLEANUP_FUNC(Settings*, settings_free);
  173. -const struct ConfigPerfItem* nspawn_gperf_lookup(const char *key, unsigned length);
  174. +const struct ConfigPerfItem* nspawn_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
  175. 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);
  176. 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);
  177. diff --git a/src/resolve/dns-type.c b/src/resolve/dns-type.c
  178. index aaf5ed62c..d89ae28dc 100644
  179. --- a/src/resolve/dns-type.c
  180. +++ b/src/resolve/dns-type.c
  181. @@ -29,7 +29,7 @@ typedef const struct {
  182. } dns_type;
  183. static const struct dns_type_name *
  184. -lookup_dns_type (register const char *str, register unsigned int len);
  185. +lookup_dns_type (register const char *str, register GPERF_LEN_TYPE len);
  186. #include "dns_type-from-name.h"
  187. #include "dns_type-to-name.h"
  188. diff --git a/src/resolve/resolved-conf.h b/src/resolve/resolved-conf.h
  189. index fc425a36b..8184d6cad 100644
  190. --- a/src/resolve/resolved-conf.h
  191. +++ b/src/resolve/resolved-conf.h
  192. @@ -41,7 +41,7 @@ int manager_parse_search_domains_and_warn(Manager *m, const char *string);
  193. int manager_add_dns_server_by_string(Manager *m, DnsServerType type, const char *word);
  194. int manager_parse_dns_server_string_and_warn(Manager *m, DnsServerType type, const char *string);
  195. -const struct ConfigPerfItem* resolved_gperf_lookup(const char *key, unsigned length);
  196. +const struct ConfigPerfItem* resolved_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
  197. 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);
  198. 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);
  199. diff --git a/src/test/test-af-list.c b/src/test/test-af-list.c
  200. index aeaa0929b..e2479133d 100644
  201. --- a/src/test/test-af-list.c
  202. +++ b/src/test/test-af-list.c
  203. @@ -24,7 +24,7 @@
  204. #include "string-util.h"
  205. #include "util.h"
  206. -static const struct af_name* lookup_af(register const char *str, register unsigned int len);
  207. +static const struct af_name* lookup_af(register const char *str, register GPERF_LEN_TYPE len);
  208. #include "af-from-name.h"
  209. #include "af-list.h"
  210. diff --git a/src/test/test-arphrd-list.c b/src/test/test-arphrd-list.c
  211. index f3989ad20..8f4f342fa 100644
  212. --- a/src/test/test-arphrd-list.c
  213. +++ b/src/test/test-arphrd-list.c
  214. @@ -24,7 +24,7 @@
  215. #include "string-util.h"
  216. #include "util.h"
  217. -static const struct arphrd_name* lookup_arphrd(register const char *str, register unsigned int len);
  218. +static const struct arphrd_name* lookup_arphrd(register const char *str, register GPERF_LEN_TYPE len);
  219. #include "arphrd-from-name.h"
  220. #include "arphrd-list.h"
  221. diff --git a/src/timesync/timesyncd-conf.h b/src/timesync/timesyncd-conf.h
  222. index cba0724b1..0280697e9 100644
  223. --- a/src/timesync/timesyncd-conf.h
  224. +++ b/src/timesync/timesyncd-conf.h
  225. @@ -22,7 +22,7 @@
  226. #include "conf-parser.h"
  227. #include "timesyncd-manager.h"
  228. -const struct ConfigPerfItem* timesyncd_gperf_lookup(const char *key, unsigned length);
  229. +const struct ConfigPerfItem* timesyncd_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
  230. int manager_parse_server_string(Manager *m, ServerType type, const char *string);
  231. diff --git a/src/udev/net/link-config.h b/src/udev/net/link-config.h
  232. index 91cc0357c..b0d8ceb76 100644
  233. --- a/src/udev/net/link-config.h
  234. +++ b/src/udev/net/link-config.h
  235. @@ -93,7 +93,7 @@ const char *mac_policy_to_string(MACPolicy p) _const_;
  236. MACPolicy mac_policy_from_string(const char *p) _pure_;
  237. /* gperf lookup function */
  238. -const struct ConfigPerfItem* link_config_gperf_lookup(const char *key, unsigned length);
  239. +const struct ConfigPerfItem* link_config_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
  240. 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);
  241. 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);
  242. diff --git a/src/udev/udev-builtin-keyboard.c b/src/udev/udev-builtin-keyboard.c
  243. index aa10beafb..09024116f 100644
  244. --- a/src/udev/udev-builtin-keyboard.c
  245. +++ b/src/udev/udev-builtin-keyboard.c
  246. @@ -29,7 +29,7 @@
  247. #include "string-util.h"
  248. #include "udev.h"
  249. -static const struct key *keyboard_lookup_key(const char *str, unsigned len);
  250. +static const struct key *keyboard_lookup_key(const char *str, GPERF_LEN_TYPE len);
  251. #include "keyboard-keys-from-name.h"
  252. static int install_force_release(struct udev_device *dev, const unsigned *release, unsigned release_count) {
  253. --
  254. 2.11.0