Commit 6cd02f1d authored by Michael Tremer's avatar Michael Tremer

Replace strerror(errno) with %m in format string throughout

Signed-off-by: default avatarMichael Tremer <michael.tremer@ipfire.org>
parent 00beb796
...@@ -436,28 +436,28 @@ static void loc_database_free(struct loc_database* db) { ...@@ -436,28 +436,28 @@ static void loc_database_free(struct loc_database* db) {
if (db->as_v1) { if (db->as_v1) {
r = munmap(db->as_v1, db->as_count * sizeof(*db->as_v1)); r = munmap(db->as_v1, db->as_count * sizeof(*db->as_v1));
if (r) 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 // Remove mapped network sections
if (db->networks_v1) { if (db->networks_v1) {
r = munmap(db->networks_v1, db->networks_count * sizeof(*db->networks_v1)); r = munmap(db->networks_v1, db->networks_count * sizeof(*db->networks_v1));
if (r) 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 // Remove mapped network nodes section
if (db->network_nodes_v1) { if (db->network_nodes_v1) {
r = munmap(db->network_nodes_v1, db->network_nodes_count * sizeof(*db->network_nodes_v1)); r = munmap(db->network_nodes_v1, db->network_nodes_count * sizeof(*db->network_nodes_v1));
if (r) 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 // Remove mapped countries section
if (db->countries_v1) { if (db->countries_v1) {
r = munmap(db->countries_v1, db->countries_count * sizeof(*db->countries_v1)); r = munmap(db->countries_v1, db->countries_count * sizeof(*db->countries_v1));
if (r) 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) if (db->pool)
...@@ -498,8 +498,8 @@ LOC_EXPORT int loc_database_verify(struct loc_database* db, FILE* f) { ...@@ -498,8 +498,8 @@ LOC_EXPORT int loc_database_verify(struct loc_database* db, FILE* f) {
// Load public key // Load public key
EVP_PKEY* pkey = PEM_read_PUBKEY(f, NULL, NULL, NULL); EVP_PKEY* pkey = PEM_read_PUBKEY(f, NULL, NULL, NULL);
if (!pkey) { if (!pkey) {
char* error = ERR_error_string(ERR_get_error(), NULL); ERROR(db->ctx, "Could not parse public key: %s\n",
ERROR(db->ctx, "Could not parse public key: %s\n", error); ERR_error_string(ERR_get_error(), NULL));
return -1; return -1;
} }
......
...@@ -227,7 +227,7 @@ static PyObject* Writer_write(WriterObject* self, PyObject* args) { ...@@ -227,7 +227,7 @@ static PyObject* Writer_write(WriterObject* self, PyObject* args) {
FILE* f = fopen(path, "w+"); FILE* f = fopen(path, "w+");
if (!f) { if (!f) {
PyErr_Format(PyExc_IOError, strerror(errno)); PyErr_SetFromErrno(PyExc_OSError);
return NULL; return NULL;
} }
...@@ -236,7 +236,7 @@ static PyObject* Writer_write(WriterObject* self, PyObject* args) { ...@@ -236,7 +236,7 @@ static PyObject* Writer_write(WriterObject* self, PyObject* args) {
// Raise any errors // Raise any errors
if (r) { if (r) {
PyErr_Format(PyExc_IOError, strerror(errno)); PyErr_SetFromErrno(PyExc_OSError);
return NULL; return NULL;
} }
......
...@@ -119,8 +119,8 @@ static void loc_stringpool_free(struct loc_stringpool* pool) { ...@@ -119,8 +119,8 @@ static void loc_stringpool_free(struct loc_stringpool* pool) {
if (pool->data) { if (pool->data) {
r = munmap(pool->data, pool->length); r = munmap(pool->data, pool->length);
if (r) if (r)
ERROR(pool->ctx, "Could not unmap data at %p: %s\n", ERROR(pool->ctx, "Could not unmap data at %p: %m\n",
pool->data, strerror(errno)); pool->data);
} }
break; break;
} }
......
...@@ -55,7 +55,7 @@ int main(int argc, char** argv) { ...@@ -55,7 +55,7 @@ int main(int argc, char** argv) {
FILE* f = tmpfile(); FILE* f = tmpfile();
if (!f) { 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); exit(EXIT_FAILURE);
} }
......
...@@ -124,7 +124,7 @@ int main(int argc, char** argv) { ...@@ -124,7 +124,7 @@ int main(int argc, char** argv) {
FILE* f = tmpfile(); FILE* f = tmpfile();
if (!f) { 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); exit(EXIT_FAILURE);
} }
......
...@@ -167,7 +167,7 @@ int main(int argc, char** argv) { ...@@ -167,7 +167,7 @@ int main(int argc, char** argv) {
FILE* f = tmpfile(); FILE* f = tmpfile();
if (!f) { 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); exit(EXIT_FAILURE);
} }
......
...@@ -260,7 +260,7 @@ int main(int argc, char** argv) { ...@@ -260,7 +260,7 @@ int main(int argc, char** argv) {
FILE* f = tmpfile(); FILE* f = tmpfile();
if (!f) { 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); exit(EXIT_FAILURE);
} }
......
...@@ -34,20 +34,20 @@ int main(int argc, char** argv) { ...@@ -34,20 +34,20 @@ int main(int argc, char** argv) {
// Open public key // Open public key
FILE* public_key = fopen(ABS_SRCDIR "/examples/public-key.pem", "r"); FILE* public_key = fopen(ABS_SRCDIR "/examples/public-key.pem", "r");
if (!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); exit(EXIT_FAILURE);
} }
// Open private key // Open private key
FILE* private_key1 = fopen(ABS_SRCDIR "/examples/private-key.pem", "r"); FILE* private_key1 = fopen(ABS_SRCDIR "/examples/private-key.pem", "r");
if (!private_key1) { 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); exit(EXIT_FAILURE);
} }
FILE* private_key2 = fopen(ABS_SRCDIR "/examples/private-key.pem", "r"); FILE* private_key2 = fopen(ABS_SRCDIR "/examples/private-key.pem", "r");
if (!private_key2) { 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); exit(EXIT_FAILURE);
} }
...@@ -67,7 +67,7 @@ int main(int argc, char** argv) { ...@@ -67,7 +67,7 @@ int main(int argc, char** argv) {
FILE* f = tmpfile(); FILE* f = tmpfile();
if (!f) { 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); exit(EXIT_FAILURE);
} }
...@@ -96,7 +96,7 @@ int main(int argc, char** argv) { ...@@ -96,7 +96,7 @@ int main(int argc, char** argv) {
// Open another public key // Open another public key
public_key = freopen(ABS_SRCDIR "/src/signing-key.pem", "r", public_key); public_key = freopen(ABS_SRCDIR "/src/signing-key.pem", "r", public_key);
if (!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); exit(EXIT_FAILURE);
} }
......
...@@ -583,7 +583,7 @@ static int loc_writer_create_signature(struct loc_writer* writer, ...@@ -583,7 +583,7 @@ static int loc_writer_create_signature(struct loc_writer* writer,
size_t bytes_read = fread(buffer, 1, sizeof(buffer), f); size_t bytes_read = fread(buffer, 1, sizeof(buffer), f);
if (ferror(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; r = errno;
goto END; goto END;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment