skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

commit db086527035619204569f79672b7a01fc26d8aa4
parent 8849baf295715efd428e9243b67b2576a41f8fe4
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Thu, 14 Jan 2016 20:09:51 +0000

 Fix/clarify utilisations of 'char' (thanks Esben Haabendal)

Diffstat:
Msrc/libstddjb/child_spawn.c | 4++--
Msrc/libstddjb/mininetstring_read.c | 4++--
Msrc/libstddjb/mininetstring_write.c | 4++--
Msrc/libstddjb/selfpipe_internal.c | 4++--
Msrc/libstddjb/sgetopt.c | 4++--
5 files changed, 10 insertions(+), 10 deletions(-)

diff --git 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 @@ -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 @@ -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 @@ -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 @@ -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 ; }