commit d9488baa63351cafd237f5af15018ea5898ec0bc
parent 208dc53700866d413efaf7374ebd9dbaeaee6551
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date: Thu, 2 Sep 2021 19:11:11 +0000
Pass errno as unsigned char
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat:
11 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/src/include/s6/lock.h b/src/include/s6/lock.h
@@ -31,7 +31,7 @@ struct s6lock_s
{
textclient connection ;
genalloc list ; /* array of uint16_t */
- gensetdyn data ; /* set of char */
+ gensetdyn data ; /* set of unsigned char */
} ;
#define S6LOCK_ZERO { .connection = TEXTCLIENT_ZERO, .list = GENALLOC_ZERO, .data = GENSETDYN_INIT(int, 2, 0, 1) }
extern s6lock_t const s6lock_zero ;
diff --git a/src/libs6/s6-ftrigrd.c b/src/libs6/s6-ftrigrd.c
@@ -74,9 +74,9 @@ static void trig (uint16_t id, char what, char info)
}
}
-static void answer (char c)
+static void answer (unsigned char c)
{
- if (!textmessage_put(textmessage_sender_1, &c, 1))
+ if (!textmessage_put(textmessage_sender_1, (char *)&c, 1))
{
cleanup() ;
strerr_diefu1sys(111, "textmessage_put") ;
diff --git a/src/libs6/s6_fdholder_delete.c b/src/libs6/s6_fdholder_delete.c
@@ -21,5 +21,5 @@ int s6_fdholder_delete (s6_fdholder_t *a, char const *id, tain const *deadline,
unixmessage_drop(&m) ;
return (errno = EPROTO, 0) ;
}
- return m.s[0] ? (errno = m.s[0], 0) : 1 ;
+ return m.s[0] ? (errno = (unsigned char)m.s[0], 0) : 1 ;
}
diff --git a/src/libs6/s6_fdholder_getdump.c b/src/libs6/s6_fdholder_getdump.c
@@ -26,7 +26,7 @@ int s6_fdholder_getdump (s6_fdholder_t *a, genalloc *g, tain const *deadline, ta
if (!unixmessage_sender_timed_flush(&a->connection.out, deadline, stamp)) return 0 ;
if (sanitize_read(unixmessage_timed_receive(&a->connection.in, &m, deadline, stamp)) < 0) return 0 ;
if (!m.len || m.nfds) return (errno = EPROTO, 0) ;
- if (m.s[0]) return (errno = m.s[0], 0) ;
+ if (m.s[0]) return (errno = (unsigned char)m.s[0], 0) ;
if (m.len != 9) return (errno = EPROTO, 0) ;
uint32_unpack_big(m.s + 1, &n) ;
uint32_unpack_big(m.s + 5, &ntot) ;
diff --git a/src/libs6/s6_fdholder_setdump.c b/src/libs6/s6_fdholder_setdump.c
@@ -34,7 +34,7 @@ int s6_fdholder_setdump (s6_fdholder_t *a, s6_fdholder_fd_t const *list, unsigne
if (!unixmessage_sender_timed_flush(&a->connection.out, deadline, stamp)) return 0 ;
if (sanitize_read(unixmessage_timed_receive(&a->connection.in, &m, deadline, stamp)) < 0) return 0 ;
if (!m.len || m.nfds) { unixmessage_drop(&m) ; return (errno = EPROTO, 0) ; }
- if (m.s[0]) return (errno = m.s[0], 0) ;
+ if (m.s[0]) return (errno = (unsigned char)m.s[0], 0) ;
if (m.len != 5) return (errno = EPROTO, 0) ;
uint32_unpack_big(m.s + 1, &trips) ;
if (trips != 1 + (ntot-1) / UNIXMESSAGE_MAXFDS) return (errno = EPROTO, 0) ;
@@ -71,10 +71,10 @@ int s6_fdholder_setdump (s6_fdholder_t *a, s6_fdholder_fd_t const *list, unsigne
unixmessage_drop(&m) ;
return (errno = EPROTO, 0) ;
}
- if (!error_isagain(m.s[0]) && i < trips-1)
- return errno = m.s[0] ? m.s[0] : EPROTO, 0 ;
+ if (!error_isagain((unsigned char)m.s[0]) && i < trips-1)
+ return errno = m.s[0] ? (unsigned char)m.s[0] : EPROTO, 0 ;
if (i == trips - 1 && m.s[0])
- return errno = error_isagain(m.s[0]) ? EPROTO : m.s[0], 0 ;
+ return errno = error_isagain((unsigned char)m.s[0]) ? EPROTO : (unsigned char)m.s[0], 0 ;
}
}
return 1 ;
diff --git a/src/libs6/s6_fdholder_store.c b/src/libs6/s6_fdholder_store.c
@@ -21,5 +21,5 @@ int s6_fdholder_store (s6_fdholder_t *a, int fd, char const *id, tain const *lim
unixmessage_drop(&m) ;
return (errno = EPROTO, 0) ;
}
- return m.s[0] ? (errno = m.s[0], 0) : 1 ;
+ return m.s[0] ? (errno = (unsigned char)m.s[0], 0) : 1 ;
}
diff --git a/src/libs6/s6lock_acquire.c b/src/libs6/s6lock_acquire.c
@@ -35,7 +35,7 @@ int s6lock_acquire (s6lock_t *a, uint16_t *u, char const *path, uint32_t options
errno = e ;
return 0 ;
}
- *GENSETDYN_P(char, &a->data, i) = EAGAIN ;
+ *GENSETDYN_P(unsigned char, &a->data, i) = EAGAIN ;
*u = i ;
return 1 ;
}
diff --git a/src/libs6/s6lock_check.c b/src/libs6/s6lock_check.c
@@ -7,7 +7,7 @@
int s6lock_check (s6lock_t *a, uint16_t id)
{
- char *p = GENSETDYN_P(char, &a->data, id) ;
+ unsigned char *p = GENSETDYN_P(unsigned char, &a->data, id) ;
switch (*p)
{
case EBUSY : return 1 ;
diff --git a/src/libs6/s6lock_release.c b/src/libs6/s6lock_release.c
@@ -9,7 +9,7 @@
int s6lock_release (s6lock_t *a, uint16_t i, tain const *deadline, tain *stamp)
{
- char *p = GENSETDYN_P(char, &a->data, i) ;
+ unsigned char *p = GENSETDYN_P(unsigned char, &a->data, i) ;
char pack[3] = "-->" ;
if ((*p != EBUSY) && !error_isagain(*p))
{
diff --git a/src/libs6/s6lock_update.c b/src/libs6/s6lock_update.c
@@ -18,11 +18,11 @@ static int msghandler (struct iovec const *v, void *context)
{
s6lock_t *a = (s6lock_t *)context ;
char const *s = v->iov_base ;
- char *p ;
+ unsigned char *p ;
uint16_t id ;
if (v->iov_len != 3) return (errno = EPROTO, 0) ;
uint16_unpack_big(s, &id) ;
- p = GENSETDYN_P(char, &a->data, id) ;
+ p = GENSETDYN_P(unsigned char, &a->data, id) ;
if (*p == EBUSY) *p = s[2] ;
else if (error_isagain(*p)) *p = s[2] ? s[2] : EBUSY ;
else return (errno = EPROTO, 0) ;
diff --git a/src/libs6/s6lockd.c b/src/libs6/s6lockd.c
@@ -56,7 +56,7 @@ static void cleanup (void)
genalloc_setlen(s6lockio_t, &a, 0) ;
}
-static void trig (uint16_t id, char e)
+static void trig (uint16_t id, unsigned char e)
{
char pack[3] ;
uint16_pack_big(pack, id) ;
@@ -68,9 +68,9 @@ static void trig (uint16_t id, char e)
}
}
-static void answer (char c)
+static void answer (unsigned char c)
{
- if (!textmessage_put(textmessage_sender_1, &c, 1))
+ if (!textmessage_put(textmessage_sender_1, (char *)&c, 1))
{
cleanup() ;
strerr_diefu1sys(111, "textmessage_put") ;