From: Alexander Egorenkov <egorenar@linux.ibm.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/1] swapping01: fix parameter truncation in abs
Date: Fri, 15 Jan 2021 13:25:43 +0100 [thread overview]
Message-ID: <20210115122543.288948-1-egorenar@linux.ibm.com> (raw)
Parameters passed to abs(int) are of type long. Use labs(long) instead
to avoid value truncation.
Fixes the following warning:
swapping01.c: In function ?check_swapping?:
swapping01.c:133:7: warning: absolute value function ?abs? given an argument of type ?long int? but has parameter of type ?int? which may cause truncation of value [-Wabsolute-value]
133 | if (abs(swap_free_now - SAFE_READ_MEMINFO("SwapFree:")) < 512)
| ^~~
Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
---
testcases/kernel/mem/swapping/swapping01.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/testcases/kernel/mem/swapping/swapping01.c b/testcases/kernel/mem/swapping/swapping01.c
index ff40c85c0..24b8313f3 100644
--- a/testcases/kernel/mem/swapping/swapping01.c
+++ b/testcases/kernel/mem/swapping/swapping01.c
@@ -130,7 +130,7 @@ static void check_swapping(void)
while (i < 10) {
swap_free_now = SAFE_READ_MEMINFO("SwapFree:");
sleep(1);
- if (abs(swap_free_now - SAFE_READ_MEMINFO("SwapFree:")) < 512)
+ if (labs(swap_free_now - SAFE_READ_MEMINFO("SwapFree:")) < 512)
break;
i++;
--
2.26.2
next reply other threads:[~2021-01-15 12:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-15 12:25 Alexander Egorenkov [this message]
2021-01-20 11:11 ` [LTP] [PATCH 1/1] swapping01: fix parameter truncation in abs 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=20210115122543.288948-1-egorenar@linux.ibm.com \
--to=egorenar@linux.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox