]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
Merge branch 'apple'
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 18 Oct 2019 18:43:59 +0000 (19:43 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 18 Oct 2019 18:43:59 +0000 (19:43 +0100)
1  2 
src/database.c

diff --combined src/database.c
index 862fe75dffdf65a1dedd6be990af1f755c5a85ca,01c52a52e16b2071b4781f6db2b1321e08c16694..3099dfc64172800977c71ea6edb940abc7c1b9ce
@@@ -16,7 -16,6 +16,6 @@@
  
  #include <arpa/inet.h>
  #include <ctype.h>
- #include <endian.h>
  #include <errno.h>
  #include <netinet/in.h>
  #include <stddef.h>
  #include <time.h>
  #include <unistd.h>
  
+ #ifdef HAVE_ENDIAN_H
+ #  include <endian.h>
+ #endif
  #include <loc/libloc.h>
  #include <loc/as.h>
+ #include <loc/compat.h>
  #include <loc/country.h>
  #include <loc/database.h>
  #include <loc/format.h>
@@@ -132,7 -136,7 +136,7 @@@ static int loc_database_read_as_section
        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,
@@@ -155,7 -159,7 +159,7 @@@ static int loc_database_read_network_no
        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,
@@@ -178,7 -182,7 +182,7 @@@ static int loc_database_read_networks_s
        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,
@@@ -397,7 -401,7 +401,7 @@@ static int loc_database_fetch_as(struc
        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) {
@@@ -466,7 -470,7 +470,7 @@@ static int loc_database_fetch_network(s
        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) {
@@@ -497,13 -501,13 +501,13 @@@ static int __loc_database_lookup_handle
                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;
        }
  
@@@ -664,7 -668,7 +668,7 @@@ LOC_EXPORT int loc_database_get_country
                // adjust our search pointers
                loc_country_unref(*country);
  
 -              if (result < 0) {
 +              if (result > 0) {
                        lo = i + 1;
                } else
                        hi = i - 1;