* [PATCH] selftests/powerpc: Replace obsolete memalign() with posix_memalign()
@ 2023-04-12 11:12 Deming Wang
2023-04-12 12:02 ` Michael Ellerman
0 siblings, 1 reply; 4+ messages in thread
From: Deming Wang @ 2023-04-12 11:12 UTC (permalink / raw)
To: shuah, mpe
Cc: Deming Wang, linux-kernel, npiggin, linux-kselftest, linuxppc-dev
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 *s 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/powerpc/stringloops/strlen.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/powerpc/stringloops/strlen.c b/tools/testing/selftests/powerpc/stringloops/strlen.c
index 9055ebc484d0..f9c1f9cc2d32 100644
--- a/tools/testing/selftests/powerpc/stringloops/strlen.c
+++ b/tools/testing/selftests/powerpc/stringloops/strlen.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#include <malloc.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
@@ -51,10 +50,11 @@ static void bench_test(char *s)
static int testcase(void)
{
char *s;
+ int ret;
unsigned long i;
- s = memalign(128, SIZE);
- if (!s) {
+ ret = posix_memalign((void **)&s, 128, SIZE);
+ if (ret < 0) {
perror("memalign");
exit(1);
}
--
2.27.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] selftests/powerpc: Replace obsolete memalign() with posix_memalign()
2023-04-12 11:12 Deming Wang
@ 2023-04-12 12:02 ` Michael Ellerman
0 siblings, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2023-04-12 12:02 UTC (permalink / raw)
To: Deming Wang, shuah
Cc: Deming Wang, linux-kernel, npiggin, linux-kselftest, linuxppc-dev
Deming Wang <wangdeming@inspur.com> writes:
> 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 *s 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).
The patch doesn't do that. There is no p?
I think you've copied the change log for a whole bunch of commits but
not updated them to be accurate for each change?
cheers
> diff --git a/tools/testing/selftests/powerpc/stringloops/strlen.c b/tools/testing/selftests/powerpc/stringloops/strlen.c
> index 9055ebc484d0..f9c1f9cc2d32 100644
> --- a/tools/testing/selftests/powerpc/stringloops/strlen.c
> +++ b/tools/testing/selftests/powerpc/stringloops/strlen.c
> @@ -1,5 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#include <malloc.h>
> #include <stdlib.h>
> #include <string.h>
> #include <time.h>
> @@ -51,10 +50,11 @@ static void bench_test(char *s)
> static int testcase(void)
> {
> char *s;
> + int ret;
> unsigned long i;
>
> - s = memalign(128, SIZE);
> - if (!s) {
> + ret = posix_memalign((void **)&s, 128, SIZE);
> + if (ret < 0) {
> perror("memalign");
> exit(1);
> }
> --
> 2.27.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] selftests/powerpc: Replace obsolete memalign() with posix_memalign()
@ 2023-04-13 1:02 Deming Wang
2023-04-28 8:09 ` Muhammad Usama Anjum
0 siblings, 1 reply; 4+ messages in thread
From: Deming Wang @ 2023-04-13 1:02 UTC (permalink / raw)
To: mpe, shuah
Cc: Deming Wang, linux-kernel, npiggin, linux-kselftest, linuxppc-dev
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 *s 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 s is returned).
Signed-off-by: Deming Wang <wangdeming@inspur.com>
---
tools/testing/selftests/powerpc/stringloops/strlen.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/powerpc/stringloops/strlen.c b/tools/testing/selftests/powerpc/stringloops/strlen.c
index 9055ebc484d0..f9c1f9cc2d32 100644
--- a/tools/testing/selftests/powerpc/stringloops/strlen.c
+++ b/tools/testing/selftests/powerpc/stringloops/strlen.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#include <malloc.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
@@ -51,10 +50,11 @@ static void bench_test(char *s)
static int testcase(void)
{
char *s;
+ int ret;
unsigned long i;
- s = memalign(128, SIZE);
- if (!s) {
+ ret = posix_memalign((void **)&s, 128, SIZE);
+ if (ret < 0) {
perror("memalign");
exit(1);
}
--
2.27.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] selftests/powerpc: Replace obsolete memalign() with posix_memalign()
2023-04-13 1:02 [PATCH] selftests/powerpc: Replace obsolete memalign() with posix_memalign() Deming Wang
@ 2023-04-28 8:09 ` Muhammad Usama Anjum
0 siblings, 0 replies; 4+ messages in thread
From: Muhammad Usama Anjum @ 2023-04-28 8:09 UTC (permalink / raw)
To: Deming Wang, mpe, shuah
Cc: linux-kernel, Muhammad Usama Anjum, npiggin, linux-kselftest,
linuxppc-dev
On 4/13/23 6:02 AM, Deming Wang wrote:
> memalign() is obsolete according to its manpage.
>
> Replace memalign() with posix_memalign() and remove malloc.h include
> that was there for memalign().
Thanks for the patch.
>
> As a pointer is passed into posix_memalign(), initialize *s to NULL
I'm unable to find this initialization below. Did you really mean to add
the initialization?
> 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 s is returned).
>
> Signed-off-by: Deming Wang <wangdeming@inspur.com>
> ---
> tools/testing/selftests/powerpc/stringloops/strlen.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/selftests/powerpc/stringloops/strlen.c b/tools/testing/selftests/powerpc/stringloops/strlen.c
> index 9055ebc484d0..f9c1f9cc2d32 100644
> --- a/tools/testing/selftests/powerpc/stringloops/strlen.c
> +++ b/tools/testing/selftests/powerpc/stringloops/strlen.c
> @@ -1,5 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#include <malloc.h>
> #include <stdlib.h>
> #include <string.h>
> #include <time.h>
> @@ -51,10 +50,11 @@ static void bench_test(char *s)
> static int testcase(void)
> {
> char *s;
> + int ret;
> unsigned long i;
>
> - s = memalign(128, SIZE);
> - if (!s) {
> + ret = posix_memalign((void **)&s, 128, SIZE);
> + if (ret < 0) {
Can we do if (!ret) instead? The page says:
posix_memalign() returns zero on success.
> perror("memalign");
> exit(1);
> }
--
BR,
Muhammad Usama Anjum
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-04-28 12:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-13 1:02 [PATCH] selftests/powerpc: Replace obsolete memalign() with posix_memalign() Deming Wang
2023-04-28 8:09 ` Muhammad Usama Anjum
-- strict thread matches above, loose matches on Subject: below --
2023-04-12 11:12 Deming Wang
2023-04-12 12:02 ` Michael Ellerman
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).