Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tools: fix -Wunused-result in linux.c

Fix the following -Wunused-result warnings on posix_memalign()
return values and add error handling.

./shared/linux.c:100:25: warning: ignoring return value of `posix_memalign' declared with attribute `warn_unused_result' [-Wunused-result]
100 | posix_memalign(&p, cachep->align, cachep->size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../shared/linux.c: In function `kmem_cache_alloc_bulk':
../shared/linux.c:198:33: warning: ignoring return value of `posix_memalign' declared with attribute `warn_unused_result' [-Wunused-result]
198 | posix_memalign(&p[i], cachep->align,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
199 | cachep->size);
| ~~~~~~~~~~~~~

Link: https://lkml.kernel.org/r/20241011225155.27607-1-skhan@linuxfoundation.org
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Shuah Khan and committed by
Andrew Morton
8801c35c 5d042707

+9 -5
+9 -5
tools/testing/shared/linux.c
··· 96 96 p = node; 97 97 } else { 98 98 pthread_mutex_unlock(&cachep->lock); 99 - if (cachep->align) 100 - posix_memalign(&p, cachep->align, cachep->size); 101 - else 99 + if (cachep->align) { 100 + if (posix_memalign(&p, cachep->align, cachep->size) < 0) 101 + return NULL; 102 + } else { 102 103 p = malloc(cachep->size); 104 + } 105 + 103 106 if (cachep->ctor) 104 107 cachep->ctor(p); 105 108 else if (gfp & __GFP_ZERO) ··· 198 195 } 199 196 200 197 if (cachep->align) { 201 - posix_memalign(&p[i], cachep->align, 202 - cachep->size); 198 + if (posix_memalign(&p[i], cachep->align, 199 + cachep->size) < 0) 200 + break; 203 201 } else { 204 202 p[i] = malloc(cachep->size); 205 203 if (!p[i])