daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
Pablo Greco 48fc63
From 4365589534812dc2dc4d015f3459c82a440ec44f Mon Sep 17 00:00:00 2001
Pablo Greco 48fc63
From: Mike Gilbert <floppymaster@gmail.com>
Pablo Greco 48fc63
Date: Tue, 10 Jan 2017 02:39:05 -0500
Pablo Greco 48fc63
Subject: [PATCH] build-sys: add check for gperf lookup function signature
Pablo Greco 48fc63
 (#5055)
Pablo Greco 48fc63
Pablo Greco 48fc63
gperf-3.1 generates lookup functions that take a size_t length
Pablo Greco 48fc63
parameter instead of unsigned int. Test for this at configure time.
Pablo Greco 48fc63
Pablo Greco 48fc63
Fixes: https://github.com/systemd/systemd/issues/5039
Pablo Greco 48fc63
(cherry picked from commit c9f7b4d356a453a01aa77a6bb74ca7ef49732c08)
Pablo Greco 48fc63
---
Pablo Greco 48fc63
 configure.ac                     | 22 ++++++++++++++++++++++
Pablo Greco 48fc63
 src/core/load-fragment.h         |  2 +-
Pablo Greco 48fc63
 src/journal/journald-server.h    |  2 +-
Pablo Greco 48fc63
 src/login/logind.h               |  2 +-
Pablo Greco 48fc63
 src/network/networkd-netdev.h    |  2 +-
Pablo Greco 48fc63
 src/network/networkd.h           |  2 +-
Pablo Greco 48fc63
 src/resolve/dns-type.c           |  2 +-
Pablo Greco 48fc63
 src/resolve/resolved-conf.h      |  2 +-
Pablo Greco 48fc63
 src/shared/af-list.c             |  2 +-
Pablo Greco 48fc63
 src/shared/arphrd-list.c         |  2 +-
Pablo Greco 48fc63
 src/shared/cap-list.c            |  2 +-
Pablo Greco 48fc63
 src/shared/conf-parser.h         |  2 +-
Pablo Greco 48fc63
 src/shared/errno-list.c          |  2 +-
Pablo Greco 48fc63
 src/timesync/timesyncd-conf.h    |  2 +-
Pablo Greco 48fc63
 src/udev/net/link-config.h       |  2 +-
Pablo Greco 48fc63
 src/udev/udev-builtin-keyboard.c |  2 +-
Pablo Greco 48fc63
 16 files changed, 37 insertions(+), 15 deletions(-)
Pablo Greco 48fc63
Pablo Greco 48fc63
diff --git a/configure.ac b/configure.ac
Pablo Greco 48fc63
index 19d42602c9..f885853f49 100644
Pablo Greco 48fc63
--- a/configure.ac
Pablo Greco 48fc63
+++ b/configure.ac
Pablo Greco 48fc63
@@ -237,6 +237,28 @@ AC_CHECK_SIZEOF(rlim_t,,[
Pablo Greco 48fc63
        #include <sys/resource.h>
Pablo Greco 48fc63
 ])
Pablo Greco 48fc63
 
Pablo Greco 48fc63
+GPERF_TEST="$(echo foo,bar | ${GPERF} -L ANSI-C)"
Pablo Greco 48fc63
+
Pablo Greco 48fc63
+AC_COMPILE_IFELSE(
Pablo Greco 48fc63
+        [AC_LANG_PROGRAM([
Pablo Greco 48fc63
+                #include <string.h>
Pablo Greco 48fc63
+                const char * in_word_set(const char *, size_t);
Pablo Greco 48fc63
+                $GPERF_TEST]
Pablo Greco 48fc63
+        )],
Pablo Greco 48fc63
+        [GPERF_LEN_TYPE=size_t],
Pablo Greco 48fc63
+        [AC_COMPILE_IFELSE(
Pablo Greco 48fc63
+                [AC_LANG_PROGRAM([
Pablo Greco 48fc63
+                        #include <string.h>
Pablo Greco 48fc63
+                        const char * in_word_set(const char *, unsigned);
Pablo Greco 48fc63
+                        $GPERF_TEST]
Pablo Greco 48fc63
+                )],
Pablo Greco 48fc63
+                [GPERF_LEN_TYPE=unsigned],
Pablo Greco 48fc63
+                [AC_MSG_ERROR([** unable to determine gperf len type])]
Pablo Greco 48fc63
+        )]
Pablo Greco 48fc63
+)
Pablo Greco 48fc63
+
Pablo Greco 48fc63
+AC_DEFINE_UNQUOTED([GPERF_LEN_TYPE], [$GPERF_LEN_TYPE], [gperf len type])
Pablo Greco 48fc63
+
Pablo Greco 48fc63
 # ------------------------------------------------------------------------------
Pablo Greco 48fc63
 # we use python to build the man page index, and for systemd-python
Pablo Greco 48fc63
 have_python=no
Pablo Greco 48fc63
diff --git a/src/core/load-fragment.h b/src/core/load-fragment.h
Pablo Greco 48fc63
index 8d334f2c86..4bd286c11b 100644
Pablo Greco 48fc63
--- a/src/core/load-fragment.h
Pablo Greco 48fc63
+++ b/src/core/load-fragment.h
Pablo Greco 48fc63
@@ -112,7 +112,7 @@ int config_parse_protect_system(const char* unit, const char *filename, unsigned
Pablo Greco 48fc63
 int config_parse_bus_name(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);
Pablo Greco 48fc63
 
Pablo Greco 48fc63
 /* gperf prototypes */
Pablo Greco 48fc63
-const struct ConfigPerfItem* load_fragment_gperf_lookup(const char *key, unsigned length);
Pablo Greco 48fc63
+const struct ConfigPerfItem* load_fragment_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
Pablo Greco 48fc63
 extern const char load_fragment_gperf_nulstr[];
Pablo Greco 48fc63
 
Pablo Greco 48fc63
 typedef enum Disabled {
Pablo Greco 48fc63
diff --git a/src/journal/journald-server.h b/src/journal/journald-server.h
Pablo Greco 48fc63
index f046fde834..e74c65dbec 100644
Pablo Greco 48fc63
--- a/src/journal/journald-server.h
Pablo Greco 48fc63
+++ b/src/journal/journald-server.h
Pablo Greco 48fc63
@@ -164,7 +164,7 @@ void server_dispatch_message(Server *s, struct iovec *iovec, unsigned n, unsigne
Pablo Greco 48fc63
 void server_driver_message(Server *s, sd_id128_t message_id, const char *format, ...) _printf_(3,4);
Pablo Greco 48fc63
 
Pablo Greco 48fc63
 /* gperf lookup function */
Pablo Greco 48fc63
-const struct ConfigPerfItem* journald_gperf_lookup(const char *key, unsigned length);
Pablo Greco 48fc63
+const struct ConfigPerfItem* journald_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
Pablo Greco 48fc63
 
Pablo Greco 48fc63
 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);
Pablo Greco 48fc63
 int config_parse_line_max(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);
Pablo Greco 48fc63
diff --git a/src/login/logind.h b/src/login/logind.h
Pablo Greco 48fc63
index 8503eb24dd..29fb1b3082 100644
Pablo Greco 48fc63
--- a/src/login/logind.h
Pablo Greco 48fc63
+++ b/src/login/logind.h
Pablo Greco 48fc63
@@ -187,7 +187,7 @@ int manager_unit_is_active(Manager *manager, const char *unit);
Pablo Greco 48fc63
 int manager_job_is_active(Manager *manager, const char *path);
Pablo Greco 48fc63
 
Pablo Greco 48fc63
 /* gperf lookup function */
Pablo Greco 48fc63
-const struct ConfigPerfItem* logind_gperf_lookup(const char *key, unsigned length);
Pablo Greco 48fc63
+const struct ConfigPerfItem* logind_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
Pablo Greco 48fc63
 
Pablo Greco 48fc63
 int manager_watch_busname(Manager *manager, const char *name);
Pablo Greco 48fc63
 void manager_drop_busname(Manager *manager, const char *name);
Pablo Greco 48fc63
diff --git a/src/network/networkd-netdev.h b/src/network/networkd-netdev.h
Pablo Greco 48fc63
index 3756b1e5a7..fb44f38e64 100644
Pablo Greco 48fc63
--- a/src/network/networkd-netdev.h
Pablo Greco 48fc63
+++ b/src/network/networkd-netdev.h
Pablo Greco 48fc63
@@ -199,7 +199,7 @@ NetDevKind netdev_kind_from_string(const char *d) _pure_;
Pablo Greco 48fc63
 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);
Pablo Greco 48fc63
 
Pablo Greco 48fc63
 /* gperf */
Pablo Greco 48fc63
-const struct ConfigPerfItem* network_netdev_gperf_lookup(const char *key, unsigned length);
Pablo Greco 48fc63
+const struct ConfigPerfItem* network_netdev_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
Pablo Greco 48fc63
 
Pablo Greco 48fc63
 /* Macros which append INTERFACE= to the message */
Pablo Greco 48fc63
 
Pablo Greco 48fc63
diff --git a/src/network/networkd.h b/src/network/networkd.h
Pablo Greco 48fc63
index bdb2f20e2f..8902bbce6b 100644
Pablo Greco 48fc63
--- a/src/network/networkd.h
Pablo Greco 48fc63
+++ b/src/network/networkd.h
Pablo Greco 48fc63
@@ -328,7 +328,7 @@ int network_node_enumerator(sd_bus *bus, const char *path, void *userdata, char
Pablo Greco 48fc63
 int network_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error);
Pablo Greco 48fc63
 
Pablo Greco 48fc63
 /* gperf */
Pablo Greco 48fc63
-const struct ConfigPerfItem* network_network_gperf_lookup(const char *key, unsigned length);
Pablo Greco 48fc63
+const struct ConfigPerfItem* network_network_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
Pablo Greco 48fc63
 
Pablo Greco 48fc63
 /* Route */
Pablo Greco 48fc63
 int route_new_static(Network *network, unsigned section, Route **ret);
Pablo Greco 48fc63
diff --git a/src/resolve/dns-type.c b/src/resolve/dns-type.c
Pablo Greco 48fc63
index a3e740896f..e409df974a 100644
Pablo Greco 48fc63
--- a/src/resolve/dns-type.c
Pablo Greco 48fc63
+++ b/src/resolve/dns-type.c
Pablo Greco 48fc63
@@ -27,7 +27,7 @@ typedef const struct {
Pablo Greco 48fc63
 } dns_type;
Pablo Greco 48fc63
 
Pablo Greco 48fc63
 static const struct dns_type_name *
Pablo Greco 48fc63
-lookup_dns_type (register const char *str, register unsigned int len);
Pablo Greco 48fc63
+lookup_dns_type (register const char *str, register GPERF_LEN_TYPE len);
Pablo Greco 48fc63
 
Pablo Greco 48fc63
 #include "dns_type-from-name.h"
Pablo Greco 48fc63
 #include "dns_type-to-name.h"
Pablo Greco 48fc63
diff --git a/src/resolve/resolved-conf.h b/src/resolve/resolved-conf.h
Pablo Greco 48fc63
index b3dbea7b6b..17b0960594 100644
Pablo Greco 48fc63
--- a/src/resolve/resolved-conf.h
Pablo Greco 48fc63
+++ b/src/resolve/resolved-conf.h
Pablo Greco 48fc63
@@ -26,7 +26,7 @@
Pablo Greco 48fc63
 int manager_parse_dns_server(Manager *m, DnsServerType type, const char *string);
Pablo Greco 48fc63
 int manager_parse_config_file(Manager *m);
Pablo Greco 48fc63
 
Pablo Greco 48fc63
-const struct ConfigPerfItem* resolved_gperf_lookup(const char *key, unsigned length);
Pablo Greco 48fc63
+const struct ConfigPerfItem* resolved_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
Pablo Greco 48fc63
 
Pablo Greco 48fc63
 int config_parse_dnsv(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);
Pablo Greco 48fc63
 int config_parse_support(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);
Pablo Greco 48fc63
diff --git a/src/shared/af-list.c b/src/shared/af-list.c
Pablo Greco 48fc63
index f396115a34..cbdec82240 100644
Pablo Greco 48fc63
--- a/src/shared/af-list.c
Pablo Greco 48fc63
+++ b/src/shared/af-list.c
Pablo Greco 48fc63
@@ -25,7 +25,7 @@
Pablo Greco 48fc63
 #include "util.h"
Pablo Greco 48fc63
 #include "af-list.h"
Pablo Greco 48fc63
 
Pablo Greco 48fc63
-static const struct af_name* lookup_af(register const char *str, register unsigned int len);
Pablo Greco 48fc63
+static const struct af_name* lookup_af(register const char *str, register GPERF_LEN_TYPE len);
Pablo Greco 48fc63
 
Pablo Greco 48fc63
 #include "af-to-name.h"
Pablo Greco 48fc63
 #include "af-from-name.h"
Pablo Greco 48fc63
diff --git a/src/shared/arphrd-list.c b/src/shared/arphrd-list.c
Pablo Greco 48fc63
index 6e113eff7a..588956c56f 100644
Pablo Greco 48fc63
--- a/src/shared/arphrd-list.c
Pablo Greco 48fc63
+++ b/src/shared/arphrd-list.c
Pablo Greco 48fc63
@@ -26,7 +26,7 @@
Pablo Greco 48fc63
 #include "util.h"
Pablo Greco 48fc63
 #include "arphrd-list.h"
Pablo Greco 48fc63
 
Pablo Greco 48fc63
-static const struct arphrd_name* lookup_arphrd(register const char *str, register unsigned int len);
Pablo Greco 48fc63
+static const struct arphrd_name* lookup_arphrd(register const char *str, register GPERF_LEN_TYPE len);
Pablo Greco 48fc63
 
Pablo Greco 48fc63
 #include "arphrd-to-name.h"
Pablo Greco 48fc63
 #include "arphrd-from-name.h"
Pablo Greco 48fc63
diff --git a/src/shared/cap-list.c b/src/shared/cap-list.c
Pablo Greco 48fc63
index 8033e8c7b2..aa23f5e13c 100644
Pablo Greco 48fc63
--- a/src/shared/cap-list.c
Pablo Greco 48fc63
+++ b/src/shared/cap-list.c
Pablo Greco 48fc63
@@ -26,7 +26,7 @@
Pablo Greco 48fc63
 #include "cap-list.h"
Pablo Greco 48fc63
 #include "missing.h"
Pablo Greco 48fc63
 
Pablo Greco 48fc63
-static const struct capability_name* lookup_capability(register const char *str, register unsigned int len);
Pablo Greco 48fc63
+static const struct capability_name* lookup_capability(register const char *str, register GPERF_LEN_TYPE len);
Pablo Greco 48fc63
 
Pablo Greco 48fc63
 #include "cap-to-name.h"
Pablo Greco 48fc63
 #include "cap-from-name.h"
Pablo Greco 48fc63
diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h
Pablo Greco 48fc63
index 7a2f855f9f..895f6f6a38 100644
Pablo Greco 48fc63
--- a/src/shared/conf-parser.h
Pablo Greco 48fc63
+++ b/src/shared/conf-parser.h
Pablo Greco 48fc63
@@ -61,7 +61,7 @@ typedef struct ConfigPerfItem {
Pablo Greco 48fc63
 } ConfigPerfItem;
Pablo Greco 48fc63
 
Pablo Greco 48fc63
 /* Prototype for a low-level gperf lookup function */
Pablo Greco 48fc63
-typedef const ConfigPerfItem* (*ConfigPerfItemLookup)(const char *section_and_lvalue, unsigned length);
Pablo Greco 48fc63
+typedef const ConfigPerfItem* (*ConfigPerfItemLookup)(const char *section_and_lvalue, GPERF_LEN_TYPE length);
Pablo Greco 48fc63
 
Pablo Greco 48fc63
 /* Prototype for a generic high-level lookup function */
Pablo Greco 48fc63
 typedef int (*ConfigItemLookup)(
Pablo Greco 48fc63
diff --git a/src/shared/errno-list.c b/src/shared/errno-list.c
Pablo Greco 48fc63
index c63296f292..99b0c689bf 100644
Pablo Greco 48fc63
--- a/src/shared/errno-list.c
Pablo Greco 48fc63
+++ b/src/shared/errno-list.c
Pablo Greco 48fc63
@@ -26,7 +26,7 @@
Pablo Greco 48fc63
 #include "errno-list.h"
Pablo Greco 48fc63
 
Pablo Greco 48fc63
 static const struct errno_name* lookup_errno(register const char *str,
Pablo Greco 48fc63
-                                                 register unsigned int len);
Pablo Greco 48fc63
+                                             register GPERF_LEN_TYPE len);
Pablo Greco 48fc63
 
Pablo Greco 48fc63
 #include "errno-to-name.h"
Pablo Greco 48fc63
 #include "errno-from-name.h"
Pablo Greco 48fc63
diff --git a/src/timesync/timesyncd-conf.h b/src/timesync/timesyncd-conf.h
Pablo Greco 48fc63
index 56466fe462..a776475ea9 100644
Pablo Greco 48fc63
--- a/src/timesync/timesyncd-conf.h
Pablo Greco 48fc63
+++ b/src/timesync/timesyncd-conf.h
Pablo Greco 48fc63
@@ -25,7 +25,7 @@
Pablo Greco 48fc63
 
Pablo Greco 48fc63
 #include "timesyncd-manager.h"
Pablo Greco 48fc63
 
Pablo Greco 48fc63
-const struct ConfigPerfItem* timesyncd_gperf_lookup(const char *key, unsigned length);
Pablo Greco 48fc63
+const struct ConfigPerfItem* timesyncd_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
Pablo Greco 48fc63
 
Pablo Greco 48fc63
 int manager_parse_server_string(Manager *m, ServerType type, const char *string);
Pablo Greco 48fc63
 
Pablo Greco 48fc63
diff --git a/src/udev/net/link-config.h b/src/udev/net/link-config.h
Pablo Greco 48fc63
index f2e9174887..af01989919 100644
Pablo Greco 48fc63
--- a/src/udev/net/link-config.h
Pablo Greco 48fc63
+++ b/src/udev/net/link-config.h
Pablo Greco 48fc63
@@ -93,7 +93,7 @@ const char *mac_policy_to_string(MACPolicy p) _const_;
Pablo Greco 48fc63
 MACPolicy mac_policy_from_string(const char *p) _pure_;
Pablo Greco 48fc63
 
Pablo Greco 48fc63
 /* gperf lookup function */
Pablo Greco 48fc63
-const struct ConfigPerfItem* link_config_gperf_lookup(const char *key, unsigned length);
Pablo Greco 48fc63
+const struct ConfigPerfItem* link_config_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
Pablo Greco 48fc63
 
Pablo Greco 48fc63
 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);
Pablo Greco 48fc63
 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);
Pablo Greco 48fc63
diff --git a/src/udev/udev-builtin-keyboard.c b/src/udev/udev-builtin-keyboard.c
Pablo Greco 48fc63
index eaa21abf60..7d30482b13 100644
Pablo Greco 48fc63
--- a/src/udev/udev-builtin-keyboard.c
Pablo Greco 48fc63
+++ b/src/udev/udev-builtin-keyboard.c
Pablo Greco 48fc63
@@ -28,7 +28,7 @@
Pablo Greco 48fc63
 
Pablo Greco 48fc63
 #include "udev.h"
Pablo Greco 48fc63
 
Pablo Greco 48fc63
-static const struct key *keyboard_lookup_key(const char *str, unsigned len);
Pablo Greco 48fc63
+static const struct key *keyboard_lookup_key(const char *str, GPERF_LEN_TYPE len);
Pablo Greco 48fc63
 #include "keyboard-keys-from-name.h"
Pablo Greco 48fc63
 #include "keyboard-keys-to-name.h"
Pablo Greco 48fc63