return 1;
DEBUG(db->ctx, "Database read check failed at %p for %zu byte(s)\n", p, length);
- DEBUG(db->ctx, " p = %p (offset = %jd, length = %zu)\n", p, offset, length);
- DEBUG(db->ctx, " data = %p (length = %zu)\n", db->data, db->length);
+ DEBUG(db->ctx, " p = %p (offset = %lu, 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);
return 1;
}
- DEBUG(db->ctx, "Mapped database of %zu byte(s) at %p\n", db->length, db->data);
+ DEBUG(db->ctx, "Mapped database of %zd byte(s) at %p\n", db->length, db->data);
// Tell the system that we expect to read data randomly
r = madvise(db->data, db->length, MADV_RANDOM);
break;
default:
- ERROR(db->ctx, "Cannot compute hash for database with format %d\n",
+ ERROR(db->ctx, "Cannot compute hash for database with format %u\n",
db->version);
r = -EINVAL;
goto CLEANUP;
r = loc_as_match_string(*as, enumerator->string);
if (r == 1) {
- DEBUG(enumerator->ctx, "AS%d (%s) matches %s\n",
+ DEBUG(enumerator->ctx, "AS%u (%s) matches %s\n",
loc_as_get_number(*as), loc_as_get_name(*as), enumerator->string);
return 0;
*network = NULL;
}
- DEBUG(enumerator->ctx, "Called with a stack of %u nodes\n",
+ DEBUG(enumerator->ctx, "Called with a stack of %d nodes\n",
enumerator->network_stack_depth);
// Perform DFS
while (enumerator->network_stack_depth > 0) {
- DEBUG(enumerator->ctx, "Stack depth: %u\n", enumerator->network_stack_depth);
+ DEBUG(enumerator->ctx, "Stack depth: %d\n", enumerator->network_stack_depth);
// Get object from top of the stack
struct loc_node_stack* node = &enumerator->network_stack[enumerator->network_stack_depth];
for (unsigned int i = 0; i < list->size; i++) {
network = list->elements[i];
- INFO(list->ctx, "%4d: %s\n",
+ INFO(list->ctx, "%4u: %s\n",
i, loc_network_str(network));
}
}
// Check if the new prefix is valid
if (!loc_address_valid_prefix(&network->first_address, prefix)) {
- ERROR(network->ctx, "Invalid prefix: %d\n", prefix);
+ ERROR(network->ctx, "Invalid prefix: %u\n", prefix);
errno = EINVAL;
return 1;
}
// We cannot shorten this any more
if (bitlength >= prefix) {
- DEBUG(n1->ctx, "Cannot shorten this any further because we need at least %jd bits,"
- " but only have %d\n", bitlength, prefix);
+ DEBUG(n1->ctx, "Cannot shorten this any further because we need at least %lu bits,"
+ " but only have %u\n", bitlength, prefix);
return 0;
}
uint32_t asn = be32toh(dbobj->asn);
r = loc_network_set_asn(*network, asn);
if (r) {
- ERROR(ctx, "Could not set ASN: %d\n", asn);
+ ERROR(ctx, "Could not set ASN: %u\n", asn);
return r;
}
goto ERROR;
for (unsigned int i = 0; i < (prefix / 4); i++) {
- r = asprintf(&buffer, "%x.%s", loc_address_get_nibble(&network->first_address, i), buffer);
+ r = asprintf(&buffer, "%x.%s",
+ (unsigned int)loc_address_get_nibble(&network->first_address, i), buffer);
if (r < 0)
goto ERROR;
}
}
if (!size || (len = *payload) >= size || !len) {
- ERROR(ctx, "Broken TXT record (len = %d, size = %d)\n", len, size);
+ ERROR(ctx, "Broken TXT record (len = %d, size = %u)\n", len, size);
return -1;
}
};
static int loc_stringpool_grow(struct loc_stringpool* pool, const size_t size) {
- DEBUG(pool->ctx, "Growing string pool by %zu byte(s)\n", size);
+ DEBUG(pool->ctx, "Growing string pool by %lu byte(s)\n", size);
// Increment size
pool->size += size;
p->data = data;
p->length = length;
- DEBUG(p->ctx, "Opened string pool at %p (%zu bytes)\n", p->data, p->length);
+ DEBUG(p->ctx, "Opened string pool at %p (%jd bytes)\n", p->data, p->length);
*pool = p;
return 0;
for (unsigned int i = 0; i < 100; i++) {
s = loc_address_str(&address);
- printf("Iteration %d: %s\n", i, s);
+ printf("Iteration %u: %s\n", i, s);
if (strcmp(s, e) != 0) {
fprintf(stderr, "IP address was formatted in an invalid format: %s\n", s);
for (unsigned int i = 1; i <= 10; i++) {
err = loc_database_get_as(db, &as, i);
if (err) {
- fprintf(stderr, "Could not find AS%d\n", i);
+ fprintf(stderr, "Could not find AS%u\n", i);
exit(EXIT_FAILURE);
}
}
while (as) {
- printf("Found AS%d: %s\n", loc_as_get_number(as), loc_as_get_name(as));
+ printf("Found AS%u: %s\n", loc_as_get_number(as), loc_as_get_name(as));
err = loc_database_enumerator_next_as(enumerator, &as);
if (err) {
free(string);
if (pos < 0) {
- fprintf(stderr, "Could not add string %d: %m\n", i);
+ fprintf(stderr, "Could not add string %u: %m\n", i);
exit(EXIT_FAILURE);
}
}
}
// Write the current node
- DEBUG(writer->ctx, "Writing node %p (0 = %d, 1 = %d)\n",
+ DEBUG(writer->ctx, "Writing node %p (0 = %u, 1 = %u)\n",
node, node->index_zero, node->index_one);
*offset += fwrite(&db_node, 1, sizeof(db_node), f);
break;
default:
- ERROR(writer->ctx, "Invalid database version: %d\n", version);
+ ERROR(writer->ctx, "Invalid database version: %u\n", version);
return -1;
}
- DEBUG(writer->ctx, "Writing database in version %d\n", version);
+ DEBUG(writer->ctx, "Writing database in version %u\n", version);
struct loc_database_magic magic;
make_magic(writer, &magic, version);