------------------------------------------------------------ revno: 13042 revision-id: squid3@treenet.co.nz-20131008041717-4l4qwmhaskabroni parent: squid3@treenet.co.nz-20131008012423-siptl9p0qrdpwetj committer: Amos Jeffries branch nick: trunk timestamp: Mon 2013-10-07 22:17:17 -0600 message: More SBuf signedness fixes ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20131008041717-4l4qwmhaskabroni # target_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # testament_sha1: 3378ec892099708397e1db40e87d920d0de38f69 # timestamp: 2013-10-08 05:06:44 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # base_revision_id: squid3@treenet.co.nz-20131008012423-\ # siptl9p0qrdpwetj # # Begin patch === modified file 'src/SBuf.h' --- src/SBuf.h 2013-10-07 10:36:47 +0000 +++ src/SBuf.h 2013-10-08 04:17:17 +0000 @@ -417,7 +417,7 @@ * \throw SBufTooBigException if the user tries to allocate too big a SBuf */ void reserveSpace(size_type minSpace) { - Must(minSpace < maxSize); + Must(minSpace <= maxSize); Must(length() <= maxSize - minSpace); reserveCapacity(length()+minSpace); } === modified file 'src/tests/SBufFindTest.cc' --- src/tests/SBufFindTest.cc 2013-10-04 13:55:21 +0000 +++ src/tests/SBufFindTest.cc 2013-10-08 04:17:17 +0000 @@ -166,9 +166,6 @@ if (theFindString == std::string::npos && theFindSBuf == SBuf::npos) return true; // both npos - if (theFindSBuf < 0) // should not happen, treat as error - return false; - // now safe to cast a non-negative SBuf result return theFindString == static_cast(theFindSBuf); } @@ -267,23 +264,21 @@ if (thePos == SBuf::npos) return ",npos"; - if (thePos < 0) - return ",posN"; // negative - - // we know Pos is not negative or special; avoid signed/unsigned warnings - const std::string::size_type pos = - static_cast(thePos); - - if (pos < theBareNeedlePos) + if (thePos < theBareNeedlePos) return ",posL"; // to the Left of the needle - if (pos == theBareNeedlePos) + + if (thePos == theBareNeedlePos) return ",posB"; // Beginning of the needle - if (pos < theBareNeedlePos + theStringNeedle.length()) + + if (thePos < theBareNeedlePos + theStringNeedle.length()) return ",posM"; // in the Middle of the needle - if (pos == theBareNeedlePos + theStringNeedle.length()) + + if (thePos == theBareNeedlePos + theStringNeedle.length()) return ",posE"; // at the End of the needle - if (pos < theStringHay.length()) + + if (thePos < theStringHay.length()) return ",posR"; // to the Right of the needle + return ",posP"; // past the hay }