signedness: Fix less obvious issues

* My compilers mark these as errors
* Attempt to be more correct
* Tested on gcc-5.2.0 and clang-3.6.2
This commit is contained in:
Kyle Manna 2015-08-17 18:52:36 -07:00
parent e933510236
commit 376b63fb81
6 changed files with 15 additions and 15 deletions

10
capn.c
View file

@ -231,7 +231,7 @@ static struct capn_segment *lookup_segment(struct capn* c, struct capn_segment *
static uint64_t lookup_double(struct capn_segment **s, char **d, uint64_t val) {
uint64_t far, tag;
uint32_t off = (U32(val) >> 3) * 8;
size_t off = (U32(val) >> 3) * 8;
char *p;
if ((*s = lookup_segment((*s)->capn, *s, U32(val >> 32))) == NULL) {
@ -266,7 +266,7 @@ static uint64_t lookup_double(struct capn_segment **s, char **d, uint64_t val) {
}
static uint64_t lookup_far(struct capn_segment **s, char **d, uint64_t val) {
uint32_t off = (U32(val) >> 3) * 8;
size_t off = (U32(val) >> 3) * 8;
if ((*s = lookup_segment((*s)->capn, *s, U32(val >> 32))) == NULL) {
return 0;
@ -371,7 +371,7 @@ static capn_ptr read_ptr(struct capn_segment *s, char *d) {
e = d + ret.len * 8;
break;
case COMPOSITE_LIST:
if (d+8-s->data > s->len) {
if ((size_t)((d+8) - s->data) > s->len) {
goto err;
}
@ -396,7 +396,7 @@ static capn_ptr read_ptr(struct capn_segment *s, char *d) {
goto err;
}
if (e - s->data > s->len)
if ((size_t)(e - s->data) > s->len)
goto err;
ret.data = d;
@ -666,7 +666,7 @@ static int copy_ptr(struct capn_segment *seg, char *data, struct capn_ptr *t, st
struct capn_segment *cs = c->copylist;
/* need to allocate a struct copy */
if (!cs || cs->len + sizeof(*n) > cs->cap) {
if (!cs || cs->len + (int)sizeof(*n) > cs->cap) {
cs = c->create_local ? c->create_local(c->user, sizeof(*n)) : NULL;
if (!cs) {
/* can't allocate a copy structure */