tst_cmd: Change tst_check_cmd() return type to int
PATCH 1/1 tst_cmd: Change tst_check_cmd() return type to int
Function use just bool value, no need for int (readability).
Signed-off-by Petr Vorel <[email protected]>
--- include/tst_private.h | 2 +- lib/tst_cmd.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-)
include/tst_private.h +1 -1
@@ -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.
lib/tst_cmd.c +5 -4
@@ -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; }
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 4 lines · Petr Vorel
Function use just bool value, no need for int (readability).
Signed-off-by Petr Vorel <[email protected]>
Reviewed-by Li Wang <[email protected]>
---
Quoted 74 lines
include/tst_private.h | 2 +- lib/tst_cmd.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-)include/tst_private.h +1
-1@@ -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. lib/tst_cmd.c +3
-2@@ -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,lib/tst_cmd.c +1
-1@@ -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",
lib/tst_cmd.c +1
-2@@ -328,5 +329,5 @@ error: cmd, op_token, ver_get, ver_parser); } -return 1 ; +return false; } --2.51.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Li,
thanks for your review, merged.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp