From d37dc68693cc6282388fd804fe40d2f9fb6c3649 Mon Sep 17 00:00:00 2001 From: Jens Remus Date: Mon, 8 Apr 2019 13:05:47 +0200 Subject: [PATCH] util_path: Get rid of "? true : false" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The functions use the C99 _Bool type in form of the alias bool from stdbool.h as return type. Scalars are implicitly converted to _Bool. Values equal to zero to 0 (false). Nonzero values to 1 (true). Therefore the explicit conversion using the ternary operator ?: with true and false is not required. Signed-off-by: Jens Remus Reviewed-by: Jan Hoeppner Signed-off-by: Jan Höppner --- libutil/util_path.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libutil/util_path.c b/libutil/util_path.c index 25ed5931..8d8b1e39 100644 --- a/libutil/util_path.c +++ b/libutil/util_path.c @@ -107,7 +107,7 @@ bool util_path_is_readable(const char *fmt, ...) bool rc; UTIL_VASPRINTF(&path, fmt, ap); - rc = access(path, R_OK) == 0 ? true : false; + rc = access(path, R_OK) == 0; free(path); return rc; @@ -131,7 +131,7 @@ bool util_path_is_writable(const char *fmt, ...) bool rc; UTIL_VASPRINTF(&path, fmt, ap); - rc = access(path, W_OK) == 0 ? true : false; + rc = access(path, W_OK) == 0; free(path); return rc; @@ -157,7 +157,7 @@ bool util_path_is_reg_file(const char *fmt, ...) UTIL_VASPRINTF(&path, fmt, ap); if (stat(path, &sb) == 0) - rc = S_ISREG(sb.st_mode) ? true : false; + rc = S_ISREG(sb.st_mode); free(path); return rc; } @@ -182,7 +182,7 @@ bool util_path_is_dir(const char *fmt, ...) UTIL_VASPRINTF(&path, fmt, ap); if (stat(path, &sb) == 0) - rc = S_ISDIR(sb.st_mode) ? true : false; + rc = S_ISDIR(sb.st_mode); free(path); return rc; } @@ -205,7 +205,7 @@ bool util_path_exists(const char *fmt, ...) bool rc; UTIL_VASPRINTF(&path, fmt, ap); - rc = access(path, F_OK) == 0 ? true : false; + rc = access(path, F_OK) == 0; free(path); return rc; }