summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-04-05 19:46:56 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-04-05 19:46:56 -0700
commite181b0717470194a853d5084f902fde539635822 (patch)
tree789f5dd541e9db2e084261e4ddb4ec7a98e8d50f
parent858ce927fc30d080793fffe42b0ce6fcddfbb3c5 (diff)
downloadtxr-e181b0717470194a853d5084f902fde539635822.tar.gz
txr-e181b0717470194a853d5084f902fde539635822.tar.bz2
txr-e181b0717470194a853d5084f902fde539635822.zip
warning cleanup: signed/unsigned in ternaries.
This is the third round of an effort to enable GCC's -Wextra option. Instances of signed/unsigned mismatch between the branches of ternary conditionals are addressed. * ffi.c (pad_retval): Add cast into the consequent of the conditional so it yields size_t, like the alternative. * lib.c (split_str_keep): Likewise. (vector): Cast -1 to ucnum so it has the same type as the alloc_plus opposite to it. * parser.c (lino_getch): Add a cast to wint_t to match return value and opposite WEOF operand. * stream.c (generic_get_line): Likewise. * sysif.c (c_time): Convert both consequent and alternative to time_t to silence warning.
-rw-r--r--ffi.c2
-rw-r--r--lib.c4
-rw-r--r--parser.c2
-rw-r--r--stream.c2
-rw-r--r--sysif.c2
5 files changed, 6 insertions, 6 deletions
diff --git a/ffi.c b/ffi.c
index 02b82372..ed04b3f1 100644
--- a/ffi.c
+++ b/ffi.c
@@ -66,7 +66,7 @@
#define alignof(type) offsetof(struct {char x; type y;}, y)
#define pad_retval(size) (!(size) || convert(size_t, size) > sizeof (ffi_arg) \
- ? (size) \
+ ? (size_t) (size) \
: sizeof (ffi_arg))
#define min(a, b) ((a) < (b) ? (a) : (b))
diff --git a/lib.c b/lib.c
index 1f8fadff..66e859f1 100644
--- a/lib.c
+++ b/lib.c
@@ -4255,7 +4255,7 @@ val split_str_keep(val str, val sep, val keep_sep)
for (;;) {
const wchar_t *psep = wcsstr(cstr, csep);
- size_t span = (psep != 0) ? psep - cstr : wcslen(cstr);
+ size_t span = (psep != 0) ? (size_t) (psep - cstr) : wcslen(cstr);
val piece = mkustring(num(span));
init_str(piece, cstr);
iter = list_collect(iter, piece);
@@ -7316,7 +7316,7 @@ val vector(val length, val initval)
unsigned i;
ucnum len = c_unum(length);
ucnum alloc_plus = len + 2;
- ucnum size = if3(alloc_plus > len, alloc_plus, -1);
+ ucnum size = if3(alloc_plus > len, alloc_plus, (ucnum) -1);
val *v = coerce(val *, chk_xalloc(size, sizeof *v, lit("vector")));
val vec = make_obj();
vec->v.type = VEC;
diff --git a/parser.c b/parser.c
index 7e7b0ddb..6372032c 100644
--- a/parser.c
+++ b/parser.c
@@ -1655,7 +1655,7 @@ static wint_t lino_getch(mem_t *stream_in)
stream = coerce(val, stream_in);
ch = get_char(stream);
- ret = if3(ch, c_num(ch), WEOF);
+ ret = if3(ch, (wint_t) c_num(ch), WEOF);
uw_catch (sy, va) {
(void) sy;
diff --git a/stream.c b/stream.c
index 662ba359..bd8d463e 100644
--- a/stream.c
+++ b/stream.c
@@ -803,7 +803,7 @@ val generic_get_line(val stream)
for (;;) {
val chr = ops->get_char(stream);
- wint_t ch = chr ? c_chr(chr) : WEOF;
+ wint_t ch = chr ? (wint_t) c_chr(chr) : WEOF;
if (ch == WEOF && buf == 0)
break;
diff --git a/sysif.c b/sysif.c
index 0f614a2e..d4452b65 100644
--- a/sysif.c
+++ b/sysif.c
@@ -1042,7 +1042,7 @@ static val exit_star_wrap(val status)
time_t c_time(val time)
{
- return if3(convert(time_t, -1) > 0, c_unum(time), c_num(time));
+ return if3(convert(time_t, -1) > 0, (time_t) c_unum(time), (time_t) c_num(time));
}
val num_time(time_t time)