From: Li Wang <liwang@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 3/3] minmax: ensure the comparison numbers have compatible type
Date: Fri, 11 Mar 2022 13:46:03 +0800 [thread overview]
Message-ID: <20220311054603.57328-4-liwang@redhat.com> (raw)
In-Reply-To: <20220311054603.57328-1-liwang@redhat.com>
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);
safety = MAX(safety, min_free);
safety /= info.mem_unit;
@@ -44,7 +44,7 @@ void tst_pollute_memory(size_t maxsize, int fillchar)
* Use the lower value of both for pollutable memory. Usually this
* means we will not evict any caches.
*/
- freeram = MIN(info.freeram, (tst_available_mem() * 1024));
+ freeram = MIN((long long)info.freeram, (tst_available_mem() * 1024));
/* Not enough free memory to avoid invoking OOM killer */
if (freeram <= safety)
diff --git a/lib/tst_timer_test.c b/lib/tst_timer_test.c
index 3cd52fc9d..c0e3de3e7 100644
--- a/lib/tst_timer_test.c
+++ b/lib/tst_timer_test.c
@@ -67,7 +67,7 @@ static const char *table_heading = " Time: us ";
*/
static unsigned int header_len(long long max_sample)
{
- unsigned int l = 1;
+ size_t l = 1;
while (max_sample/=10)
l++;
@@ -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(100000, requested_us / 1000);
+ unsigned int slack_per_scall = MIN((long long)100000, requested_us / 1000);
slack_per_scall = MAX(slack_per_scall, timerslack);
diff --git a/testcases/kernel/syscalls/fallocate/fallocate06.c b/testcases/kernel/syscalls/fallocate/fallocate06.c
index bf0d24328..25b27e41d 100644
--- a/testcases/kernel/syscalls/fallocate/fallocate06.c
+++ b/testcases/kernel/syscalls/fallocate/fallocate06.c
@@ -95,7 +95,7 @@ static void setup(void)
TEST(toggle_cow(fd, 0));
SAFE_FSTAT(fd, &statbuf);
blocksize = statbuf.st_blksize;
- block_offset = MIN(blocksize / 2, 512);
+ block_offset = MIN(blocksize / 2, (blksize_t)512);
wbuf_size = MAX(WRITE_BLOCKS, FALLOCATE_BLOCKS) * blocksize;
rbuf_size = (DEALLOCATE_BLOCKS + 1) * blocksize;
SAFE_CLOSE(fd);
--
2.31.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2022-03-11 5:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-11 5:46 [LTP] [PATCH 0/3] refine the MIN/MAX macros Li Wang
2022-03-11 5:46 ` [LTP] [PATCH 1/3] include: replace min/max macro by the new definition Li Wang
2022-03-23 10:19 ` Petr Vorel
2022-03-24 2:52 ` Li Wang
2022-03-11 5:46 ` [LTP] [PATCH 2/3] lib: adding unnecessary pointer comparison Li Wang
2022-03-23 10:22 ` Petr Vorel
2022-03-11 5:46 ` Li Wang [this message]
2022-03-11 8:52 ` [LTP] [PATCH 3/3] minmax: ensure the comparison numbers have compatible type Li Wang
2022-03-23 13:33 ` Petr Vorel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220311054603.57328-4-liwang@redhat.com \
--to=liwang@redhat.com \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.