From 7496a6a86688807c3d8bd751842fea11449b79b0 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Fri, 6 Sep 2024 15:40:32 +0200 Subject: [PATCH] Fix easy cases of unneeded casts --- src/emu/chan.c | 8 +++++--- src/emu/ovnievents.c | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/emu/chan.c b/src/emu/chan.c index 40cfba9..6d24a0a 100644 --- a/src/emu/chan.c +++ b/src/emu/chan.c @@ -15,9 +15,11 @@ chan_init(struct chan *chan, enum chan_type type, const char *fmt, ...) va_list ap; va_start(ap, fmt); - int n = (int) ARRAYLEN(chan->name); - int ret = vsnprintf(chan->name, (size_t) n, fmt, ap); - if (ret >= n) + size_t n = ARRAYLEN(chan->name); + int ret = vsnprintf(chan->name, n, fmt, ap); + if (ret < 0) + die("vsnprintf failed"); + else if ((size_t) ret >= n) die("channel name too long"); va_end(ap); diff --git a/src/emu/ovnievents.c b/src/emu/ovnievents.c index c217e1e..bb037a4 100644 --- a/src/emu/ovnievents.c +++ b/src/emu/ovnievents.c @@ -29,14 +29,14 @@ html_encode(char *dst, int ndst, const char *src) return -1; } - int c = src[i]; + char c = src[i]; switch (c) { case '&': strcpy(&dst[j], "&"); j += 5; break; case '"': strcpy(&dst[j], """); j += 6; break; case '\'': strcpy(&dst[j], "'"); j += 6; break; case '<': strcpy(&dst[j], "<"); j += 4; break; case '>': strcpy(&dst[j], ">"); j += 4; break; - default: dst[j++] = (char) c; break; + default: dst[j++] = c; break; } }