[dev] Bug in join.c

From: Random832 <random832_AT_fastmail.com>
Date: Mon, 14 Dec 2015 12:49:04 -0500

I was going through sbase checking with -Wall -Wextra -pedantic
-Werror, and among a bunch of noise errors relating to
signed/unsigned comparisons, I found one with actual substance:
the result of getline is being converted to size_t before
comparing to -1 to check for error.

diff --git a/join.c b/join.c
index 1a08927..6828cf4 100644
--- a/join.c
+++ b/join.c
_AT_@ -261,7 +261,8 @@ static int
 addtospan(struct span *sp, FILE *fp, int reset)
 {
        char *newl = NULL;
- size_t len, size = 0;
+ ssize_t len;
+ size_t size = 0;
 
        if ((len = getline(&newl, &size, fp)) == -1) {
                if (ferror(fp))


I also couldn't quite figure out if this line of tail.c is
correct or not.

n = MIN(llabs(estrtonum(numstr, LLONG_MIN + 1, MIN(LLONG_MAX, SIZE_MAX))), SIZE_MAX);
Received on Mon Dec 14 2015 - 18:49:04 CET

This archive was generated by hypermail 2.3.0 : Mon Dec 14 2015 - 19:00:12 CET