daandemeyer / rpms / systemd

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