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

Jeremy Huddleston jeremyhu at apple.com
Sat Apr 23 21:52:36 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 connection.c:77:
/usr/X11/include/X11/Xtrans/Xtransint.h:349:12: error: unused function 'is_numeric' [-Werror,-Wunused-function]
static int is_numeric (
           ^
/usr/X11/include/X11/Xtrans/Xtransint.h:354:12: error: unused function 'trans_mkdir' [-Werror,-Wunused-function]
static int trans_mkdir (
           ^

In file included from xstrans.c:8:
In file included from /usr/X11/include/X11/Xtrans/transport.c:67:
...
fatal error: too many errors emitted, stopping now [-ferror-limit=]

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>
---
 os/access.c     |    2 +-
 os/connection.c |   11 +++++++++++
 os/log.c        |   10 ++++++++++
 os/xstrans.c    |    5 +++++
 4 files changed, 27 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/connection.c b/os/connection.c
index 0c580ab..c0f1d83 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -73,8 +73,19 @@ SOFTWARE.
 #define XSERV_t
 #define TRANS_SERVER
 #define TRANS_REOPEN
+
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunused-function"
+#endif
+
 #include <X11/Xtrans/Xtrans.h>
 #include <X11/Xtrans/Xtransint.h>
+
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
 #include <errno.h>
 #include <signal.h>
 #include <stdio.h>
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..5c3dda2 100644
--- a/os/xstrans.c
+++ b/os/xstrans.c
@@ -2,6 +2,11 @@
 #include <dix-config.h>
 #endif
 
+#ifdef __clang__
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
 #define TRANS_REOPEN
 #define TRANS_SERVER
 #define XSERV_t
-- 
1.7.4.1




More information about the xorg-devel mailing list