linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests/mm: Replace obsolete memalign() with posix_memalign()
@ 2023-04-13  1:27 Deming Wang
  2023-04-13 22:11 ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Deming Wang @ 2023-04-13  1:27 UTC (permalink / raw)
  To: akpm, shuah; +Cc: linux-mm, linux-kselftest, linux-kernel, Deming Wang

memalign() is obsolete according to its manpage.

Replace memalign() with posix_memalign().

As a pointer is passed into posix_memalign(),initialize *map to
NULL,to silence a warning about the function's return value being
used as uninitialized (which is not valid anyway because the
error is properly checked before map is returned).

Signed-off-by: Deming Wang <wangdeming@inspur.com>
---
 tools/testing/selftests/mm/soft-dirty.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/mm/soft-dirty.c b/tools/testing/selftests/mm/soft-dirty.c
index 21d8830c5f24..c99350e110ec 100644
--- a/tools/testing/selftests/mm/soft-dirty.c
+++ b/tools/testing/selftests/mm/soft-dirty.c
@@ -80,9 +80,9 @@ static void test_hugepage(int pagemap_fd, int pagesize)
 	int i, ret;
 	size_t hpage_len = read_pmd_pagesize();
 
-	map = memalign(hpage_len, hpage_len);
-	if (!map)
-		ksft_exit_fail_msg("memalign failed\n");
+	ret = posix_memalign((void **)(&map), hpage_len, hpage_len);
+	if (ret < 0)
+		ksft_exit_fail_msg("posix_memalign failed\n");
 
 	ret = madvise(map, hpage_len, MADV_HUGEPAGE);
 	if (ret)
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [PATCH] selftests/mm: Replace obsolete memalign() with posix_memalign()
@ 2023-04-12  9:35 Deming Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Deming Wang @ 2023-04-12  9:35 UTC (permalink / raw)
  To: akpm, shuah; +Cc: linux-mm, linux-kselftest, linux-kernel, Deming Wang

memalign() is obsolete according to its manpage.

Replace memalign() with posix_memalign().

As a pointer is passed into posix_memalign(),initialize *map to
NULL,to silence a warning about the function's return value being
used as uninitialized (which is not valid anyway because the
error is properly checked before p is returned).

Signed-off-by: Deming Wang <wangdeming@inspur.com>
---
 tools/testing/selftests/mm/soft-dirty.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/mm/soft-dirty.c b/tools/testing/selftests/mm/soft-dirty.c
index 21d8830c5f24..c99350e110ec 100644
--- a/tools/testing/selftests/mm/soft-dirty.c
+++ b/tools/testing/selftests/mm/soft-dirty.c
@@ -80,9 +80,9 @@ static void test_hugepage(int pagemap_fd, int pagesize)
 	int i, ret;
 	size_t hpage_len = read_pmd_pagesize();
 
-	map = memalign(hpage_len, hpage_len);
-	if (!map)
-		ksft_exit_fail_msg("memalign failed\n");
+	ret = posix_memalign((void **)(&map), hpage_len, hpage_len);
+	if (ret < 0)
+		ksft_exit_fail_msg("posix_memalign failed\n");
 
 	ret = madvise(map, hpage_len, MADV_HUGEPAGE);
 	if (ret)
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [PATCH] selftests/mm: Replace obsolete memalign() with posix_memalign()
@ 2023-04-12  7:27 Deming Wang
  2023-04-12  8:25 ` David Hildenbrand
  0 siblings, 1 reply; 6+ messages in thread
From: Deming Wang @ 2023-04-12  7:27 UTC (permalink / raw)
  To: akpm, shuah; +Cc: linux-mm, linux-kselftest, linux-kernel, Deming Wang

memalign() is obsolete according to its manpage.

Replace memalign() with posix_memalign() and remove malloc.h include
that was there for memalign().

As a pointer is passed into posix_memalign(), initialize *p to NULL
to silence a warning about the function's return value being used as
uninitialized (which is not valid anyway because the error is properly
checked before p is returned).

Signed-off-by: Deming Wang <wangdeming@inspur.com>
---
 tools/testing/selftests/mm/soft-dirty.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/mm/soft-dirty.c b/tools/testing/selftests/mm/soft-dirty.c
index 21d8830c5f24..4bb7421141a2 100644
--- a/tools/testing/selftests/mm/soft-dirty.c
+++ b/tools/testing/selftests/mm/soft-dirty.c
@@ -80,8 +80,8 @@ static void test_hugepage(int pagemap_fd, int pagesize)
 	int i, ret;
 	size_t hpage_len = read_pmd_pagesize();
 
-	map = memalign(hpage_len, hpage_len);
-	if (!map)
+	ret = posix_memalign((void *)(&map), hpage_len, hpage_len);
+	if (ret < 0)
 		ksft_exit_fail_msg("memalign failed\n");
 
 	ret = madvise(map, hpage_len, MADV_HUGEPAGE);
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [PATCH] selftests/mm: Replace obsolete memalign() with posix_memalign()
@ 2023-04-12  6:58 Deming Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Deming Wang @ 2023-04-12  6:58 UTC (permalink / raw)
  To: akpm, shuah; +Cc: linux-mm, linux-kselftest, linux-kernel, Deming Wang

memalign() is obsolete according to its manpage.

Replace memalign() with posix_memalign() and remove malloc.h include
that was there for memalign().

As a pointer is passed into posix_memalign(), initialize *p to NULL
to silence a warning about the function's return value being used as
uninitialized (which is not valid anyway because the error is properly
checked before p is returned).

Signed-off-by: Deming Wang <wangdeming@inspur.com>
---
 tools/testing/selftests/mm/soft-dirty.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/mm/soft-dirty.c b/tools/testing/selftests/mm/soft-dirty.c
index 21d8830c5f24..4bb7421141a2 100644
--- a/tools/testing/selftests/mm/soft-dirty.c
+++ b/tools/testing/selftests/mm/soft-dirty.c
@@ -80,8 +80,8 @@ static void test_hugepage(int pagemap_fd, int pagesize)
 	int i, ret;
 	size_t hpage_len = read_pmd_pagesize();
 
-	map = memalign(hpage_len, hpage_len);
-	if (!map)
+	ret = posix_memalign((void *)(&map), hpage_len, hpage_len)
+	if (ret < 0)
 		ksft_exit_fail_msg("memalign failed\n");
 
 	ret = madvise(map, hpage_len, MADV_HUGEPAGE);
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-04-13 22:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-13  1:27 [PATCH] selftests/mm: Replace obsolete memalign() with posix_memalign() Deming Wang
2023-04-13 22:11 ` Andrew Morton
  -- strict thread matches above, loose matches on Subject: below --
2023-04-12  9:35 Deming Wang
2023-04-12  7:27 Deming Wang
2023-04-12  8:25 ` David Hildenbrand
2023-04-12  6:58 Deming Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).