This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: _ssl.c: Missing "do" for do {} while(0) idiom
Type: compile error Stage: resolved
Components: Extension Modules Versions: Python 3.6, Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Brian.Cain, martin.panter, python-dev
Priority: normal Keywords: patch

Created on 2015-07-17 22:32 by Brian.Cain, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
ssl_convert.patch Brian.Cain, 2015-07-17 22:32 review
ssl_convert_2nd.patch Brian.Cain, 2015-07-18 01:47 with recommended changes review
ssl_convert_3rd.patch Brian.Cain, 2015-07-18 01:49 review
Messages (5)
msg246868 - (view) Author: Brian Cain (Brian.Cain) * Date: 2015-07-17 22:32
_ssl.c has a "convert()" macro which misuses the "do { ... } while(0)" pattern by accidentally omitting the "do".

This was discovered when building with clang, it reports "while loop has empty body".  Effectively, convert puts the body into gratuitous scope braces and happens to be followed by a "while(0);".  If convert() were used in some context where it weren't followed by a semicolon, it might do something terribly interesting.  Or, more likely, just fail to build.
msg246871 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-07-18 00:06
The patch is certainly an improvement and could be committed. It looks like the same fault is in the 3.4 and 2.7 code.

However, since the usage of this macro is limited to the four lines immediately following its definition, it might be clearer to just drop the do-while hackery in this case. (And make it CONVERT uppercase to signify that it is a macro.)
msg246875 - (view) Author: Brian Cain (Brian.Cain) * Date: 2015-07-18 01:47
New patch.
msg246876 - (view) Author: Brian Cain (Brian.Cain) * Date: 2015-07-18 01:49
Whoops, that's not right.  Corrected.
msg246911 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-07-18 18:01
New changeset 24cf6b4d72c2 by Benjamin Peterson in branch '3.4':
improve style of the convert macro (#24655)
https://hg.python.org/cpython/rev/24cf6b4d72c2

New changeset bffa3b5fd2d8 by Benjamin Peterson in branch '3.5':
merge 3.4 (#24655)
https://hg.python.org/cpython/rev/bffa3b5fd2d8

New changeset 35d6606b2480 by Benjamin Peterson in branch 'default':
merge 3.5 (#24655)
https://hg.python.org/cpython/rev/35d6606b2480

New changeset e4f9562d625d by Benjamin Peterson in branch '2.7':
improve style of the convert macro (#24655)
https://hg.python.org/cpython/rev/e4f9562d625d
History
Date User Action Args
2022-04-11 14:58:18adminsetgithub: 68843
2015-07-18 21:52:55berker.peksagsetstage: commit review -> resolved
2015-07-18 18:22:14benjamin.petersonsetstatus: open -> closed
resolution: fixed
2015-07-18 18:01:24python-devsetnosy: + python-dev
messages: + msg246911
2015-07-18 01:49:11Brian.Cainsetfiles: + ssl_convert_3rd.patch

messages: + msg246876
2015-07-18 01:47:15Brian.Cainsetfiles: + ssl_convert_2nd.patch

messages: + msg246875
2015-07-18 00:06:47martin.pantersetversions: + Python 2.7, Python 3.4, Python 3.5
nosy: + martin.panter

messages: + msg246871

type: compile error
stage: commit review
2015-07-17 22:32:24Brian.Caincreate