mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
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💯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>
This commit is contained in:
parent
5d04270708
commit
8801c35c36
|
|
@ -96,10 +96,13 @@ void *kmem_cache_alloc_lru(struct kmem_cache *cachep, struct list_lru *lru,
|
||||||
p = node;
|
p = node;
|
||||||
} else {
|
} else {
|
||||||
pthread_mutex_unlock(&cachep->lock);
|
pthread_mutex_unlock(&cachep->lock);
|
||||||
if (cachep->align)
|
if (cachep->align) {
|
||||||
posix_memalign(&p, cachep->align, cachep->size);
|
if (posix_memalign(&p, cachep->align, cachep->size) < 0)
|
||||||
else
|
return NULL;
|
||||||
|
} else {
|
||||||
p = malloc(cachep->size);
|
p = malloc(cachep->size);
|
||||||
|
}
|
||||||
|
|
||||||
if (cachep->ctor)
|
if (cachep->ctor)
|
||||||
cachep->ctor(p);
|
cachep->ctor(p);
|
||||||
else if (gfp & __GFP_ZERO)
|
else if (gfp & __GFP_ZERO)
|
||||||
|
|
@ -195,8 +198,9 @@ int kmem_cache_alloc_bulk(struct kmem_cache *cachep, gfp_t gfp, size_t size,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cachep->align) {
|
if (cachep->align) {
|
||||||
posix_memalign(&p[i], cachep->align,
|
if (posix_memalign(&p[i], cachep->align,
|
||||||
cachep->size);
|
cachep->size) < 0)
|
||||||
|
break;
|
||||||
} else {
|
} else {
|
||||||
p[i] = malloc(cachep->size);
|
p[i] = malloc(cachep->size);
|
||||||
if (!p[i])
|
if (!p[i])
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user