Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b05cbe6

Browse files
committed
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.
1 parent 8d94229 commit b05cbe6

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

Misc/NEWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ Tools/Demos
4343
- Issue #20142: Py_buffer variables generated by Argument Clinic are now
4444
initialized with a default value.
4545

46+
Build
47+
-----
48+
49+
- Issue #12837: Silence a tautological comparison warning on OS X under Clang in
50+
socketmodule.c.
51+
4652
What's New in Python 3.4.0 Beta 2?
4753
==================================
4854

Modules/socketmodule.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1885,8 +1885,22 @@ cmsg_min_space(struct msghdr *msg, struct cmsghdr *cmsgh, size_t space)
18851885
sizeof(cmsgh->cmsg_len));
18861886

18871887
/* Note that POSIX allows msg_controllen to be of signed type. */
1888-
if (cmsgh == NULL || msg->msg_control == NULL || msg->msg_controllen < 0)
1888+
if (cmsgh == NULL || msg->msg_control == NULL)
18891889
return 0;
1890+
/* Note that POSIX allows msg_controllen to be of a signed type. This is
1891+
annoying under OS X as it's unsigned there and so it triggers a
1892+
tautological comparison warning under Clang when compared against 0.
1893+
Since the check is valid on other platforms, silence the warning under
1894+
Clang. */
1895+
#ifdef __clang__
1896+
#pragma clang diagnostic push
1897+
#pragma clang diagnostic ignored "-Wtautological-compare"
1898+
#endif
1899+
if (msg->msg_controllen < 0)
1900+
return 0;
1901+
#ifdef __clang__
1902+
#pragma clang diagnostic pop
1903+
#endif
18901904
if (space < cmsg_len_end)
18911905
space = cmsg_len_end;
18921906
cmsg_offset = (char *)cmsgh - (char *)msg->msg_control;

0 commit comments

Comments
 (0)