]> git.ipfire.org Git - location/libloc.git/commitdiff
Format off_t data types properly for printing
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 12 Jan 2019 16:07:31 +0000 (16:07 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 17 Oct 2019 13:25:37 +0000 (14:25 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/database.c
src/stringpool.c
src/writer.c

index 6d39ae16f977cb3dacf9c891a75fa2148c4b4c15..01c52a52e16b2071b4781f6db2b1321e08c16694 100644 (file)
@@ -136,7 +136,7 @@ static int loc_database_read_as_section_v0(struct loc_database* db,
        off_t as_offset  = be32toh(header->as_offset);
        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) {
                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,
        size_t network_nodes_length = be32toh(header->network_tree_length);
 
        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) {
                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,
        size_t networks_length = be32toh(header->network_data_length);
 
        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) {
                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
        if ((size_t)pos >= db->as_count)
                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;
        switch (db->version) {
@@ -470,7 +470,7 @@ static int loc_database_fetch_network(struct loc_database* db, struct loc_networ
        if ((size_t)pos >= db->networks_count)
                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;
        switch (db->version) {
@@ -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) {
        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
        int r = loc_database_fetch_network(db, network,
                network_address, prefix, network_index);
        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;
        }
 
index 6468c5e8f07889aec976601382f706a7c4d38673..e43c4cb3a7fa84b00c449dc49c261fe895a27294 100644 (file)
@@ -68,7 +68,7 @@ static int loc_stringpool_mmap(struct loc_stringpool* pool, FILE* f, size_t leng
        if (pool->mode != STRINGPOOL_MMAP)
                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
        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
 LOC_EXPORT off_t loc_stringpool_add(struct loc_stringpool* pool, const char* string) {
        off_t offset = loc_stringpool_find(pool, string);
        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;
        }
 
@@ -251,7 +251,7 @@ LOC_EXPORT void loc_stringpool_dump(struct loc_stringpool* pool) {
                if (!string)
                        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);
        }
index 594df1a0327672ce072e8099a213aa7a70a57d85..c241e8b49584bf0cb82f7534e78a12255cc5f5e3 100644 (file)
@@ -235,7 +235,7 @@ static void align_page_boundary(off_t* offset, FILE* f) {
 static int loc_database_write_pool(struct loc_writer* writer,
                struct loc_database_header_v0* header, off_t* offset, FILE* f) {
        // 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);
 
        // Write the pool
@@ -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,
                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);
 
        size_t as_length = 0;
@@ -325,7 +325,7 @@ static void free_network(struct network* network) {
 static int loc_database_write_networks(struct loc_writer* writer,
                struct loc_database_header_v0* header, off_t* offset, FILE* f) {
        // 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);
 
        size_t network_tree_length = 0;
@@ -415,7 +415,7 @@ static int loc_database_write_networks(struct loc_writer* writer,
 
        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);
 
        // We have now written the entire tree and have all networks