Instead of:
+ if (wb->buf == NULL)
+ if (!ssl3_setup_write_buffer(s))
+ return -1;
Why not: + if (wb->buf == NULL) {
+ if (!ssl3_setup_write_buffer(s)) {
+ return -1;
+ }
+ }31–38 of 38 posts
Instead of:
+ if (wb->buf == NULL)
+ if (!ssl3_setup_write_buffer(s))
+ return -1;
Why not: + if (wb->buf == NULL) {
+ if (!ssl3_setup_write_buffer(s)) {
+ return -1;
+ }
+ }That patch is set up for a later bug to be introduced: no brackets on the if statements. Instead of: + if (wb->buf == NULL) + if (!ssl3_setup_write_buffer(s)) + return -1; Why not: + if (wb->buf == NULL) { + if (!ssl3_setup_write_buffer(s)) { + return -1; + } + }
if ((wb->buf == NULL) && !ssl3_setup_write_buffer(s)) {
return -1;
}That patch is set up for a later bug to be introduced: no brackets on the if statements. Instead of: + if (wb->buf == NULL) + if (!ssl3_setup_write_buffer(s)) + return -1; Why not: + if (wb->buf == NULL) { + if (!ssl3_setup_write_buffer(s)) { + return -1; + } + }
Disagree you may, but it's consistent with their self-imposed guidelines.
That patch is set up for a later bug to be introduced: no brackets on the if statements. Instead of: + if (wb->buf == NULL) + if (!ssl3_setup_write_buffer(s)) + return -1; Why not: + if (wb->buf == NULL) { + if (!ssl3_setup_write_buffer(s)) { + return -1; + } + }
Is it me or should code that has to be secure be written in more manage languages to prevent these mistake ? (But managed languages probably have other security issues I don't know about ?)
That patch is set up for a later bug to be introduced: no brackets on the if statements. Instead of: + if (wb->buf == NULL) + if (!ssl3_setup_write_buffer(s)) + return -1; Why not: + if (wb->buf == NULL) { + if (!ssl3_setup_write_buffer(s)) { + return -1; + } + }
this is getting boring. ever time a patch using no parentheses shows up there is that comment. if all your code uses that style you get used to it. feel free to show evidence of openbsd making that mistake once! (there might have been those, but i am sure it's going to be very hard to find).
If writing defensively by always putting braces around if statements means we no longer have to consider the possibility of a fall through error, then that saves mental processing for you and more importantly for lesser programmers.
Are we better off using decoder rings and snail mail at this point?
That patch is set up for a later bug to be introduced: no brackets on the if statements. Instead of: + if (wb->buf == NULL) + if (!ssl3_setup_write_buffer(s)) + return -1; Why not: + if (wb->buf == NULL) { + if (!ssl3_setup_write_buffer(s)) { + return -1; + } + }
This is OpenBSD Kernel Normal Form ( http://www.openbsd.org/cgi-bin/man.cgi?query=style&sektion=9 ). Disagree you may, but it's consistent with their self-imposed guidelines.
So technically, this is still OK, but they are allowed to use braces when there are multiple lines. (the if and the return) They have an example in that link that covers this as a permitted case, but as you say, it's OK and consistent, but that doesn't make it good :)