jerryscript-project / iotjs

Platform for Internet of Things with JavaScript http://www.iotjs.net
Other
2.6k stars 438 forks source link

Removed an unnecessary 'do { } while(0);' from HTTP parser module. #1839

Closed LaszloLango closed 5 years ago

LaszloLango commented 5 years ago

Usually 'do { } while(0)' without a semicolon is used in a macro when we want to force the semicolon for the certain macro. The compiler does fails if the developer forgot the semicolon after the macro call. Using this technique with a semicolon after the 'while' has no sense ('...while(0);').

IoT.js-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com

LaszloLango commented 5 years ago

@daeyeon, unfortunately we cannot just drop the semicolon here. The implementation of HTTP_METHOD_MAP makes it impossible, but it is in the http-parser sub-module. Furthermore it cannot be modified, because would lead into other errors (eg.: semicolon between elements of enum, which is a syntax error). We have some different options: 1) Leave as is and close the PR 2) Do not use the HTTP_METHOD_MAP, but define a new one in http-parser with a proper semicolon usage. This wouldn't be too good, because it leads to code duplications and makes worse the readability of the code. 3) Use empty block ({ }) instead of do { } while(0); 4) Remove the do { } while(0); (as this PR does).

Which one do you prefer?