Re-fix signed/unsigned warnings

This commit is contained in:
David Lamparter 2016-02-28 12:42:52 +01:00
parent 02268ff818
commit b55d847db6
5 changed files with 18 additions and 14 deletions

View file

@ -1,7 +1,8 @@
.PHONY: all clean test
LDFLAGS=-O2 -Wall -fPIC
CFLAGS=-O2 -Wall -fPIC -I. -Wno-unused-function
LDFLAGS=-O2 -fPIC
CFLAGS=-O2 -std=gnu11 -Wall -Wextra -fPIC -I. \
-Wno-unused-function -Wno-missing-field-initializers -Wno-unused-parameter
ifneq (,$(findstring gcc, $(CC)))
# gcc's maybe-unintialized is too imprecise, disable it.
# clang disbles this functionality by default and doesn't recognize the flag.

View file

@ -190,7 +190,7 @@ static void header_calc(struct capn *c, uint32_t *headerlen, size_t *headersz)
static int header_render(struct capn *c, struct capn_segment *seg, uint32_t *header, uint32_t headerlen, size_t *datasz)
{
int i;
size_t i;
header[0] = capn_flip32(c->segnum - 1);
header[headerlen-1] = 0; /* Zero out the spare position in the header sizes */
@ -291,8 +291,8 @@ capn_write_mem(struct capn *c, uint8_t *p, size_t sz, int packed)
static int _write_fd(ssize_t (*write_fd)(int fd, void *p, size_t count), int fd, void *p, size_t count)
{
int ret;
int sent = 0;
ssize_t ret;
size_t sent = 0;
while (sent < count) {
ret = write_fd(fd, ((uint8_t*)p)+sent, count-sent);

View file

@ -12,7 +12,8 @@ int capn_deflate(struct capn_stream* s) {
}
while (s->avail_in) {
int i, sz;
int i;
size_t sz;
uint8_t hdr = 0;
uint8_t *p;
@ -105,7 +106,8 @@ int capn_inflate(struct capn_stream* s) {
}
while (s->avail_out) {
int i, sz;
int i;
size_t sz;
uint8_t hdr;
if (s->zeros > 0) {

4
capn.c
View file

@ -1034,10 +1034,10 @@ capn_ptr capn_new_ptr_list(struct capn_segment *seg, int sz) {
return p;
}
capn_ptr capn_new_string(struct capn_segment *seg, const char *str, int sz) {
capn_ptr capn_new_string(struct capn_segment *seg, const char *str, ssize_t sz) {
capn_ptr p = {CAPN_LIST};
p.seg = seg;
p.len = ((sz >= 0) ? sz : strlen(str)) + 1;
p.len = ((sz >= 0) ? (size_t)sz : strlen(str)) + 1;
p.datasz = 1;
new_object(&p, p.len);
if (p.data) {

View file

@ -656,7 +656,7 @@ static const char *field_name(struct field *f) {
"_Thread_local",
};
int i;
size_t i;
const char *s = f->f.name.str;
for (i = 0; i < sizeof(reserved)/sizeof(reserved[0]); i++) {
if (!strcmp(s, reserved[i])) {
@ -1248,13 +1248,14 @@ int main() {
fprintf(srcf, "static const capn_ptr capn_null = {CAPN_NULL};\n");
if (g_valseg.len > 8) {
size_t k;
fprintf(srcf, "static const uint8_t capn_buf[%lu] = {", g_valseg.len-8);
for (j = 8; j < g_valseg.len; j++) {
if (j > 8)
for (k = 8; k < g_valseg.len; k++) {
if (k > 8)
fprintf(srcf, ",");
if ((j % 8) == 0)
if ((k % 8) == 0)
fprintf(srcf, "\n\t");
fprintf(srcf, "%u", ((uint8_t*)g_valseg.data)[j]);
fprintf(srcf, "%u", ((uint8_t*)g_valseg.data)[k]);
}
fprintf(srcf, "\n};\n");