[PATCH 3/5 v2] os: Silence warnings when building with clang

Jeremy Huddleston jeremyhu at apple.com
Sun Apr 24 19:52:46 PDT 2011


access.c:1492:20: error: equality comparison with extraneous parentheses [-Werror,-Wparentheses]
        if ((host->family == FamilyServerInterpreted)) {
             ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
access.c:1492:20: note: use '=' to turn this equality comparison into an assignment
        if ((host->family == FamilyServerInterpreted)) {
                          ^~
                          =
access.c:1492:20: note: remove extraneous parentheses around the comparison to silence this warning
        if ((host->family == FamilyServerInterpreted)) {
            ~             ^                         ~

In file included from xstrans.c:8:
In file included from /usr/X11/include/X11/Xtrans/transport.c:62:
/usr/X11/include/X11/Xtrans/Xtranssock.c:262:5: error: implicit declaration of function 'ErrorF' is invalid in C99
      [-Werror,-Wimplicit-function-declaration]
    PRMSG (3,"SocketSelectFamily(%s)\n", family, 0, 0);
    ^

log.c:180:29: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
        if (asprintf(&logFileName, fname, display) == -1)
                                   ^~~~~
log.c:190:26: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
                if ((asprintf(&suffix, backup, display) == -1) ||
                                       ^~~~~~

Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
---

The other 4 are unchanged, and I didn't want to spam the list with them since I just sent them yesterday.

 os/access.c  |    2 +-
 os/log.c     |   10 ++++++++++
 os/xstrans.c |    5 +++++
 3 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/os/access.c b/os/access.c
index 3856e60..b7b1927 100644
--- a/os/access.c
+++ b/os/access.c
@@ -1489,7 +1489,7 @@ InvalidHost (
     }
     for (host = validhosts; host; host = host->next)
     {
-	if ((host->family == FamilyServerInterpreted)) {
+	if (host->family == FamilyServerInterpreted) {
 	    if (siAddrMatch (family, addr, len, host, client)) {
 		return 0;
 	    }
diff --git a/os/log.c b/os/log.c
index 65195ba..795d8f0 100644
--- a/os/log.c
+++ b/os/log.c
@@ -171,6 +171,12 @@ asm (".desc ___crashreporter_info__, 0x10");
  * string.
  */
 
+
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
+#endif
+
 const char *
 LogInit(const char *fname, const char *backup)
 {
@@ -226,6 +232,10 @@ LogInit(const char *fname, const char *backup)
     return logFileName;
 }
 
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
 void
 LogClose(void)
 {
diff --git a/os/xstrans.c b/os/xstrans.c
index c086e22..44ff976 100644
--- a/os/xstrans.c
+++ b/os/xstrans.c
@@ -2,6 +2,11 @@
 #include <dix-config.h>
 #endif
 
+#include <X11/Xfuncproto.h>
+
+/* ErrorF is used by xtrans */
+extern _X_EXPORT void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
+
 #define TRANS_REOPEN
 #define TRANS_SERVER
 #define XSERV_t
-- 
1.7.4.1




More information about the xorg-devel mailing list