Please direct comments regarding the Squid source code to 
[EMAIL PROTECTED]

Posting is allowed for all as long as relevant to the Squid source.

Regards
Henrik

---------- Forwarded message ----------
Date: Tue, 3 Aug 2004 00:20:22 -0700
From: mohan <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: signed vs unsigned size_t ickiness in squid3

Hi Henrik,

Just was trying out squid3 and noticed a problem with quickAbort
settings.  Basically, with g++-3.x the meaning of size_t (also
per iso c++ spec from what I understand) is really an unsigned int.

In c, using gcc this is not the case, and size_t is infact a
signed int.  With squid3, the first place you encounter this ickiness
directly, is in cache_cf.cc where the config is being parsed
with parse_kb_t.  While most values are positive, there's that 
quickAbortMin == -1 KB setting (per documentation and legacy squid2
carryover), which makes the config parser throw up all over the place. 

Then, there are things such as:


store_client.cc:764

    size_t curlen = (size_t) mem->endOffset ();

    size_t minlen = (size_t) Config.quickAbort.min << 10;

    if (minlen < 0) {
        debug(90, 3) ("CheckQuickAbort2: NO disabled\n");
        return 0;
    }


Well, in the case of g++ 3, minlen will never be negative!

I shudder to think where else this assumption is made in the
rest of the code... I suppose one way to address this issue
might be to make a new namespace for squid that redefines all
the necessary types.  But then again, it is probably going
to be better to fix all the broken assumptions across squid3.

FYI, this appears to be a duplicate of bug #905 which hasn't
been commented on since it's creation in January.

-mohan

Reply via email to