Re: [PATCH] HttpHdrSc c++ refactoring

From: Kinkie <gkinkie_at_gmail.com>
Date: Fri, 18 Nov 2011 00:57:48 +0100

>> Please find attached a new iteration of the patch for review.
>
>
>> -        temp = xstrndup (item, initiallen + 1);
>> -
>> -        if (!((target = strrchr(temp, ';')) && !strchr (target, '"') && *(target + 1) != '\0'))
>> +        if (!((target = memrchr(item, ';')) && !strchr (target, '"') && *(target + 1) != '\0'))
>
> I shortened the memchr() call in the new line for clarity -- it is not
> relevant for this specific comment. Look at the stuff after "&&". The
> old code was calling strchr() for "target" pointing to a zero-terminated
> "temp" string. The new code calls it for target pointing to a
> non-terminated "item". AFAICT, this means that we may find '"' beyond
> the current item (at best). A bug?

I've reverted the change. While it may improve performance, it's not a
critical code-path and it'll be moot once StringNg hits anyways.

>> +        case SC_MAX_AGE:
>> +             int ma;
>
> IIRC, some compilers complain about a local variable not confined
> "enough" to a single switch case scope (in case the if statements bypass
> the "break" command and the compiler cannot reliably detect that?). I
> tried to quickly find any examples of "bare" case-local variables in
> Squid but failed.
>
> Consider surrounding the whole case with {}.

Done.

New iteration attached, please review it.

Thanks

-- 
    /kinkie

Received on Thu Nov 17 2011 - 23:58:03 MST

This archive was generated by hypermail 2.2.0 : Fri Nov 18 2011 - 12:00:07 MST