Thread (6 messages) 6 messages, 3 authors, 2016-06-15

[PATCH] http: Include locale.h when using setlocale()

flat view
DORMANTno replies

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 23:04:00
Subsystem: the rest · Maintainer: Linus Torvalds

Since v2.3.0-rc1-37-gf18604b we've been using setlocale() here without
importing locale.h. Oddly enough this only causes issues for me under
-O0 on GCC & Clang. I.e. if I do:

    $ git clean -dxf; make -j 1 V=1 CFLAGS="-g -O0 -Wall" http.o

I'll get this on clang 3.5.0-6 & GCC 4.9.1-19 on Debian:

    http.c: In function ‘get_preferred_languages’:
    http.c:1021:2: warning: implicit declaration of function ‘setlocale’ [-Wimplicit-function-declaration]
      retval = setlocale(LC_MESSAGES, NULL);
      ^
    http.c:1021:21: error: ‘LC_MESSAGES’ undeclared (first use in this function)
      retval = setlocale(LC_MESSAGES, NULL);

But changing -O0 to -O1 or another optimization level makes the issue go
away. Odd, but in any case we should be including this header if we're
going to use the function, so just do that.

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
 http.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/http.c b/http.c
index 0153fb0..0606e6c 100644
--- a/http.c
+++ b/http.c
@@ -8,6 +8,9 @@
 #include "credential.h"
 #include "version.h"
 #include "pkt-line.h"
+#ifndef NO_GETTEXT
+#	include <locale.h>
+#endif
 
 int active_requests;
 int http_is_verbose;
-- 
2.1.3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help