Commit 5c57de03 authored by Michael Tremer's avatar Michael Tremer

Format off_t data types properly for printing

Signed-off-by: default avatarMichael Tremer <michael.tremer@ipfire.org>
parent 42f3ccd7
...@@ -136,7 +136,7 @@ static int loc_database_read_as_section_v0(struct loc_database* db, ...@@ -136,7 +136,7 @@ static int loc_database_read_as_section_v0(struct loc_database* db,
off_t as_offset = be32toh(header->as_offset); off_t as_offset = be32toh(header->as_offset);
size_t as_length = be32toh(header->as_length); size_t as_length = be32toh(header->as_length);
DEBUG(db->ctx, "Reading AS section from %jd (%zu bytes)\n", as_offset, as_length); DEBUG(db->ctx, "Reading AS section from %jd (%zu bytes)\n", (intmax_t)as_offset, as_length);
if (as_length > 0) { if (as_length > 0) {
db->as_v0 = mmap(NULL, as_length, PROT_READ, db->as_v0 = mmap(NULL, as_length, PROT_READ,
...@@ -159,7 +159,7 @@ static int loc_database_read_network_nodes_section_v0(struct loc_database* db, ...@@ -159,7 +159,7 @@ static int loc_database_read_network_nodes_section_v0(struct loc_database* db,
size_t network_nodes_length = be32toh(header->network_tree_length); size_t network_nodes_length = be32toh(header->network_tree_length);
DEBUG(db->ctx, "Reading network nodes section from %jd (%zu bytes)\n", DEBUG(db->ctx, "Reading network nodes section from %jd (%zu bytes)\n",
network_nodes_offset, network_nodes_length); (intmax_t)network_nodes_offset, network_nodes_length);
if (network_nodes_length > 0) { if (network_nodes_length > 0) {
db->network_nodes_v0 = mmap(NULL, network_nodes_length, PROT_READ, db->network_nodes_v0 = mmap(NULL, network_nodes_length, PROT_READ,
...@@ -182,7 +182,7 @@ static int loc_database_read_networks_section_v0(struct loc_database* db, ...@@ -182,7 +182,7 @@ static int loc_database_read_networks_section_v0(struct loc_database* db,
size_t networks_length = be32toh(header->network_data_length); size_t networks_length = be32toh(header->network_data_length);
DEBUG(db->ctx, "Reading networks section from %jd (%zu bytes)\n", DEBUG(db->ctx, "Reading networks section from %jd (%zu bytes)\n",
networks_offset, networks_length); (intmax_t)networks_offset, networks_length);
if (networks_length > 0) { if (networks_length > 0) {
db->networks_v0 = mmap(NULL, networks_length, PROT_READ, db->networks_v0 = mmap(NULL, networks_length, PROT_READ,
...@@ -401,7 +401,7 @@ static int loc_database_fetch_as(struct loc_database* db, struct loc_as** as, of ...@@ -401,7 +401,7 @@ static int loc_database_fetch_as(struct loc_database* db, struct loc_as** as, of
if ((size_t)pos >= db->as_count) if ((size_t)pos >= db->as_count)
return -EINVAL; return -EINVAL;
DEBUG(db->ctx, "Fetching AS at position %jd\n", pos); DEBUG(db->ctx, "Fetching AS at position %jd\n", (intmax_t)pos);
int r; int r;
switch (db->version) { switch (db->version) {
...@@ -470,7 +470,7 @@ static int loc_database_fetch_network(struct loc_database* db, struct loc_networ ...@@ -470,7 +470,7 @@ static int loc_database_fetch_network(struct loc_database* db, struct loc_networ
if ((size_t)pos >= db->networks_count) if ((size_t)pos >= db->networks_count)
return -EINVAL; return -EINVAL;
DEBUG(db->ctx, "Fetching network at position %jd\n", pos); DEBUG(db->ctx, "Fetching network at position %jd\n", (intmax_t)pos);
int r; int r;
switch (db->version) { switch (db->version) {
...@@ -501,13 +501,13 @@ static int __loc_database_lookup_handle_leaf(struct loc_database* db, const stru ...@@ -501,13 +501,13 @@ static int __loc_database_lookup_handle_leaf(struct loc_database* db, const stru
const struct loc_database_network_node_v0* node) { const struct loc_database_network_node_v0* node) {
off_t network_index = be32toh(node->network); off_t network_index = be32toh(node->network);
DEBUG(db->ctx, "Handling leaf node at %jd (%jd)\n", node - db->network_nodes_v0, network_index); DEBUG(db->ctx, "Handling leaf node at %jd (%jd)\n", (intmax_t)(node - db->network_nodes_v0), (intmax_t)network_index);
// Fetch the network // Fetch the network
int r = loc_database_fetch_network(db, network, int r = loc_database_fetch_network(db, network,
network_address, prefix, network_index); network_address, prefix, network_index);
if (r) { if (r) {
ERROR(db->ctx, "Could not fetch network %jd from database\n", network_index); ERROR(db->ctx, "Could not fetch network %jd from database\n", (intmax_t)network_index);
return r; return r;
} }
......
...@@ -68,7 +68,7 @@ static int loc_stringpool_mmap(struct loc_stringpool* pool, FILE* f, size_t leng ...@@ -68,7 +68,7 @@ static int loc_stringpool_mmap(struct loc_stringpool* pool, FILE* f, size_t leng
if (pool->mode != STRINGPOOL_MMAP) if (pool->mode != STRINGPOOL_MMAP)
return -EINVAL; return -EINVAL;
DEBUG(pool->ctx, "Reading string pool starting from %zu (%zu bytes)\n", offset, length); DEBUG(pool->ctx, "Reading string pool starting from %jd (%zu bytes)\n", (intmax_t)offset, length);
// Map file content into memory // Map file content into memory
pool->data = pool->pos = mmap(NULL, length, PROT_READ, pool->data = pool->pos = mmap(NULL, length, PROT_READ,
...@@ -236,7 +236,7 @@ static off_t loc_stringpool_append(struct loc_stringpool* pool, const char* stri ...@@ -236,7 +236,7 @@ static off_t loc_stringpool_append(struct loc_stringpool* pool, const char* stri
LOC_EXPORT off_t loc_stringpool_add(struct loc_stringpool* pool, const char* string) { LOC_EXPORT off_t loc_stringpool_add(struct loc_stringpool* pool, const char* string) {
off_t offset = loc_stringpool_find(pool, string); off_t offset = loc_stringpool_find(pool, string);
if (offset >= 0) { if (offset >= 0) {
DEBUG(pool->ctx, "Found '%s' at position %jd\n", string, offset); DEBUG(pool->ctx, "Found '%s' at position %jd\n", string, (intmax_t)offset);
return offset; return offset;
} }
...@@ -251,7 +251,7 @@ LOC_EXPORT void loc_stringpool_dump(struct loc_stringpool* pool) { ...@@ -251,7 +251,7 @@ LOC_EXPORT void loc_stringpool_dump(struct loc_stringpool* pool) {
if (!string) if (!string)
break; break;
printf("%jd (%zu): %s\n", offset, strlen(string), string); printf("%jd (%zu): %s\n", (intmax_t)offset, strlen(string), string);
offset = loc_stringpool_get_next_offset(pool, offset); offset = loc_stringpool_get_next_offset(pool, offset);
} }
......
...@@ -235,7 +235,7 @@ static void align_page_boundary(off_t* offset, FILE* f) { ...@@ -235,7 +235,7 @@ static void align_page_boundary(off_t* offset, FILE* f) {
static int loc_database_write_pool(struct loc_writer* writer, static int loc_database_write_pool(struct loc_writer* writer,
struct loc_database_header_v0* header, off_t* offset, FILE* f) { struct loc_database_header_v0* header, off_t* offset, FILE* f) {
// Save the offset of the pool section // Save the offset of the pool section
DEBUG(writer->ctx, "Pool starts at %jd bytes\n", *offset); DEBUG(writer->ctx, "Pool starts at %jd bytes\n", (intmax_t)*offset);
header->pool_offset = htobe32(*offset); header->pool_offset = htobe32(*offset);
// Write the pool // Write the pool
...@@ -250,7 +250,7 @@ static int loc_database_write_pool(struct loc_writer* writer, ...@@ -250,7 +250,7 @@ static int loc_database_write_pool(struct loc_writer* writer,
static int loc_database_write_as_section(struct loc_writer* writer, static int loc_database_write_as_section(struct loc_writer* writer,
struct loc_database_header_v0* header, off_t* offset, FILE* f) { struct loc_database_header_v0* header, off_t* offset, FILE* f) {
DEBUG(writer->ctx, "AS section starts at %jd bytes\n", *offset); DEBUG(writer->ctx, "AS section starts at %jd bytes\n", (intmax_t)*offset);
header->as_offset = htobe32(*offset); header->as_offset = htobe32(*offset);
size_t as_length = 0; size_t as_length = 0;
...@@ -325,7 +325,7 @@ static void free_network(struct network* network) { ...@@ -325,7 +325,7 @@ static void free_network(struct network* network) {
static int loc_database_write_networks(struct loc_writer* writer, static int loc_database_write_networks(struct loc_writer* writer,
struct loc_database_header_v0* header, off_t* offset, FILE* f) { struct loc_database_header_v0* header, off_t* offset, FILE* f) {
// Write the network tree // Write the network tree
DEBUG(writer->ctx, "Network tree starts at %jd bytes\n", *offset); DEBUG(writer->ctx, "Network tree starts at %jd bytes\n", (intmax_t)*offset);
header->network_tree_offset = htobe32(*offset); header->network_tree_offset = htobe32(*offset);
size_t network_tree_length = 0; size_t network_tree_length = 0;
...@@ -415,7 +415,7 @@ static int loc_database_write_networks(struct loc_writer* writer, ...@@ -415,7 +415,7 @@ static int loc_database_write_networks(struct loc_writer* writer,
align_page_boundary(offset, f); align_page_boundary(offset, f);
DEBUG(writer->ctx, "Networks data section starts at %jd bytes\n", *offset); DEBUG(writer->ctx, "Networks data section starts at %jd bytes\n", (intmax_t)*offset);
header->network_data_offset = htobe32(*offset); header->network_data_offset = htobe32(*offset);
// We have now written the entire tree and have all networks // We have now written the entire tree and have all networks
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment