aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergei Trofimovich <slyfox@gentoo.org>2017-08-01 09:33:35 +0100
committerAndrew G. Morgan <morgan@kernel.org>2018-09-09 13:19:55 -0700
commit892b7c2f6e6d7b6b52a9ccd54c4b1a6d2d1b3209 (patch)
tree09ebfd769ae878aa2956ccbb215537014aeb8bec
parent190d5a8d70d7088a630390e1f570788240d71ebe (diff)
downloadlibcap-892b7c2f6e6d7b6b52a9ccd54c4b1a6d2d1b3209.tar.gz
cap_text.c: fix 'asprintf' inplicit declaration
Detected by gcc: cap_text.c: In function 'cap_to_name': cap_text.c:291:2: warning: implicit declaration of function 'asprintf'; did you mean 'vsprintf'? [-Wimplicit-function-declaration] asprintf(&tmp, "%u", cap); ^~~~~~~~ vsprintf In order to get 'asprintf' declaration '_GNU_SOURCE' needs to be defined before '<stdio.h>' in included. 'cap_text.c' injects '<stdio.h>' include as '-include _caps_output.gperf' (via '<string.h>') before '_GNU_SOURCE' is defined in source file. The change moves '_caps_output.gperf' inclusion after '_GNU_SOURCE' declaration. Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
-rw-r--r--libcap/Makefile2
-rw-r--r--libcap/cap_text.c5
2 files changed, 6 insertions, 1 deletions
diff --git a/libcap/Makefile b/libcap/Makefile
index d189777..a85beba 100644
--- a/libcap/Makefile
+++ b/libcap/Makefile
@@ -22,7 +22,7 @@ all: $(MINLIBNAME) $(STALIBNAME) libcap.pc
ifeq ($(BUILD_GPERF),yes)
USE_GPERF_OUTPUT = $(GPERF_OUTPUT)
-INCLUDE_GPERF_OUTPUT = -include $(GPERF_OUTPUT)
+INCLUDE_GPERF_OUTPUT = -DINCLUDE_GPERF_OUTPUT='"$(GPERF_OUTPUT)"'
endif
libcap.pc: libcap.pc.in
diff --git a/libcap/cap_text.c b/libcap/cap_text.c
index 42fb685..29fc73f 100644
--- a/libcap/cap_text.c
+++ b/libcap/cap_text.c
@@ -15,6 +15,11 @@
#include <ctype.h>
#include <limits.h>
+#ifdef INCLUDE_GPERF_OUTPUT
+/* we need to include it after #define _GNU_SOURCE is set */
+#include INCLUDE_GPERF_OUTPUT
+#endif
+
/* Maximum output text length (16 per cap) */
#define CAP_TEXT_SIZE (16*__CAP_MAXBITS)