diff options
author | EuAndreh <eu@euandre.org> | 2024-04-06 11:42:57 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-04-06 11:42:57 -0300 |
commit | c05302791c128c7e29cd4beabfbcd8ce8036390a (patch) | |
tree | 22f85849cd2ed8c135182a85dffa45be69c03bec | |
parent | Start "rc = -1" instead of 0 (diff) | |
download | pindaiba-c05302791c128c7e29cd4beabfbcd8ce8036390a.tar.gz pindaiba-c05302791c128c7e29cd4beabfbcd8ce8036390a.tar.xz |
src/: Check "if (x != NULL)" instead of "if (x)"
-rw-r--r-- | src/catalog.c | 8 | ||||
-rw-r--r-- | src/random.c | 4 | ||||
-rw-r--r-- | src/testing.c | 2 |
3 files changed, 7 insertions, 7 deletions
diff --git a/src/catalog.c b/src/catalog.c index 6c3bdad..03c400d 100644 --- a/src/catalog.c +++ b/src/catalog.c @@ -37,7 +37,7 @@ i18n_init(void) { } catalog_descriptor = catopen(CATALOG_NAME, 0); - if (catalog_descriptor && catalog_descriptor == (nl_catd)-1) { + if (catalog_descriptor != NULL && catalog_descriptor == (nl_catd)-1) { logerr("catopen(\"%s\", 0): %s\n", CATALOG_NAME, strerror(errno)); catalog_descriptor = NULL; goto out; @@ -52,7 +52,7 @@ int i18n_destroy(void) { int rc = -1; - if (catalog_descriptor) { + if (catalog_descriptor != NULL) { if (catclose(catalog_descriptor)) { logerr("catclose(...): %s\n", strerror(errno)); goto out; @@ -61,7 +61,7 @@ i18n_destroy(void) { rc = 0; out: - if (catalog_descriptor) { + if (catalog_descriptor != NULL) { catalog_descriptor = NULL; } return rc; @@ -75,7 +75,7 @@ s(const char* const MSGS[], const int msg_id) { assert(msg_id > 0); // FIXME: assert within bounds! // printf("sizeof(MSGS): %ld\n", sizeof(MSGS)); - if (!catalog_descriptor) { + if (catalog_descriptor == NULL) { return MSGS[msg_id]; } diff --git a/src/random.c b/src/random.c index 7574074..fa87cbb 100644 --- a/src/random.c +++ b/src/random.c @@ -18,7 +18,7 @@ urandom_bytes(const size_t n, uint8_t (*const addr)[]) { FILE *f = NULL; f = fopen("/dev/urandom", "r"); - if (!f) { + if (f == NULL) { logerr("fopen(\"/dev/urandom\", \"r\"): %s\n", strerror(errno)); goto out; } @@ -32,7 +32,7 @@ urandom_bytes(const size_t n, uint8_t (*const addr)[]) { rc = 0; out: - if (f) { + if (f != NULL) { if (fclose(f)) { logerr("fclose(f): %s\n", strerror(errno)); rc = -1; diff --git a/src/testing.c b/src/testing.c index b554ab9..aa58bc7 100644 --- a/src/testing.c +++ b/src/testing.c @@ -18,7 +18,7 @@ ENVVAR_NAME = "NO_COLOR"; static bool show_colour(void) { const char *const no_colour = getenv(ENVVAR_NAME); - return !no_colour || no_colour[0] == '\0'; + return (no_colour != NULL) && (no_colour[0] != '\0'); } void |