httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Garrett Rooney" <roo...@electricjellyfish.net>
Subject Re: Coding style
Date Mon, 02 Oct 2006 18:59:12 GMT
On 10/2/06, Nick Kew <nick@webthing.com> 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) {

}

-garrett

Mime
View raw message