diff options
author | EuAndreh <eu@euandre.org> | 2024-04-06 11:37:04 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-04-06 11:37:04 -0300 |
commit | 3b32f5a1abbec9655a93a184ed0a3c5e6e5134fd (patch) | |
tree | 03969b7b76835f2507ccd1a8aeb057bb1d7f7201 /src | |
parent | src/: Remove unused "infallible" tag (diff) | |
download | pindaiba-3b32f5a1abbec9655a93a184ed0a3c5e6e5134fd.tar.gz pindaiba-3b32f5a1abbec9655a93a184ed0a3c5e6e5134fd.tar.xz |
Start "rc = -1" instead of 0
Diffstat (limited to 'src')
-rw-r--r-- | src/catalog.c | 20 | ||||
-rw-r--r-- | src/random.c | 5 |
2 files changed, 10 insertions, 15 deletions
diff --git a/src/catalog.c b/src/catalog.c index e56ca0b..6c3bdad 100644 --- a/src/catalog.c +++ b/src/catalog.c @@ -27,13 +27,12 @@ NLSPATH_KEY = "NLSPATH"; int i18n_init(void) { - int rc = 0; + int rc = -1; 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)); - rc = -1; goto out; } @@ -41,26 +40,26 @@ i18n_init(void) { if (catalog_descriptor && catalog_descriptor == (nl_catd)-1) { logerr("catopen(\"%s\", 0): %s\n", CATALOG_NAME, strerror(errno)); catalog_descriptor = NULL; - rc = -1; goto out; } + rc = 0; out: return rc; } int i18n_destroy(void) { - int rc = 0; + int rc = -1; if (catalog_descriptor) { if (catclose(catalog_descriptor)) { logerr("catclose(...): %s\n", strerror(errno)); - rc = -1; goto out; } } + rc = 0; out: if (catalog_descriptor) { catalog_descriptor = NULL; @@ -97,17 +96,17 @@ s_print_msgs( const int msg_begin, const int msg_end ) { - int rc = 0; + int rc = -1; 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)); - rc = -1; goto out; } } + rc = 0; out: return rc; } @@ -119,12 +118,11 @@ s_print_msg(const char *const MSGS[], FILE *const fd, const int msg_id) { int dump_translatable_strings(const char *const MSGS[]) { - int rc = 0; + int rc = -1; for (size_t i = 1; MSGS[i]; i++) { if (printf("%ld ", i) < 0) { logerr("printf(\"%%ld\", %d): %s\n", i); - rc = -1; goto out; } @@ -133,7 +131,6 @@ dump_translatable_strings(const char *const MSGS[]) { if (printf("\\n") < 0) { logerr("printf(\"\\\\n\"): %s\n", strerror(errno)); - rc = -1; goto out; } } else { @@ -141,7 +138,6 @@ dump_translatable_strings(const char *const MSGS[]) { logerr("printf(\"%%c\", " "MSGS[%ld][%ld]): %s\n", i, j, strerror(errno)); - rc = -1; goto out; } } @@ -149,11 +145,11 @@ dump_translatable_strings(const char *const MSGS[]) { if (printf("\n\n") < 0) { logerr("printf(\"\\n\\n\"): %s\n", strerror(errno)); - rc = -1; goto out; } } + rc = 0; out: return rc; } diff --git a/src/random.c b/src/random.c index 3ec9e24..7574074 100644 --- a/src/random.c +++ b/src/random.c @@ -13,25 +13,24 @@ int urandom_bytes(const size_t n, uint8_t (*const addr)[]) { - int rc = 0; + int rc = -1; FILE *f = NULL; f = fopen("/dev/urandom", "r"); if (!f) { logerr("fopen(\"/dev/urandom\", \"r\"): %s\n", strerror(errno)); - rc = -1; goto out; } const size_t read_count = fread(addr, 1, n, f); if (ferror(f)) { logerr("fread(addr, 1, n, f): %s\n", strerror(errno)); - rc = -1; goto out; } assert(read_count == n); + rc = 0; out: if (f) { if (fclose(f)) { |