From 2d9daf44f2cc47410d3bbe3dc1623a61cf4eba15 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 6 Jun 2017 06:25:58 -0700 Subject: c++ maintenance: signed/unsigned comparisons. * ffi.c (ffi_sbit_put, make_ffi_type_struct): Fix signed/unsigned comparison warning from g++. (pad_retval): Likewise. * stream.c (stdio_put_buf, stdio_fill_buf): Likewise. --- ffi.c | 6 +++--- stream.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ffi.c b/ffi.c index e80e0e60..1db20fcc 100644 --- a/ffi.c +++ b/ffi.c @@ -62,7 +62,7 @@ #define alignof(type) offsetof(struct {char x; type y;}, y) -#define pad_retval(size) ((size) > sizeof (ffi_arg) \ +#define pad_retval(size) (convert(size_t, size) > sizeof (ffi_arg) \ ? (size) \ : sizeof (ffi_arg)) @@ -1295,7 +1295,7 @@ static void ffi_sbit_put(struct txr_ffi_type *tft, val n, int icheck = -(int)(((uput ^ mask) >> shift) + 1); if (icheck != cn) goto range; - } else if (uput >> shift != cn) { + } else if (convert(cnum, uput >> shift) != cn) { goto range; } @@ -2730,7 +2730,7 @@ static val make_ffi_type_struct(val syntax, val lisp_type, mtft->mask = ((1U << bits) - 1) << mtft->shift; bit_offs += bits; } else { - cnum align = mtft->align; + ucnum align = mtft->align; ucnum almask = align - 1; if (bit_offs > 0) { diff --git a/stream.c b/stream.c index a4560f05..64ca8888 100644 --- a/stream.c +++ b/stream.c @@ -860,9 +860,9 @@ static val stdio_put_buf(val stream, val buf, cnum pos) ucnum len = c_unum(length_buf(buf)); mem_t *ptr = buf_get(buf, self); struct stdio_handle *h = coerce(struct stdio_handle *, stream->co.handle); - if ((size_t) len != len) + if ((size_t) len != len || len > INT_PTR_MAX) uw_throwf(error_s, lit("~a: buffer too large"), self, nao); - if (pos >= len) + if (convert(ucnum, pos) >= len) return num(len); errno = 0; if (h->f != 0) { @@ -880,9 +880,9 @@ static val stdio_fill_buf(val stream, val buf, cnum pos) ucnum len = c_unum(length_buf(buf)); mem_t *ptr = buf_get(buf, self); struct stdio_handle *h = coerce(struct stdio_handle *, stream->co.handle); - if ((size_t) len != len) + if ((size_t) len != len || len > INT_PTR_MAX) uw_throwf(error_s, lit("~a: buffer too large"), self, nao); - if (pos >= len) + if (convert(ucnum, pos) >= len) return num(len); errno = 0; if (h->f != 0) { -- cgit v1.2.3