MINOR: chunk: remove impossible tests on negative chunk->data
Since commit 843b7cb ("MEDIUM: chunks: make the chunk struct's fields
match the buffer struct") a chunk length is unsigned so we can remove
negative size checks.
diff --git a/include/common/chunk.h b/include/common/chunk.h
index a127f9a..383e157 100644
--- a/include/common/chunk.h
+++ b/include/common/chunk.h
@@ -117,7 +117,7 @@
static inline int chunk_memcat(struct buffer *chk, const char *src,
size_t len)
{
- if (unlikely(chk->data < 0 || chk->data + len >= chk->size))
+ if (unlikely(chk->data + len >= chk->size))
return 0;
memcpy(chk->area + chk->data, src, len);
@@ -152,7 +152,7 @@
len = strlen(str);
- if (unlikely(chk->data < 0 || chk->data + len >= chk->size))
+ if (unlikely(chk->data + len >= chk->size))
return 0;
memcpy(chk->area + chk->data, str, len + 1);
@@ -165,7 +165,7 @@
*/
static inline int chunk_strncat(struct buffer *chk, const char *str, int nb)
{
- if (unlikely(chk->data < 0 || chk->data + nb >= chk->size))
+ if (unlikely(chk->data + nb >= chk->size))
return 0;
memcpy(chk->area + chk->data, str, nb);
@@ -187,7 +187,7 @@
*/
static inline char *chunk_newstr(struct buffer *chk)
{
- if (chk->data < 0 || chk->data + 1 >= chk->size)
+ if (chk->data + 1 >= chk->size)
return NULL;
chk->area[chk->data++] = 0;
@@ -219,7 +219,7 @@
*/
static inline char *chunk_dup(struct buffer *dst, const struct buffer *src)
{
- if (!dst || !src || src->data < 0 || !src->area)
+ if (!dst || !src || !src->area)
return NULL;
if (dst->size)
diff --git a/src/chunk.c b/src/chunk.c
index 7e90ee6..303d3fd 100644
--- a/src/chunk.c
+++ b/src/chunk.c
@@ -167,7 +167,7 @@
va_list argp;
int ret;
- if (chk->data < 0 || !chk->area || !chk->size)
+ if (!chk->area || !chk->size)
return 0;
va_start(argp, fmt);
@@ -193,9 +193,6 @@
int olen, free;
char c;
- if (dst->data < 0)
- return dst->data;
-
olen = dst->data;
for (i = 0; i < src->data; i++) {
@@ -238,9 +235,6 @@
int olen, free;
char c;
- if (dst->data < 0)
- return dst->data;
-
olen = dst->data;
for (i = 0; i < src->data; i++) {