[LTP] [PATCH 1/1] tst_cmd: Change tst_check_cmd() return type to int
    Petr Vorel 
    pvorel@suse.cz
       
    Mon Oct 20 16:28:13 CEST 2025
    
    
  
Function use just bool value, no need for int (readability).
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 include/tst_private.h | 2 +-
 lib/tst_cmd.c         | 9 +++++----
 2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/include/tst_private.h b/include/tst_private.h
index 292f7e9366..87ec8829a1 100644
--- a/include/tst_private.h
+++ b/include/tst_private.h
@@ -45,7 +45,7 @@ char tst_kconfig_get(const char *confname);
  * function checks command version whether meets this requirement.
  * If not, case breaks if brk_nosupp is defined.
  */
-int tst_check_cmd(const char *cmd, const int brk_nosupp);
+bool tst_check_cmd(const char *cmd, const int brk_nosupp);
 
 /*
  * Returns NULL-terminated array of kernel-supported filesystems.
diff --git a/lib/tst_cmd.c b/lib/tst_cmd.c
index 82d60497a8..2faf7c7430 100644
--- a/lib/tst_cmd.c
+++ b/lib/tst_cmd.c
@@ -27,6 +27,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <signal.h>
+#include <stdbool.h>
 #include "test.h"
 #include "tst_cmd.h"
 #include "tst_private.h"
@@ -249,7 +250,7 @@ static struct version_parser {
 	{},
 };
 
-int tst_check_cmd(const char *cmd, const int brk_nosupp)
+bool tst_check_cmd(const char *cmd, const int brk_nosupp)
 {
 	struct version_parser *p;
 	char *cmd_token, *op_token, *version_token, *next, *str;
@@ -268,7 +269,7 @@ int tst_check_cmd(const char *cmd, const int brk_nosupp)
 		tst_brkm(TCONF, NULL, "Couldn't find '%s' in $PATH", cmd_token);
 
 	if (!op_token)
-		return 0;
+		return true;
 
 	if (!version_token || str) {
 		tst_brkm(TCONF, NULL,
@@ -318,7 +319,7 @@ int tst_check_cmd(const char *cmd, const int brk_nosupp)
 		tst_brkm(TCONF, NULL, "Invalid op(%s)", op_token);
 	}
 
-	return 0;
+	return true;
 error:
 	if (brk_nosupp) {
 		tst_brkm(TCONF, NULL, "%s requires %s %d, but got %d",
@@ -328,5 +329,5 @@ error:
 			cmd, op_token, ver_get, ver_parser);
 	}
 
-	return 1;
+	return false;
 }
-- 
2.51.0
    
    
More information about the ltp
mailing list