selftests/powerpc: Replace obsolete memalign() with posix_memalign()
PATCH 1/1 selftests/powerpc: Replace obsolete memalign() with posix_memalign()
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).
--- tools/testing/selftests/powerpc/stringloops/strlen.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/powerpc/stringloops/strlen.c +3 -3
@@ -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 ); }
Signature · 1 line
2.27.0
Quoted 4 lines · Deming Wang
memalign()is obsolete according to its manpage.Replace
memalign()withposix_memalign()and removemalloc.hinclude that was there formemalign().
Thanks for the patch.
Quoted 2 lines
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?
Quoted 20 lines
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 <[email protected]>--- tools/testing/selftests/powerpc/stringloops/strlen.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)tools/testing/selftests/powerpc/stringloops/strlen.c +0
-1@@ -1,5 +1,4 @@// SPDX-License-Identifier: GPL-2.0 -#include <malloc.h> #include <stdlib.h> #include <string.h> #include <time.h>
tools/testing/selftests/powerpc/stringloops/strlen.c static void bench_test(char *s) · line 57
Quoted 10 lines
tools/testing/selftests/powerpc/stringloops/strlen.c +3
-2@@ -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.
Quoted 3 lines
tools/testing/selftests/powerpc/stringloops/strlen.c +0
-0perror ("memalign" );exit (1 ); }
Signature · 2 lines
BR, Muhammad Usama Anjum