X Tutup
Skip to content

Commit c9f7b4d

Browse files
floppymmartinpitt
authored andcommitted
build-sys: add check for gperf lookup function signature (systemd#5055)
gperf-3.1 generates lookup functions that take a size_t length parameter instead of unsigned int. Test for this at configure time. Fixes: systemd#5039
1 parent 64083a6 commit c9f7b4d

File tree

19 files changed

+40
-18
lines changed

19 files changed

+40
-18
lines changed

configure.ac

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,28 @@ AC_CHECK_SIZEOF(rlim_t,,[
255255
#include <sys/resource.h>
256256
])
257257

258+
GPERF_TEST="$(echo foo,bar | ${GPERF} -L ANSI-C)"
259+
260+
AC_COMPILE_IFELSE(
261+
[AC_LANG_PROGRAM([
262+
#include <string.h>
263+
const char * in_word_set(const char *, size_t);
264+
$GPERF_TEST]
265+
)],
266+
[GPERF_LEN_TYPE=size_t],
267+
[AC_COMPILE_IFELSE(
268+
[AC_LANG_PROGRAM([
269+
#include <string.h>
270+
const char * in_word_set(const char *, unsigned);
271+
$GPERF_TEST]
272+
)],
273+
[GPERF_LEN_TYPE=unsigned],
274+
[AC_MSG_ERROR([** unable to determine gperf len type])]
275+
)]
276+
)
277+
278+
AC_DEFINE_UNQUOTED([GPERF_LEN_TYPE], [$GPERF_LEN_TYPE], [gperf len type])
279+
258280
# ------------------------------------------------------------------------------
259281
# we use python to build the man page index
260282
have_python=no

src/basic/af-list.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "af-list.h"
2424
#include "macro.h"
2525

26-
static const struct af_name* lookup_af(register const char *str, register unsigned int len);
26+
static const struct af_name* lookup_af(register const char *str, register GPERF_LEN_TYPE len);
2727

2828
#include "af-from-name.h"
2929
#include "af-to-name.h"

src/basic/arphrd-list.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "arphrd-list.h"
2424
#include "macro.h"
2525

26-
static const struct arphrd_name* lookup_arphrd(register const char *str, register unsigned int len);
26+
static const struct arphrd_name* lookup_arphrd(register const char *str, register GPERF_LEN_TYPE len);
2727

2828
#include "arphrd-from-name.h"
2929
#include "arphrd-to-name.h"

src/basic/cap-list.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "parse-util.h"
2727
#include "util.h"
2828

29-
static const struct capability_name* lookup_capability(register const char *str, register unsigned int len);
29+
static const struct capability_name* lookup_capability(register const char *str, register GPERF_LEN_TYPE len);
3030

3131
#include "cap-from-name.h"
3232
#include "cap-to-name.h"

src/basic/errno-list.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "macro.h"
2424

2525
static const struct errno_name* lookup_errno(register const char *str,
26-
register unsigned int len);
26+
register GPERF_LEN_TYPE len);
2727

2828
#include "errno-from-name.h"
2929
#include "errno-to-name.h"

src/core/load-fragment.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ int config_parse_restrict_namespaces(const char *unit, const char *filename, uns
120120
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);
121121

122122
/* gperf prototypes */
123-
const struct ConfigPerfItem* load_fragment_gperf_lookup(const char *key, unsigned length);
123+
const struct ConfigPerfItem* load_fragment_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
124124
extern const char load_fragment_gperf_nulstr[];
125125

126126
typedef enum Disabled {

src/journal/journald-server.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ void server_dispatch_message(Server *s, struct iovec *iovec, unsigned n, unsigne
179179
void server_driver_message(Server *s, sd_id128_t message_id, const char *format, ...) _printf_(3,0) _sentinel_;
180180

181181
/* gperf lookup function */
182-
const struct ConfigPerfItem* journald_gperf_lookup(const char *key, unsigned length);
182+
const struct ConfigPerfItem* journald_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
183183

184184
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);
185185

src/login/logind.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ int manager_unit_is_active(Manager *manager, const char *unit);
182182
int manager_job_is_active(Manager *manager, const char *path);
183183

184184
/* gperf lookup function */
185-
const struct ConfigPerfItem* logind_gperf_lookup(const char *key, unsigned length);
185+
const struct ConfigPerfItem* logind_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
186186

187187
int manager_set_lid_switch_ignore(Manager *m, usec_t until);
188188

src/network/netdev/netdev.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ NetDevKind netdev_kind_from_string(const char *d) _pure_;
175175
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);
176176

177177
/* gperf */
178-
const struct ConfigPerfItem* network_netdev_gperf_lookup(const char *key, unsigned length);
178+
const struct ConfigPerfItem* network_netdev_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
179179

180180
/* Macros which append INTERFACE= to the message */
181181

src/network/networkd-conf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ typedef struct Manager Manager;
2323

2424
int manager_parse_config_file(Manager *m);
2525

26-
const struct ConfigPerfItem* networkd_gperf_lookup(const char *key, unsigned length);
26+
const struct ConfigPerfItem* networkd_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
2727

2828
int config_parse_duid_type(
2929
const char *unit,

0 commit comments

Comments
 (0)
X Tutup