summaryrefslogtreecommitdiff
path: root/cord
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2016-08-29 15:58:00 +0300
committerIvan Maidanski <ivmai@mail.ru>2016-08-29 16:34:45 +0300
commitc54aba1c5feb77ad9b111a990481e8a5be29954c (patch)
tree7430ac905b703b8ff375e84a8f8afb697041cf1e /cord
parentf0fd1b1595781e9305733fd29d1c147b3dceaccc (diff)
downloadbdwgc-c54aba1c5feb77ad9b111a990481e8a5be29954c.tar.gz
Eliminate 'checking if unsigned variable is <0' cppcheck style warning
* cord/cordbscs.c (CORD_from_fn, CORD_substr): Do not expect size_t value to be negative (replace <=0 comparison with ==0 one). * cord/cordxtra.c (CORD_cmp): Likewise. * cord/cordbscs.c (CORD_substr): Remove obsolete comment (about SunOS 4 which had signed size_t type).
Diffstat (limited to 'cord')
-rw-r--r--cord/cordbscs.c6
-rw-r--r--cord/cordxtra.c5
2 files changed, 5 insertions, 6 deletions
diff --git a/cord/cordbscs.c b/cord/cordbscs.c
index 2c54d06f..efe75b54 100644
--- a/cord/cordbscs.c
+++ b/cord/cordbscs.c
@@ -281,7 +281,7 @@ CORD CORD_cat(CORD x, CORD y)
CORD CORD_from_fn(CORD_fn fn, void * client_data, size_t len)
{
- if (len <= 0) return(0);
+ if (len == 0) return(0);
if (len <= SHORT_LIMIT) {
register char * result;
register size_t i;
@@ -457,9 +457,7 @@ CORD CORD_substr(CORD x, size_t i, size_t n)
{
register size_t len = CORD_len(x);
- if (i >= len || n <= 0) return(0);
- /* n < 0 is impossible in a correct C implementation, but */
- /* quite possible under SunOS 4.X. */
+ if (i >= len || n == 0) return(0);
if (i + n > len) n = len - i;
return(CORD_substr_checked(x, i, n));
}
diff --git a/cord/cordxtra.c b/cord/cordxtra.c
index 79abca0e..cac407d4 100644
--- a/cord/cordxtra.c
+++ b/cord/cordxtra.c
@@ -172,8 +172,9 @@ int CORD_cmp(CORD x, CORD y)
if (!CORD_pos_valid(ypos)) {
return(1);
}
- if ((avail = CORD_pos_chars_left(xpos)) <= 0
- || (yavail = CORD_pos_chars_left(ypos)) <= 0) {
+ avail = CORD_pos_chars_left(xpos);
+ if (avail == 0
+ || (yavail = CORD_pos_chars_left(ypos)) == 0) {
register char xcurrent = CORD_pos_fetch(xpos);
register char ycurrent = CORD_pos_fetch(ypos);
if (xcurrent != ycurrent) return(xcurrent - ycurrent);