On 10/2/06, Garrett Rooney <[EMAIL PROTECTED]> wrote:
On 10/2/06, Nick Kew <[EMAIL PROTECTED]> wrote:
> We have a bunch of new bug reports[1], detailing bugs of the form
>
>    if ((rv = do_something(args) == APR_SUCCESS))
>
> for
>
>     if ((rv = do_something(args)) == APR_SUCCESS)
>
> Of course, that's a C classic, and can be a *** to spot.
>
> We can avoid this by adopting an alternative coding style
> that doesn't rely on confusing parentheses:
>
>   if (rv = do_something(args), rv == APR_SUCCESS)
>
> Can I suggest adopting this as a guideline for new code,
> to avoid this kind of bug?

Or the even more readable:

rv = do_something(args);
if (rv == APR_SUCCESS) {

}

+1 to this one

Reply via email to