From db086527035619204569f79672b7a01fc26d8aa4 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Thu, 14 Jan 2016 20:09:51 +0000 Subject: Fix/clarify utilisations of 'char' (thanks Esben Haabendal) --- src/libstddjb/child_spawn.c | 4 ++-- src/libstddjb/mininetstring_read.c | 4 ++-- src/libstddjb/mininetstring_write.c | 4 ++-- src/libstddjb/selfpipe_internal.c | 4 ++-- src/libstddjb/sgetopt.c | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/libstddjb/child_spawn.c b/src/libstddjb/child_spawn.c index 18cee96..addc7cd 100644 --- a/src/libstddjb/child_spawn.c +++ b/src/libstddjb/child_spawn.c @@ -138,8 +138,8 @@ pid_t child_spawn (char const *prog, char const *const *argv, char const *const syncdie: { - char c = errno ; - fd_write(syncpipe[1], &c, 1) ; + unsigned char c = errno ; + fd_write(syncpipe[1], (char const *)&c, 1) ; } _exit(127) ; } diff --git a/src/libstddjb/mininetstring_read.c b/src/libstddjb/mininetstring_read.c index 6a38523..f7c7a55 100644 --- a/src/libstddjb/mininetstring_read.c +++ b/src/libstddjb/mininetstring_read.c @@ -22,8 +22,8 @@ int mininetstring_read (int fd, stralloc *sa, uint32 *w) } if (*w & (1U << 31)) { - char c ; - switch (fd_read(fd, &c, 1)) + unsigned char c ; + switch (fd_read(fd, (char *)&c, 1)) { case -1 : return -1 ; case 0 : return (errno = EPIPE, -1) ; diff --git a/src/libstddjb/mininetstring_write.c b/src/libstddjb/mininetstring_write.c index cb3c30e..5eddc7b 100644 --- a/src/libstddjb/mininetstring_write.c +++ b/src/libstddjb/mininetstring_write.c @@ -23,8 +23,8 @@ int mininetstring_write (int fd, char const *s, uint16 len, uint32 *w) } if (*w & (1U << 31)) { - char c = len & 0xFFU ; - switch (fd_write(fd, &c, 1)) + unsigned char c = len & 0xFFU ; + switch (fd_write(fd, (char const *)&c, 1)) { case -1 : return -1 ; case 0 : return (errno = EAGAIN, -1) ; diff --git a/src/libstddjb/selfpipe_internal.c b/src/libstddjb/selfpipe_internal.c index e5d5d95..f65e07a 100644 --- a/src/libstddjb/selfpipe_internal.c +++ b/src/libstddjb/selfpipe_internal.c @@ -22,8 +22,8 @@ int selfpipe[2] = { -1, -1 } ; static void selfpipe_trigger (int s) { - char c = (char)s ; - fd_write(selfpipe[1], &c, 1) ; + unsigned char c = (unsigned char)s ; + fd_write(selfpipe[1], (char *)&c, 1) ; } struct skasigaction const selfpipe_ssa = { &selfpipe_trigger, SKASA_NOCLDSTOP | SKASA_MASKALL } ; diff --git a/src/libstddjb/sgetopt.c b/src/libstddjb/sgetopt.c index 3f94c93..f576689 100644 --- a/src/libstddjb/sgetopt.c +++ b/src/libstddjb/sgetopt.c @@ -9,7 +9,7 @@ int sgetopt_r (int argc, char const *const *argv, char const *opts, subgetopt_t *o) { - char c = (char)subgetopt_r(argc, argv, opts, o) ; + int c = subgetopt_r(argc, argv, opts, o) ; if (o->err && ((c == '?') || (c == ':'))) { buffer_puts(buffer_2, o->prog ? o->prog : argv[0]) ; @@ -18,5 +18,5 @@ int sgetopt_r (int argc, char const *const *argv, char const *opts, subgetopt_t "illegal option" : "option requires an argument") ; buffer_putflush(buffer_2, "\n", 1) ; } - return (int)c ; + return c ; } -- cgit v1.2.3