[LTP] [PATCH 3/3] minmax: ensure the comparison numbers have compatible type

Li Wang liwang@redhat.com
Fri Mar 11 09:52:16 CET 2022


On Fri, Mar 11, 2022 at 1:46 PM Li Wang <liwang@redhat.com> wrote:

> To get rid of many compiler warnings.
>
> Signed-off-by: Li Wang <liwang@redhat.com>
> ---
>  lib/tst_cgroup.c                                  | 2 +-
>  lib/tst_memutils.c                                | 4 ++--
>  lib/tst_timer_test.c                              | 4 ++--
>  testcases/kernel/syscalls/fallocate/fallocate06.c | 2 +-
>  4 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c
> index 8cca0654d..57940ba09 100644
> --- a/lib/tst_cgroup.c
> +++ b/lib/tst_cgroup.c
> @@ -1116,7 +1116,7 @@ ssize_t safe_cg_read(const char *const file, const
> int lineno,
>                 prev_len = MIN(sizeof(prev_buf), (size_t)read_ret);
>         }
>
> -       out[MAX(read_ret, 0)] = '\0';
> +       out[MAX(read_ret, (ssize_t)0)] = '\0';
>
>         return read_ret;
>  }
> diff --git a/lib/tst_memutils.c b/lib/tst_memutils.c
> index 3741d6e6f..d95d75e5d 100644
> --- a/lib/tst_memutils.c
> +++ b/lib/tst_memutils.c
> @@ -30,7 +30,7 @@ void tst_pollute_memory(size_t maxsize, int fillchar)
>         min_free += min_free / 10;
>
>         SAFE_SYSINFO(&info);
> -       safety = MAX(4096 * SAFE_SYSCONF(_SC_PAGESIZE), 128 * 1024 * 1024);
> +       safety = MAX(4096 * SAFE_SYSCONF(_SC_PAGESIZE), (long)128 * 1024 *
> 1024);
>

This should be 128L. and tst_timer_test has the same issue.

--- a/lib/tst_memutils.c
+++ b/lib/tst_memutils.c
@@ -30,7 +30,7 @@ void tst_pollute_memory(size_t maxsize, int fillchar)
        min_free += min_free / 10;

        SAFE_SYSINFO(&info);
-       safety = MAX(4096 * SAFE_SYSCONF(_SC_PAGESIZE), (long)128 * 1024 *
1024);
+       safety = MAX(4096 * SAFE_SYSCONF(_SC_PAGESIZE), 128L * 1024 * 1024);
        safety = MAX(safety, min_free);
        safety /= info.mem_unit;

diff --git a/lib/tst_timer_test.c b/lib/tst_timer_test.c
index c0e3de3e7..32fa55c7c 100644
--- a/lib/tst_timer_test.c
+++ b/lib/tst_timer_test.c
@@ -184,7 +184,7 @@ static int cmp(const void *a, const void *b)
 static long long compute_threshold(long long requested_us,
                                   unsigned int nsamples)
 {
-       unsigned int slack_per_scall = MIN((long long)100000, requested_us
/ 1000);
+       unsigned int slack_per_scall = MIN(100000LL, requested_us / 1000);

        slack_per_scall = MAX(slack_per_scall, timerslack);


-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20220311/bfc7893a/attachment-0001.htm>


More information about the ltp mailing list