summaryrefslogtreecommitdiffstats
path: root/Modules/socketmodule.c
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2014-01-07 22:01:01 (GMT)
committerBrett Cannon <brett@python.org>2014-01-07 22:01:01 (GMT)
commitb05cbe61b3751bf829198bd8b75aa8c7b3d2ee56 (patch)
tree7f0dda030dccbea81b5f9c7d3ce4984f6e2a6af5 /Modules/socketmodule.c
parent8d942296bb6cc45e519447484084bee1507d664b (diff)
downloadcpython-b05cbe61b3751bf829198bd8b75aa8c7b3d2ee56.zip
cpython-b05cbe61b3751bf829198bd8b75aa8c7b3d2ee56.tar.gz
cpython-b05cbe61b3751bf829198bd8b75aa8c7b3d2ee56.tar.bz2
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.
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r--Modules/socketmodule.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 0aba591..6c229bc 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -1885,8 +1885,22 @@ cmsg_min_space(struct msghdr *msg, struct cmsghdr *cmsgh, size_t space)
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;