[Python-checkins] cpython: Issue #12837: Silence a Clang compiler warning on OS X.

brett.cannon python-checkins at python.org
Tue Jan 7 23:01:12 CET 2014


http://hg.python.org/cpython/rev/407c9c297ff7
changeset:   88346:407c9c297ff7
user:        Brett Cannon <brett at python.org>
date:        Tue Jan 07 17:01:01 2014 -0500
summary:
  Issue #12837: Silence a Clang compiler warning on OS X.

Now makes CPython build without warnings on OS X under Clang with
-Wno-unused-value -Wno-empty-body -Qunused-arguments
-Wno-deprecated-declarations.

Thanks to David Watson for taking an initial stab at a solution.

files:
  Misc/NEWS              |   6 ++++++
  Modules/socketmodule.c |  16 +++++++++++++++-
  2 files changed, 21 insertions(+), 1 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -43,6 +43,12 @@
 - Issue #20142: Py_buffer variables generated by Argument Clinic are now
   initialized with a default value.
 
+Build
+-----
+
+- Issue #12837: Silence a tautological comparison warning on OS X under Clang in
+  socketmodule.c.
+
 What's New in Python 3.4.0 Beta 2?
 ==================================
 
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -1885,8 +1885,22 @@
                                         sizeof(cmsgh->cmsg_len));
 
     /* Note that POSIX allows msg_controllen to be of signed type. */
-    if (cmsgh == NULL || msg->msg_control == NULL || msg->msg_controllen < 0)
+    if (cmsgh == NULL || msg->msg_control == NULL)
         return 0;
+    /* Note that POSIX allows msg_controllen to be of a signed type. This is
+       annoying under OS X as it's unsigned there and so it triggers a
+       tautological comparison warning under Clang when compared against 0.
+       Since the check is valid on other platforms, silence the warning under
+       Clang. */
+    #ifdef __clang__
+    #pragma clang diagnostic push
+    #pragma clang diagnostic ignored "-Wtautological-compare"
+    #endif
+    if (msg->msg_controllen < 0)
+        return 0;
+    #ifdef __clang__
+    #pragma clang diagnostic pop
+    #endif
     if (space < cmsg_len_end)
         space = cmsg_len_end;
     cmsg_offset = (char *)cmsgh - (char *)msg->msg_control;

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list