[LTP] [PATCH v1] hugemmap: use 64-bit types
Edward Liaw
edliaw@google.com
Wed Mar 22 00:07:06 CET 2023
Compiler throws -Wshift-count-overflow warning when compiling hugemmap13
and hugemmap14 as 32-bit. Resolve warning by using unsigned long long
that is always 64-bit.
Signed-off-by: Edward Liaw <edliaw@google.com>
---
.../kernel/mem/hugetlb/hugemmap/hugemmap13.c | 10 +++++-----
.../kernel/mem/hugetlb/hugemmap/hugemmap14.c | 18 +++++++++---------
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap13.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap13.c
index 7235c55ac..f8c36640d 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap13.c
+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap13.c
@@ -24,7 +24,7 @@
#include "hugetlb.h"
-#define FOURGB (1UL << 32)
+#define FOURGB (1ULL << 32)
#define MNTPOINT "hugetlbfs/"
static int fd = -1;
static unsigned long hpage_size;
@@ -33,16 +33,16 @@ static int page_size;
static void run_test(void)
{
void *p, *q = NULL;
- unsigned long lowaddr;
- unsigned long below_start;
- unsigned long above_end;
+ unsigned long long lowaddr;
+ unsigned long long below_start;
+ unsigned long long above_end;
p = mmap((void *)FOURGB, hpage_size, PROT_READ|PROT_WRITE,
MAP_SHARED | MAP_FIXED, fd, 0);
if (p == MAP_FAILED) {
/* slice 0 (high) spans from 4G-1T */
below_start = FOURGB;
- above_end = 1024L*1024*1024*1024;
+ above_end = 1024ULL*1024*1024*1024;
if (range_is_mapped(below_start, above_end) == 1) {
tst_res(TINFO|TERRNO, "region 4G-IT is not free & "
diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap14.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap14.c
index 13068e5b6..c54a746b3 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap14.c
+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap14.c
@@ -24,30 +24,30 @@
#include "hugetlb.h"
-#define FOURGB (1UL << 32)
+#define FOURGB (1ULL << 32)
#define MNTPOINT "hugetlbfs/"
static int fd = -1;
-static unsigned long hpage_size;
+static unsigned long long hpage_size;
static int page_size;
static void run_test(void)
{
void *p, *q = NULL, *r = NULL;
- unsigned long lowaddr, highaddr;
- unsigned long below_start;
- unsigned long above_end;
+ unsigned long long lowaddr, highaddr;
+ unsigned long long below_start;
+ unsigned long long above_end;
/*
* We use a low address right below 4GB so we can test for
* off-by-one errors
*/
lowaddr = FOURGB - hpage_size;
- tst_res(TINFO, "Mapping hugepage at %lx...", lowaddr);
+ tst_res(TINFO, "Mapping hugepage at %llx...", lowaddr);
p = mmap((void *)lowaddr, hpage_size, PROT_READ|PROT_WRITE,
MAP_SHARED|MAP_FIXED, fd, 0);
if (p == MAP_FAILED) {
/* This is last low slice - 256M just before 4G */
- below_start = FOURGB - 256L*1024*1024;
+ below_start = FOURGB - 256ULL*1024*1024;
above_end = FOURGB;
if (range_is_mapped(below_start, above_end) == 1) {
@@ -66,7 +66,7 @@ static void run_test(void)
/* Test for off by one errors */
highaddr = FOURGB;
- tst_res(TINFO, "Mapping normal page at %lx...", highaddr);
+ tst_res(TINFO, "Mapping normal page at %llx...", highaddr);
q = mmap((void *)highaddr, page_size, PROT_READ|PROT_WRITE,
MAP_SHARED|MAP_FIXED|MAP_ANONYMOUS, 0, 0);
if (q == MAP_FAILED) {
@@ -94,7 +94,7 @@ static void run_test(void)
* greater.
*/
highaddr = ((lowaddr >> 28) + 128) << 28;
- tst_res(TINFO, "Mapping normal page at %lx...", highaddr);
+ tst_res(TINFO, "Mapping normal page at %llx...", highaddr);
r = mmap((void *)highaddr, page_size, PROT_READ|PROT_WRITE,
MAP_SHARED|MAP_FIXED|MAP_ANONYMOUS, 0, 0);
if (r == MAP_FAILED) {
--
2.40.0.rc1.284.g88254d51c5-goog
More information about the ltp
mailing list