if ((err = SSLHashSHA1.update(&hashCtx, &serverRandom)) != 0)
goto fail;
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
goto fail;
goto fail;
if ((err = SSLHashSHA1.final(&hashCtx, &hashOut)) != 0)
goto fail;(code snippet from http://opensource.apple.com/source/Security/Security-55471/libsecurity_ssl/lib/sslKeyExchange.c)
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
On Feb 22, 2014 10:41 AM, "Nico Weber" <tha...@chromium.org> wrote:
>
> I like to think that it's unlikely that this exact bug would happen in Chromium (strict code review policy, strict testing policy, clang-format, etc). I think the lessons to take away here aren't "let's parse C in our presubmit!" or "let's require braces on all ifs", but rather:
>
> * When reviewing code, review every line, don't just glance over the review and think "looks roughly correct, lgtm"
> * Make sure your feature has good automated tests. A good quick check you can do is introduce a small bug somewhere in your code and verify that your tests catch that.
> * For subtle behavior that's hard to test automatically (hint: this is rare), work with QA to get your feature added to their manual test plan.
All of the above are great points. They are not mutually exclusive with braces after if statement though. Is there any short coming with requiring braces?
Nam
On Feb 22, 2014 10:41 AM, "Nico Weber" <tha...@chromium.org> wrote:
>
> I like to think that it's unlikely that this exact bug would happen in Chromium (strict code review policy, strict testing policy, clang-format, etc). I think the lessons to take away here aren't "let's parse C in our presubmit!" or "let's require braces on all ifs", but rather:
>
> * When reviewing code, review every line, don't just glance over the review and think "looks roughly correct, lgtm"
> * Make sure your feature has good automated tests. A good quick check you can do is introduce a small bug somewhere in your code and verify that your tests catch that.
> * For subtle behavior that's hard to test automatically (hint: this is rare), work with QA to get your feature added to their manual test plan.All of the above are great points. They are not mutually exclusive with braces after if statement though. Is there any short coming with requiring braces?
On Feb 22, 2014 10:41 AM, "Nico Weber" <tha...@chromium.org> wrote:
>
> I like to think that it's unlikely that this exact bug would happen in Chromium (strict code review policy, strict testing policy, clang-format, etc). I think the lessons to take away here aren't "let's parse C in our presubmit!" or "let's require braces on all ifs", but rather:
>
> * When reviewing code, review every line, don't just glance over the review and think "looks roughly correct, lgtm"
> * Make sure your feature has good automated tests. A good quick check you can do is introduce a small bug somewhere in your code and verify that your tests catch that.
> * For subtle behavior that's hard to test automatically (hint: this is rare), work with QA to get your feature added to their manual test plan.All of the above are great points. They are not mutually exclusive with braces after if statement though. Is there any short coming with requiring braces?
Nam>
> All this are things everyone should be doing already anyhow (and at least all the people I work with do do this :-) ), so I'm not sure there's much to do here.
>
> (If someone wants to add an automatic check for this problem, I think the right way to attack this is to add some kind of -Windent warning to clang that checks the indent of statements after ifs, whiles, and fors. This is tricky due to tabs vs spaces (the libsecurity_nss code mixes spaces and tabs freely, so something would have to infer that tabs are 4 spaces in that codebase), performance (you'd need to compute column numbers on lots of statements), and false positive rate (as with any new warning, you'd have to try it out on a large codebase such as Chromium). If someone wants to give this a try, that'd be cool.)
On Sun, Feb 23, 2014 at 3:04 PM, Nam Nguyen <namn...@chromium.org> wrote:
On Feb 22, 2014 10:41 AM, "Nico Weber" <tha...@chromium.org> wrote:
>
> I like to think that it's unlikely that this exact bug would happen in Chromium (strict code review policy, strict testing policy, clang-format, etc). I think the lessons to take away here aren't "let's parse C in our presubmit!" or "let's require braces on all ifs", but rather:
>
> * When reviewing code, review every line, don't just glance over the review and think "looks roughly correct, lgtm"
> * Make sure your feature has good automated tests. A good quick check you can do is introduce a small bug somewhere in your code and verify that your tests catch that.
> * For subtle behavior that's hard to test automatically (hint: this is rare), work with QA to get your feature added to their manual test plan.All of the above are great points. They are not mutually exclusive with braces after if statement though. Is there any short coming with requiring braces?
As this is a style question, there will be strong opinions either way. That's why we have a style guide. "Some other code base had a serious bug where one of the things that went wrong might not have gone wrong if _we_ used a different style" isn't an argument for changing our style guide I don't think :-) (And if it was, it should be changed in the google style guide, it shouldn't be a downstream chromium style thing, as we try to stick to regular google style.)
Does anybody know exactly how that defect arose? When I see the same line twice for no good reason, I think it might be a bad merge, which could have happened after review.
Thanks,
jason!
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
if must always always have an accompanying brace."if (condition) DoSomething(); // 2 space indent.
What are you referring to?
if (...) ...
Or
if (...)
....Isnt the second multiline?
Nam
What are you referring to?
if (...) ...
Or
if (...)
....Isnt the second multiline?
Nam
On Feb 24, 2014 3:00 AM, "Colin Blundell" <blun...@chromium.org> wrote:
(From the right address this time.)
I believe clang at least will warn on that one.
I believe clang at least will warn on that one.
On Feb 24, 2014 10:30 AM, "Johnny Graettinger" <jgraet...@chromium.org> wrote:
Another failure mode I've been bitten by is:if (condition);DoSomething(); // 2 space indent.This is very easy to miss in a review. (+1 to requiring braces).
On Mon, Feb 24, 2014 at 10:20 AM, Colin Blundell <blun...@chromium.org> wrote:
My understanding is that "single-line statement" is referring to the number of lines contained in the if block:This is OK:if (foo)...But this would need braces according to Google style (at least from how I've been told to interpret the rule):if (foo)// Explanatory comment here....
The first three seem like they could just as easily be reorganized to be tidier.
But, the fourth NOTREACHED() and default return are (I'm guessing) why the warning was disabled.
I skimmed through the warnings for debug build. These look like potentially real bugs:https://code.google.com/p/chromium/codesearch#chromium/src/ui/views/widget/widget.cc&l=1206 (neither braces nor indent checking would help here, assuming it matters http://crbug.com/346380)
https://code.google.com/p/chromium/codesearch#chromium/src/sandbox/win/src/process_mitigations.cc&l=265 (I note that using braces didn't help here, and it looks like a revert/merge problem http://crbug.com/346382)
This one made me giggle https://code.google.com/p/chromium/codesearch#chromium/src/ppapi/proxy/tcp_socket_resource_base.cc&l=198 given the function name, but it's just not implemented.
There are many cases that are |switch|s that have both a "default: NOTREACHED(); return;" and also a "NOTREACHED(); return;" after the switch body. (Personally, I don't like that style, but some people seem to.).
There's also a bunch of cases where "for(;;)" is used but then a "return Nothing" at the end of the function is also used. Presumably that was to silence a compiler complaining about no return value, so it'd have to be macro'd properly depending on whether the compiler knows that it's unreachable or not.
Overall, I'm not sure that it would be worth changing the correct-but-uninteresting locations to enable the warning. I think I'd probably support it iff all compilers diagnosed in similar ways.
In reference to an earlier comment regarding both spaces and tabs used on a single file, there really should be a coding style guideline going one way or the other.