// Data mapped into memory
char* data;
- off_t length;
+ ssize_t length;
struct loc_stringpool* pool;
static inline int __loc_database_check_boundaries(struct loc_database* db,
const char* p, const size_t length) {
- size_t offset = p - db->data;
+ ssize_t offset = p - db->data;
// Return if everything is within the boundary
- if (offset <= db->length - length)
+ if (offset <= (ssize_t)(db->length - length))
return 1;
DEBUG(db->ctx, "Database read check failed at %p for %zu byte(s)\n", p, length);
- DEBUG(db->ctx, " p = %p (offset = %lu, length = %zu)\n", p, offset, length);
+ DEBUG(db->ctx, " p = %p (offset = %zd, length = %zu)\n", p, offset, length);
DEBUG(db->ctx, " data = %p (length = %zd)\n", db->data, db->length);
DEBUG(db->ctx, " end = %p\n", db->data + db->length);
- DEBUG(db->ctx, " overflow of %zu byte(s)\n", offset + length - db->length);
+ DEBUG(db->ctx, " overflow of %zd byte(s)\n", (ssize_t)(offset + length - db->length));
// Otherwise raise EFAULT
errno = EFAULT;
if (!n1->prefix || !n2->prefix)
return 0;
- const unsigned int prefix = loc_network_prefix(n1);
+ const size_t prefix = loc_network_prefix(n1);
// How many bits do we need to represent this address?
const size_t bitlength = loc_address_bit_length(&n1->first_address);
// We cannot shorten this any more
if (bitlength >= prefix) {
- DEBUG(n1->ctx, "Cannot shorten this any further because we need at least %lu bits,"
- " but only have %u\n", bitlength, prefix);
+ DEBUG(n1->ctx, "Cannot shorten this any further because we need at least %zu bits,"
+ " but only have %zu\n", bitlength, prefix);
return 0;
}
};
static int loc_stringpool_grow(struct loc_stringpool* pool, const size_t size) {
- DEBUG(pool->ctx, "Growing string pool by %lu byte(s)\n", size);
+ DEBUG(pool->ctx, "Growing string pool by %zu byte(s)\n", size);
// Increment size
pool->size += size;
p->data = data;
p->length = length;
- DEBUG(p->ctx, "Opened string pool at %p (%jd bytes)\n", p->data, p->length);
+ DEBUG(p->ctx, "Opened string pool at %p (%zd bytes)\n", p->data, p->length);
*pool = p;
return 0;