summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2015-09-28 20:45:13 +0200
committerLinus Nordberg <linus@nordu.net>2015-11-11 13:32:37 +0100
commit3f0bd65b14d6441bc9c0bbf2d58f94a40eb282f3 (patch)
tree7dbc7a843367ece573f7f6aa6869a8b412ce4553
parent2524eac4f82fd6808cc771884ef7442645f95100 (diff)
Remove warnings on Linux
-rw-r--r--c_src/Makefile2
-rw-r--r--c_src/permdb.c16
2 files changed, 11 insertions, 7 deletions
diff --git a/c_src/Makefile b/c_src/Makefile
index 7c69de5..aa380cb 100644
--- a/c_src/Makefile
+++ b/c_src/Makefile
@@ -1,5 +1,5 @@
CC = gcc
-CFLAGS = -Wall -Werror
+CFLAGS = -Wall -Werror -std=gnu99
LDFLAGS =
PORTS = fsynchelper hsmhelper permdbport
diff --git a/c_src/permdb.c b/c_src/permdb.c
index ccac2f5..6267c51 100644
--- a/c_src/permdb.c
+++ b/c_src/permdb.c
@@ -51,7 +51,7 @@ void
print_entry(node_object node)
{
for (int i = 0; i < entriespernode; i++) {
- fprintf(stderr, " %016llx", node.data[i]);
+ fprintf(stderr, " %016llx", (long long unsigned int)node.data[i]);
}
fprintf(stderr, "\n");
}
@@ -417,6 +417,10 @@ set_error(permdb_object *state, const char *format, ...)
va_start(args, format);
char *formatted = NULL;
ret = vasprintf (&formatted, format, args);
+ if (ret == -1) {
+ fprintf(stderr, "vasprintf error\n");
+ return;
+ }
if (state->error) {
free(state->error);
}
@@ -454,20 +458,20 @@ read_internal_data(permdb_object *state, node_offset offset, unsigned int length
if (offset >= file->filesize) {
node_offset writebufferoffset = offset - file->filesize;
if (offset + length > file->datasize) {
- set_error(state, "pread: not enough data for offset %llu and length %u\n", offset, length);
+ set_error(state, "pread: not enough data for offset %llu and length %u\n", (long long unsigned int) offset, length);
return NULL;
}
memcpy(result, file->writebuffer + writebufferoffset, length);
} else {
if (offset + length > file->filesize) {
- set_error(state, "pread: trying to read over file/writebuffer boundary for offset %llu and length %u\n", offset, length);
+ set_error(state, "pread: trying to read over file/writebuffer boundary for offset %llu and length %u\n", (long long unsigned int) offset, length);
return NULL;
}
int ret = pread(file->fd, result, length, offset);
if (ret != length) {
free(result);
- set_error(state, "short pread: %u (wanted %u) at offset %llu\n", ret, length, offset);
+ set_error(state, "short pread: %u (wanted %u) at offset %llu\n", ret, length, (long long unsigned int) offset);
return NULL;
}
}
@@ -514,7 +518,7 @@ readnode(permdb_object *state, node_offset offset, const char *cachekey)
int ret = pread(state->indexfile.fd, buffer, length, offset);
if (ret != length) {
free(buffer);
- set_error(state, "node not present at %llu: length %d\n", offset, ret);
+ set_error(state, "node not present at %llu: length %d\n", (long long unsigned int) offset, ret);
return nullnode;
}
@@ -574,7 +578,7 @@ getpath(permdb_object *state, const char *key, struct nodelist *nodes)
node_object node = readnode(state, rootoffset, "");
if (isnullnode(node)) {
- fprintf(stderr, "cannot find root node at offset %llu (lastcommit %llu)\n", rootoffset, state->indexfile.lastcommit);
+ fprintf(stderr, "cannot find root node at offset %llu (lastcommit %llu)\n", (long long unsigned int) rootoffset, (long long unsigned int) state->indexfile.lastcommit);
if (nodes->pos >= nodes->len) {
fprintf(stderr, "tried to write after end of allocated list\n");
return -1;