[LTP] [PATCH 1/1] tst_cmd: Change tst_check_cmd() return type to int
Li Wang
liwang@redhat.com
Wed Oct 22 11:14:59 CEST 2025
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
More information about the ltp
mailing list