httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick Kew <n...@webthing.com>
Subject Re: Coding style
Date Mon, 02 Oct 2006 21:12:27 GMT
On Monday 02 October 2006 21:39, Ruediger Pluem wrote:

> In general I agree with the above, but there are situations were the old
> style really makes sense, e.g (from log_child in server/log.c):
>
> if (((rc = apr_procattr_create(&procattr, p)) == APR_SUCCESS)
>         && ((rc = apr_procattr_cmdtype_set(procattr,
>                                            APR_SHELLCMD_ENV)) ==
> APR_SUCCESS) && ((rc = apr_procattr_io_set(procattr,
>                                       APR_FULL_BLOCK,
>                                       APR_NO_PIPE,
>                                       APR_NO_PIPE)) == APR_SUCCESS)
>         && ((rc = apr_procattr_error_check_set(procattr, 1)) ==
> APR_SUCCESS) && ((rc = apr_procattr_child_errfn_set(procattr,
> log_child_errfn)) == APR_SUCCESS)) {

Now that is true bug-heaven.  If we accept your premise that a complex
if (...) is better than the alternatives, then a comma-list is much less
bug-prone:

  if ((rc = apr_procattr_create(&procattr, p), rc == APR_SUCCESS)
    && (rc = apr_procattr_cmdtype_set(procattr, APR_SHELLCMD_ENV),
		rc == APR_SUCCESS)
    && (rc = apr_procattr_io_set(procattr, APR_FULL_BLOCK,
                                                   APR_NO_PIPE, APR_NO_PIPE),
		rc == APR_SUCCESS)
    && (rc = apr_procattr_error_check_set(procattr, 1), rc == APR_SUCCESS)
    && (rc = apr_procattr_child_errfn_set(procattr, log_child_errfn),
		rc == APR_SUCCESS)) {

(Not sure how that'll look in terms of wrap and whitespace -
this is a mailer, not a program editor.  But you get the point).

-- 
Nick Kew

Mime
View raw message