httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: a missing while block runs the next statement?
Date Fri, 19 Apr 2002 15:34:36 GMT
Joe Schaefer wrote:
> Stas Bekman <stas@stason.org> writes:
> 
> 
>>I think this patch is needed. Otherwise to me it looks like we have:
>>
>>   ap_hard_timeout(...)
>>   while (...) {
>>       ap_kill_timeout(...);
>>   }
>>
>>or was this intentional and therefore the indent is wrong?
> 
> 
> In C, the {} braces are for grouping multiple statements into a single
> compound statement.

I know :) I'm not talking about this. I'm talking about the case where a 
loop doesn't have any statement, which is the case I'm trying to 
present. Since these two are exactly the same and that's not what we want.

a)
    while (...)
    ap_kill_timeout(...);

b)
     while (...) {
        ap_kill_timeout(...);
     }

currently the code calls ap_kill_timeout() in a while loop. I think this 
is wrong. empty {} prevents that.

>>while porting, I'm enforcing explicit {} everywhere per apache style.
> 
>                                                           ^^^^^^^^^^^^
> 
> The apache style guide does NOT _enforce_ {} everywhere.

I have reread the guidelines and indeed you are right. However we do so 
in the modperl-2.0 land, and I think it's a good habit. But I'm not 
trying to argue :)

> [...]
> 
> 
>>              ap_hard_timeout("[libapreq] parse_multipart", r);
>>-            while ( ap_get_client_block(r, buff, sizeof(buff)) > 0 )
>>+            while ( ap_get_client_block(r, buff, sizeof(buff)) > 0 ) {
>>                  /* wait for more input to ignore */ ;
>>+            }
> 
> 
> As far as the C compiler is concerned, your patch changes 
> absolutely nothing.  However, I don't object to your patch
> if you think it makes the code clearer.

Yup, thanks for confirming that. I think I read this before in the C FAQ.
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Mime
View raw message