From: Sven Eden Date: Thu, 12 Jan 2017 08:28:02 +0000 (+0100) Subject: Fix lookup_errno by adding a gperf length parameter detection. X-Git-Tag: v226.4~1^2~56 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=947a6c107a40f43b64adb3736a495e47caad7414;ds=sidebyside Fix lookup_errno by adding a gperf length parameter detection. build-sys: add check for gperf lookup function signature (#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: https://github.com/systemd/systemd/issues/5039 --- diff --git a/configure.ac b/configure.ac index 8e3f7b3cd..24f4d0dd6 100644 --- a/configure.ac +++ b/configure.ac @@ -232,7 +232,29 @@ AC_CHECK_SIZEOF(rlim_t,,[ #include ]) - # ------------------------------------------------------------------------------ +GPERF_TEST="$(echo foo,bar | ${GPERF} -L ANSI-C)" + +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([ + #include + const char * in_word_set(const char *, size_t); + $GPERF_TEST] + )], + [GPERF_LEN_TYPE=size_t], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([ + #include + const char * in_word_set(const char *, unsigned); + $GPERF_TEST] + )], + [GPERF_LEN_TYPE=unsigned], + [AC_MSG_ERROR([** unable to determine gperf len type])] + )] +) + +AC_DEFINE_UNQUOTED([GPERF_LEN_TYPE], [$GPERF_LEN_TYPE], [gperf len type]) + +# ------------------------------------------------------------------------------ # we use python to build the man page index have_python=no AC_ARG_WITH([python], diff --git a/src/basic/errno-list.c b/src/basic/errno-list.c index fff37eb3e..f7f33bb44 100644 --- a/src/basic/errno-list.c +++ b/src/basic/errno-list.c @@ -21,11 +21,13 @@ #include +#include "config.h" #include "util.h" #include "errno-list.h" static const struct errno_name* lookup_errno(register const char *str, - register unsigned int len); + register GPERF_LEN_TYPE len); + #include "errno-to-name.h" #include "errno-from-name.h" diff --git a/src/login/logind.h b/src/login/logind.h index ff9607413..306709e5b 100644 --- a/src/login/logind.h +++ b/src/login/logind.h @@ -24,6 +24,7 @@ #include #include +#include "config.h" #include "sd-event.h" #include "sd-bus.h" #include "list.h" @@ -179,7 +180,7 @@ int manager_unit_is_active(Manager *manager, const char *unit); int manager_job_is_active(Manager *manager, const char *path); /* gperf lookup function */ -const struct ConfigPerfItem* logind_gperf_lookup (const char *str, size_t len); +const struct ConfigPerfItem* logind_gperf_lookup(const char *key, GPERF_LEN_TYPE length); int manager_set_lid_switch_ignore(Manager *m, usec_t until);