summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-06-06 06:25:58 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-06-06 06:25:58 -0700
commit840330f271f25b093c7a86b41e7cddaec0cb6d7f (patch)
treed6d603f3a783b217959746c9bcc9410548dfb9a6
parent9bc7cb70ae8d216f90f11ba66e202e941c469a91 (diff)
downloadtxr-840330f271f25b093c7a86b41e7cddaec0cb6d7f.tar.gz
txr-840330f271f25b093c7a86b41e7cddaec0cb6d7f.tar.bz2
txr-840330f271f25b093c7a86b41e7cddaec0cb6d7f.zip
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.
-rw-r--r--ffi.c6
-rw-r--r--stream.c8
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) {