* [LTP] [PATCH 1/1] tst_cmd: Change tst_check_cmd() return type to int
@ 2025-10-20 14:28 Petr Vorel
2025-10-22 9:14 ` Li Wang via ltp
0 siblings, 1 reply; 3+ messages in thread
From: Petr Vorel @ 2025-10-20 14:28 UTC (permalink / raw)
To: ltp
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH 1/1] tst_cmd: Change tst_check_cmd() return type to int
2025-10-20 14:28 [LTP] [PATCH 1/1] tst_cmd: Change tst_check_cmd() return type to int Petr Vorel
@ 2025-10-22 9:14 ` Li Wang via ltp
2025-10-22 11:41 ` Petr Vorel
0 siblings, 1 reply; 3+ messages in thread
From: Li Wang via ltp @ 2025-10-22 9:14 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
On Mon, Oct 20, 2025 at 10:28 PM Petr Vorel <pvorel@suse.cz> wrote:
> Function use just bool value, no need for int (readability).
>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
>
Reviewed-by: Li Wang <liwang@redhat.com>
---
> 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
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
>
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH 1/1] tst_cmd: Change tst_check_cmd() return type to int
2025-10-22 9:14 ` Li Wang via ltp
@ 2025-10-22 11:41 ` Petr Vorel
0 siblings, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2025-10-22 11:41 UTC (permalink / raw)
To: Li Wang; +Cc: ltp
Hi Li,
thanks for your review, merged.
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-22 11:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-20 14:28 [LTP] [PATCH 1/1] tst_cmd: Change tst_check_cmd() return type to int Petr Vorel
2025-10-22 9:14 ` Li Wang via ltp
2025-10-22 11:41 ` Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox