Re-fix signed/unsigned warnings
This commit is contained in:
parent
02268ff818
commit
b55d847db6
5 changed files with 18 additions and 14 deletions
5
Makefile
5
Makefile
|
|
@ -1,7 +1,8 @@
|
||||||
.PHONY: all clean test
|
.PHONY: all clean test
|
||||||
|
|
||||||
LDFLAGS=-O2 -Wall -fPIC
|
LDFLAGS=-O2 -fPIC
|
||||||
CFLAGS=-O2 -Wall -fPIC -I. -Wno-unused-function
|
CFLAGS=-O2 -std=gnu11 -Wall -Wextra -fPIC -I. \
|
||||||
|
-Wno-unused-function -Wno-missing-field-initializers -Wno-unused-parameter
|
||||||
ifneq (,$(findstring gcc, $(CC)))
|
ifneq (,$(findstring gcc, $(CC)))
|
||||||
# gcc's maybe-unintialized is too imprecise, disable it.
|
# gcc's maybe-unintialized is too imprecise, disable it.
|
||||||
# clang disbles this functionality by default and doesn't recognize the flag.
|
# clang disbles this functionality by default and doesn't recognize the flag.
|
||||||
|
|
|
||||||
|
|
@ -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)
|
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[0] = capn_flip32(c->segnum - 1);
|
||||||
header[headerlen-1] = 0; /* Zero out the spare position in the header sizes */
|
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)
|
static int _write_fd(ssize_t (*write_fd)(int fd, void *p, size_t count), int fd, void *p, size_t count)
|
||||||
{
|
{
|
||||||
int ret;
|
ssize_t ret;
|
||||||
int sent = 0;
|
size_t sent = 0;
|
||||||
|
|
||||||
while (sent < count) {
|
while (sent < count) {
|
||||||
ret = write_fd(fd, ((uint8_t*)p)+sent, count-sent);
|
ret = write_fd(fd, ((uint8_t*)p)+sent, count-sent);
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,8 @@ int capn_deflate(struct capn_stream* s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
while (s->avail_in) {
|
while (s->avail_in) {
|
||||||
int i, sz;
|
int i;
|
||||||
|
size_t sz;
|
||||||
uint8_t hdr = 0;
|
uint8_t hdr = 0;
|
||||||
uint8_t *p;
|
uint8_t *p;
|
||||||
|
|
||||||
|
|
@ -105,7 +106,8 @@ int capn_inflate(struct capn_stream* s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
while (s->avail_out) {
|
while (s->avail_out) {
|
||||||
int i, sz;
|
int i;
|
||||||
|
size_t sz;
|
||||||
uint8_t hdr;
|
uint8_t hdr;
|
||||||
|
|
||||||
if (s->zeros > 0) {
|
if (s->zeros > 0) {
|
||||||
|
|
|
||||||
4
capn.c
4
capn.c
|
|
@ -1034,10 +1034,10 @@ capn_ptr capn_new_ptr_list(struct capn_segment *seg, int sz) {
|
||||||
return p;
|
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};
|
capn_ptr p = {CAPN_LIST};
|
||||||
p.seg = seg;
|
p.seg = seg;
|
||||||
p.len = ((sz >= 0) ? sz : strlen(str)) + 1;
|
p.len = ((sz >= 0) ? (size_t)sz : strlen(str)) + 1;
|
||||||
p.datasz = 1;
|
p.datasz = 1;
|
||||||
new_object(&p, p.len);
|
new_object(&p, p.len);
|
||||||
if (p.data) {
|
if (p.data) {
|
||||||
|
|
|
||||||
|
|
@ -656,7 +656,7 @@ static const char *field_name(struct field *f) {
|
||||||
"_Thread_local",
|
"_Thread_local",
|
||||||
};
|
};
|
||||||
|
|
||||||
int i;
|
size_t i;
|
||||||
const char *s = f->f.name.str;
|
const char *s = f->f.name.str;
|
||||||
for (i = 0; i < sizeof(reserved)/sizeof(reserved[0]); i++) {
|
for (i = 0; i < sizeof(reserved)/sizeof(reserved[0]); i++) {
|
||||||
if (!strcmp(s, reserved[i])) {
|
if (!strcmp(s, reserved[i])) {
|
||||||
|
|
@ -1248,13 +1248,14 @@ int main() {
|
||||||
fprintf(srcf, "static const capn_ptr capn_null = {CAPN_NULL};\n");
|
fprintf(srcf, "static const capn_ptr capn_null = {CAPN_NULL};\n");
|
||||||
|
|
||||||
if (g_valseg.len > 8) {
|
if (g_valseg.len > 8) {
|
||||||
|
size_t k;
|
||||||
fprintf(srcf, "static const uint8_t capn_buf[%lu] = {", g_valseg.len-8);
|
fprintf(srcf, "static const uint8_t capn_buf[%lu] = {", g_valseg.len-8);
|
||||||
for (j = 8; j < g_valseg.len; j++) {
|
for (k = 8; k < g_valseg.len; k++) {
|
||||||
if (j > 8)
|
if (k > 8)
|
||||||
fprintf(srcf, ",");
|
fprintf(srcf, ",");
|
||||||
if ((j % 8) == 0)
|
if ((k % 8) == 0)
|
||||||
fprintf(srcf, "\n\t");
|
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");
|
fprintf(srcf, "\n};\n");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue