BUILD: general: always pass unsigned chars to is* functions
authorWilly Tarreau <w@1wt.eu>
Tue, 25 Feb 2020 07:16:33 +0000 (08:16 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 25 Feb 2020 07:16:33 +0000 (08:16 +0100)
commit908071171b56a74b42fbb473ed648189f60388a0
tree6f5854dd193049bc48d5becd945af5863d4bbdf5
parentded15b75640d8f96929beefa3357cafbea25171e
BUILD: general: always pass unsigned chars to is* functions

The isalnum(), isalpha(), isdigit() etc functions from ctype.h are
supposed to take an int in argument which must either reflect an
unsigned char or EOF. In practice on some platforms they're implemented
as macros referencing an array, and when passed a char, they either cause
a warning "array subscript has type 'char'" when lucky, or cause random
segfaults when unlucky. It's quite unconvenient by the way since none of
them may return true for negative values. The recent introduction of
cygwin to the list of regularly tested build platforms revealed a lot
of breakage there due to the same issues again.

So this patch addresses the problem all over the code at once. It adds
unsigned char casts to every valid use case, and also drops the unneeded
double cast to int that was sometimes added on top of it.

It may be backported by dropping irrelevant changes if that helps better
support uncommon platforms. It's unlikely to fix bugs on platforms which
would already not emit any warning though.
18 files changed:
include/common/standard.h
src/buffer.c
src/cfgparse-listen.c
src/cfgparse.c
src/chunk.c
src/fcgi-app.c
src/fcgi.c
src/flt_spoe.c
src/flt_trace.c
src/haproxy.c
src/hlua.c
src/http_htx.c
src/log.c
src/sample.c
src/server.c
src/standard.c
src/stats.c
src/vars.c