tools/virtio/ringtest: Replace obsolete memalign() with posix_memalign()
PATCH 1/1 tools/virtio/ringtest: 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 *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).
--- tools/virtio/ringtest/ptr_ring.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
tools/virtio/ringtest/ptr_ring.c +6 -3
@@ -26,9 +26,12 @@ typedef int gfp_t;static void *kmalloc (unsigned size,gfp_t gfp) { -void *p =memalign (64 , size); -if (!p) -return p; +void *p; +int ret; + + ret =posix_memalign (&p,64 , size); +if (ret <0 ) +return NULL ;if (gfp & __GFP_ZERO)memset (p,0 , size);
Signature · 1 line
2.27.0
Quoted 11 lines · Deming Wang
memalign()is obsolete according to its manpage.Replace
memalign()withposix_memalign()and removemalloc.hinclude that was there formemalign().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 <[email protected]>
LGTM
Quoted 25 lines
--- tools/virtio/ringtest/ptr_ring.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)tools/virtio/ringtest/ptr_ring.c +6
-4@@ -26,9 +26,12 @@ typedef int gfp_t;static void *kmalloc (unsigned size,gfp_t gfp) { -void *p =memalign (64 , size); -if (!p) -return p; +void *p; +int ret; + + ret =posix_memalign (&p,64 , size); +if (ret <0 ) +return NULL ;if (gfp & __GFP_ZERO)memset (p,0 , size); --
Quoted 2 lines
2.27.0
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization