summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2024-05-24 20:45:54 -0300
committerEuAndreh <eu@euandre.org>2024-05-24 20:59:27 -0300
commit48939391bdb9dd53ac2e664568e5991a9bc47543 (patch)
treec89d66e310e10e6de95f1fc45eb97a1e6c283c7b /src
parentsrc/vector.h: Add implementation and tests for vector_contains() (diff)
downloadpindaiba-48939391bdb9dd53ac2e664568e5991a9bc47543.tar.gz
pindaiba-48939391bdb9dd53ac2e664568e5991a9bc47543.tar.xz
Remove all remaining calls to logerr() that included a trailing newline
Diffstat (limited to 'src')
-rw-r--r--src/catalog.c23
-rw-r--r--src/lib.c2
-rw-r--r--src/random.c11
-rw-r--r--src/util.c14
-rw-r--r--src/vector.c10
5 files changed, 26 insertions, 34 deletions
diff --git a/src/catalog.c b/src/catalog.c
index 03c400d..8ddfaee 100644
--- a/src/catalog.c
+++ b/src/catalog.c
@@ -31,14 +31,13 @@ i18n_init(void) {
static const int should_overwrite = 0;
if (setenv(NLSPATH_KEY, NLSPATH, should_overwrite)) {
- logerr("setenv(\"%s\", \"%s\", 0): %s\n", NLSPATH_KEY,
- NLSPATH, strerror(errno));
+ logerr("setenv(): %s", strerror(errno));
goto out;
}
catalog_descriptor = catopen(CATALOG_NAME, 0);
if (catalog_descriptor != NULL && catalog_descriptor == (nl_catd)-1) {
- logerr("catopen(\"%s\", 0): %s\n", CATALOG_NAME, strerror(errno));
+ logerr("catopen(): %s", strerror(errno));
catalog_descriptor = NULL;
goto out;
}
@@ -54,7 +53,7 @@ i18n_destroy(void) {
if (catalog_descriptor != NULL) {
if (catclose(catalog_descriptor)) {
- logerr("catclose(...): %s\n", strerror(errno));
+ logerr("catclose(): %s", strerror(errno));
goto out;
}
}
@@ -83,7 +82,7 @@ s(const char* const MSGS[], const int msg_id) {
const char *const ret =
catgets(catalog_descriptor, NL_SETD, msg_id, MSGS[msg_id]);
if (errno) {
- logerr("catgets(%d): %s\n", msg_id, strerror(errno));
+ logerr("catgets(): %s", strerror(errno));
}
return ret;
@@ -100,8 +99,7 @@ s_print_msgs(
for (int i = msg_begin; i <= msg_end; i++) {
if (fprintf(stream, "%s", s(MSGS, i)) < 0) {
- logerr("fprintf(stream, \"%%s\", _(%d)): %s\n", i,
- strerror(errno));
+ logerr("fprintf(): %s", strerror(errno));
goto out;
}
}
@@ -122,29 +120,26 @@ dump_translatable_strings(const char *const MSGS[]) {
for (size_t i = 1; MSGS[i]; i++) {
if (printf("%ld ", i) < 0) {
- logerr("printf(\"%%ld\", %d): %s\n", i);
+ logerr("printf(): %s", strerror(errno));
goto out;
}
for (size_t j = 0; MSGS[i][j]; j++) {
if (MSGS[i][j] == '\n') {
if (printf("\\n") < 0) {
- logerr("printf(\"\\\\n\"): %s\n",
- strerror(errno));
+ logerr("printf(): %s", strerror(errno));
goto out;
}
} else {
if (printf("%c", MSGS[i][j]) < 0) {
- logerr("printf(\"%%c\", "
- "MSGS[%ld][%ld]): %s\n",
- i, j, strerror(errno));
+ logerr("printf(): %s", strerror(errno));
goto out;
}
}
}
if (printf("\n\n") < 0) {
- logerr("printf(\"\\n\\n\"): %s\n", strerror(errno));
+ logerr("printf(): %s", strerror(errno));
goto out;
}
}
diff --git a/src/lib.c b/src/lib.c
index 8d06ee0..eb22734 100644
--- a/src/lib.c
+++ b/src/lib.c
@@ -17,7 +17,7 @@ pindaiba_main(int argc, char *argv[]) {
(void)argv;
if (printf("%s %s %s\n", NAME, VERSION, DATE) < 0) {
- logerr("printf() < 0: %s\n", strerror(errno));
+ logerr("printf(): %s", strerror(errno));
goto out;
}
diff --git a/src/random.c b/src/random.c
index 648ec9f..2f9f731 100644
--- a/src/random.c
+++ b/src/random.c
@@ -18,30 +18,31 @@ int
urandom_bytes(const size_t n, uint8_t (*const addr)[]) {
int rc = -1;
+ // FIXME: rename ret
uint8_t *temp = NULL;
FILE *f = NULL;
temp = malloc(n);
if (temp == NULL) {
- logerr("malloc(...): %s\n", strerror(errno));
+ logerr("malloc(): %s", strerror(errno));
goto out;
}
f = fopen("/dev/urandom", "r");
if (f == NULL) {
- logerr("fopen(...): %s\n", strerror(errno));
+ logerr("fopen(): %s", strerror(errno));
goto out;
}
const size_t read_count = fread(temp, 1, n, f);
if (ferror(f)) {
- logerr("fread(...), n, f): %s\n", strerror(errno));
+ logerr("fread(): %s", strerror(errno));
goto out;
}
assert(read_count == n);
if (fclose(f)) {
- logerr("fclose(...): %s\n", strerror(errno));
+ logerr("fclose(): %s", strerror(errno));
goto out;
}
f = NULL;
@@ -51,7 +52,7 @@ urandom_bytes(const size_t n, uint8_t (*const addr)[]) {
out:
if (f != NULL) {
if (fclose(f)) {
- logerr("fclose(...): %s\n", strerror(errno));
+ logerr("fclose(): %s", strerror(errno));
rc = -1;
}
}
diff --git a/src/util.c b/src/util.c
index 33307a6..e7a3823 100644
--- a/src/util.c
+++ b/src/util.c
@@ -22,18 +22,18 @@ slurp(const char *const filename, char **out) {
file = fopen(filename, "r");
if (file == NULL) {
- logerr("fopen(\"%s\"): %s\n", filename, strerror(errno));
+ logerr("fopen(): %s", strerror(errno));
goto out;
}
if (fseek(file, 0L, SEEK_END)) {
- logerr("fseek(): %s\n", strerror(errno));
+ logerr("fseek(): %s", strerror(errno));
goto out;
}
const long lsize = ftell(file);
if (lsize == -1) {
- logerr("ftell(): %s\n", strerror(errno));
+ logerr("ftell(): %s", strerror(errno));
goto out;
}
const size_t size = (size_t)lsize;
@@ -41,18 +41,18 @@ slurp(const char *const filename, char **out) {
errno = 0;
rewind(file);
if (errno) {
- logerr("rewind(file): %s\n", strerror(errno));
+ logerr("rewind(): %s", strerror(errno));
goto out;
}
str = malloc(size + NULL_TERMINATOR);
if (str == NULL) {
- logerr("malloc(%ld): %s\n", size + NULL_TERMINATOR, strerror(errno));
+ logerr("malloc(): %s", strerror(errno));
goto out;
}
if (fread(str, sizeof(char), size, file) != size) {
- logerr("fread(\"%s\"): %s\n", filename, strerror(errno));
+ logerr("fread(): %s", strerror(errno));
goto out;
}
str[size] = '\0';
@@ -62,7 +62,7 @@ slurp(const char *const filename, char **out) {
out:
if (file != NULL) {
if (fclose(file)) {
- logerr("fclose(\"%s\"): %s\n", filename, strerror(errno));
+ logerr("fclose(): %s", strerror(errno));
rc = -1;
}
}
diff --git a/src/vector.c b/src/vector.c
index 9634630..7304942 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -70,13 +70,13 @@ vector_new_with(
const size_t array_bytes_size = capacity * value_size;
v.values = malloc(array_bytes_size);
if (v.values == NULL) {
- logerr("malloc(%ld): %s\n", array_bytes_size, strerror(errno));
+ logerr("malloc(): %s", strerror(errno));
goto out;
}
ret = malloc(sizeof(*ret));
if (ret == NULL) {
- logerr("malloc(%ld): %s\n", sizeof(ret), strerror(errno));
+ logerr("malloc(): %s", strerror(errno));
goto out;
}
memcpy(ret, &v, sizeof(v));
@@ -182,11 +182,7 @@ vector_push_back(const struct Vector *const v, const void *const value) {
new_values = realloc(v->values, new_size);
if (new_values == NULL) {
- logerr(
- "realloc(v->values, %ld): %s\n",
- new_size,
- strerror(errno)
- );
+ logerr("realloc(): %s", strerror(errno));
goto out;
}
v_mut->capacity = new_capacity;