Fix easy cases of unneeded casts

This commit is contained in:
Rodrigo Arias 2024-09-06 15:40:32 +02:00
parent c8750b9dfd
commit 7496a6a866
2 changed files with 7 additions and 5 deletions

View File

@ -15,9 +15,11 @@ chan_init(struct chan *chan, enum chan_type type, const char *fmt, ...)
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
int n = (int) ARRAYLEN(chan->name); size_t n = ARRAYLEN(chan->name);
int ret = vsnprintf(chan->name, (size_t) n, fmt, ap); int ret = vsnprintf(chan->name, n, fmt, ap);
if (ret >= n) if (ret < 0)
die("vsnprintf failed");
else if ((size_t) ret >= n)
die("channel name too long"); die("channel name too long");
va_end(ap); va_end(ap);

View File

@ -29,14 +29,14 @@ html_encode(char *dst, int ndst, const char *src)
return -1; return -1;
} }
int c = src[i]; char c = src[i];
switch (c) { switch (c) {
case '&': strcpy(&dst[j], "&amp;"); j += 5; break; case '&': strcpy(&dst[j], "&amp;"); j += 5; break;
case '"': strcpy(&dst[j], "&quot;"); j += 6; break; case '"': strcpy(&dst[j], "&quot;"); j += 6; break;
case '\'': strcpy(&dst[j], "&apos;"); j += 6; break; case '\'': strcpy(&dst[j], "&apos;"); j += 6; break;
case '<': strcpy(&dst[j], "&lt;"); j += 4; break; case '<': strcpy(&dst[j], "&lt;"); j += 4; break;
case '>': strcpy(&dst[j], "&gt;"); j += 4; break; case '>': strcpy(&dst[j], "&gt;"); j += 4; break;
default: dst[j++] = (char) c; break; default: dst[j++] = c; break;
} }
} }