if (db->as_v1) {
r = munmap(db->as_v1, db->as_count * sizeof(*db->as_v1));
if (r)
- ERROR(db->ctx, "Could not unmap AS section: %s\n", strerror(errno));
+ ERROR(db->ctx, "Could not unmap AS section: %m\n");
}
// Remove mapped network sections
if (db->networks_v1) {
r = munmap(db->networks_v1, db->networks_count * sizeof(*db->networks_v1));
if (r)
- ERROR(db->ctx, "Could not unmap networks section: %s\n", strerror(errno));
+ ERROR(db->ctx, "Could not unmap networks section: %m\n");
}
// Remove mapped network nodes section
if (db->network_nodes_v1) {
r = munmap(db->network_nodes_v1, db->network_nodes_count * sizeof(*db->network_nodes_v1));
if (r)
- ERROR(db->ctx, "Could not unmap network nodes section: %s\n", strerror(errno));
+ ERROR(db->ctx, "Could not unmap network nodes section: %m\n");
}
// Remove mapped countries section
if (db->countries_v1) {
r = munmap(db->countries_v1, db->countries_count * sizeof(*db->countries_v1));
if (r)
- ERROR(db->ctx, "Could not unmap countries section: %s\n", strerror(errno));
+ ERROR(db->ctx, "Could not unmap countries section: %m\n");
}
if (db->pool)
// Load public key
EVP_PKEY* pkey = PEM_read_PUBKEY(f, NULL, NULL, NULL);
if (!pkey) {
- char* error = ERR_error_string(ERR_get_error(), NULL);
- ERROR(db->ctx, "Could not parse public key: %s\n", error);
+ ERROR(db->ctx, "Could not parse public key: %s\n",
+ ERR_error_string(ERR_get_error(), NULL));
return -1;
}
FILE* f = fopen(path, "w+");
if (!f) {
- PyErr_Format(PyExc_IOError, strerror(errno));
+ PyErr_SetFromErrno(PyExc_OSError);
return NULL;
}
// Raise any errors
if (r) {
- PyErr_Format(PyExc_IOError, strerror(errno));
+ PyErr_SetFromErrno(PyExc_OSError);
return NULL;
}
if (pool->data) {
r = munmap(pool->data, pool->length);
if (r)
- ERROR(pool->ctx, "Could not unmap data at %p: %s\n",
- pool->data, strerror(errno));
+ ERROR(pool->ctx, "Could not unmap data at %p: %m\n",
+ pool->data);
}
break;
}
FILE* f = tmpfile();
if (!f) {
- fprintf(stderr, "Could not open file for writing: %s\n", strerror(errno));
+ fprintf(stderr, "Could not open file for writing: %m\n");
exit(EXIT_FAILURE);
}
FILE* f = tmpfile();
if (!f) {
- fprintf(stderr, "Could not open file for writing: %s\n", strerror(errno));
+ fprintf(stderr, "Could not open file for writing: %m\n");
exit(EXIT_FAILURE);
}
FILE* f = tmpfile();
if (!f) {
- fprintf(stderr, "Could not open file for writing: %s\n", strerror(errno));
+ fprintf(stderr, "Could not open file for writing: %m\n");
exit(EXIT_FAILURE);
}
FILE* f = tmpfile();
if (!f) {
- fprintf(stderr, "Could not open file for writing: %s\n", strerror(errno));
+ fprintf(stderr, "Could not open file for writing: %m\n");
exit(EXIT_FAILURE);
}
// Open public key
FILE* public_key = fopen(ABS_SRCDIR "/examples/public-key.pem", "r");
if (!public_key) {
- fprintf(stderr, "Could not open public key file: %s\n", strerror(errno));
+ fprintf(stderr, "Could not open public key file: %m\n");
exit(EXIT_FAILURE);
}
// Open private key
FILE* private_key1 = fopen(ABS_SRCDIR "/examples/private-key.pem", "r");
if (!private_key1) {
- fprintf(stderr, "Could not open private key file: %s\n", strerror(errno));
+ fprintf(stderr, "Could not open private key file: %m\n");
exit(EXIT_FAILURE);
}
FILE* private_key2 = fopen(ABS_SRCDIR "/examples/private-key.pem", "r");
if (!private_key2) {
- fprintf(stderr, "Could not open private key file: %s\n", strerror(errno));
+ fprintf(stderr, "Could not open private key file: %m\n");
exit(EXIT_FAILURE);
}
FILE* f = tmpfile();
if (!f) {
- fprintf(stderr, "Could not open file for writing: %s\n", strerror(errno));
+ fprintf(stderr, "Could not open file for writing: %m\n");
exit(EXIT_FAILURE);
}
// Open another public key
public_key = freopen(ABS_SRCDIR "/src/signing-key.pem", "r", public_key);
if (!public_key) {
- fprintf(stderr, "Could not open public key file: %s\n", strerror(errno));
+ fprintf(stderr, "Could not open public key file: %m\n");
exit(EXIT_FAILURE);
}
size_t bytes_read = fread(buffer, 1, sizeof(buffer), f);
if (ferror(f)) {
- ERROR(writer->ctx, "Error reading from file: %s\n", strerror(errno));
+ ERROR(writer->ctx, "Error reading from file: %m\n");
r = errno;
goto END;
}