httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Trawick" <traw...@gmail.com>
Subject Re: Coding style
Date Mon, 02 Oct 2006 19:40:42 GMT
On 10/2/06, Garrett Rooney <rooneg@electricjellyfish.net> wrote:
> 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) {
>
> }

+1 to this one

Mime
View raw message