Re: [dev] Bug in join.c

From: Mattias Andrée <maandree_AT_kth.se>
Date: Mon, 14 Dec 2015 19:01:23 +0100

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

> 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);
>
>

I think this patch should be included. But I don't see
how it is of substance. It will never occur with two's
complement or ones' complement. Only, signed magnitude
representatiion. Any sensible C compiler for POSIX
systems will only use two's complement; otherwise
int[0-9]*_t cannot be implemented.


Received on Mon Dec 14 2015 - 19:01:23 CET

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