From: Amos Jeffries Date: Mon, 7 Oct 2013 11:23:58 +0000 (-0600) Subject: Fix more signedness comparisons in SBuf X-Git-Tag: SQUID_3_5_0_1~606 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b6776e98124e38a783f9b49b3d58b06d428be357;p=thirdparty%2Fsquid.git Fix more signedness comparisons in SBuf --- diff --git a/src/SBuf.cc b/src/SBuf.cc index 46faa6bc57..db745a1672 100644 --- a/src/SBuf.cc +++ b/src/SBuf.cc @@ -558,10 +558,6 @@ SBuf::find(char c, size_type startPos) const if (startPos > length()) return npos; - // ignore invalid startPos - if (startPos < 0) - startPos = 0; - const void *i = memchr(buf()+startPos, (int)c, (size_type)length()-startPos); if (i == NULL) @@ -578,9 +574,6 @@ SBuf::find(const SBuf &needle, size_type startPos) const return npos; } - if (startPos < 0) - startPos = 0; - // std::string allows needle to overhang hay but not start outside if (startPos > length()) { ++stats.find; @@ -673,8 +666,6 @@ SBuf::rfind(char c, SBuf::size_type endPos) const // on npos input std::string compares last octet of hay if (endPos == npos || endPos >= length()) { endPos = length(); - } else if (endPos < 0) { - return npos; } else { // NP: off-by-one weirdness: // endPos is an offset ... 0-based @@ -709,9 +700,6 @@ SBuf::find_first_of(const SBuf &set, size_type startPos) const if (startPos >= length()) return npos; - if (startPos < 0) - startPos = 0; - if (set.length() == 0) return npos; @@ -813,8 +801,6 @@ SBuf::toUpper() const void SBuf::checkAccessBounds(size_type pos) const { - if (pos < 0) - throw OutOfBoundsException(*this, pos, __FILE__, __LINE__); if (pos >= length()) throw OutOfBoundsException(*this, pos, __FILE__, __LINE__); }