linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Suppress the sparse warning ./include/linux/slab.h:332:43: warning: dubious: x & !y
@ 2018-11-09  2:28 Darryl T. Agostinelli
  2018-11-14 22:25 ` David Rientjes
  0 siblings, 1 reply; 2+ messages in thread
From: Darryl T. Agostinelli @ 2018-11-09  2:28 UTC (permalink / raw)
  To: linux-mm
  Cc: cl, bvanassche, akpm, penberg, vbabka, rientjes, iamjoonsoo.kim,
	linux-kernel, Darryl T. Agostinelli

Signed-off-by: Darryl T. Agostinelli <dagostinelli@gmail.com>
---
 include/linux/slab.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/linux/slab.h b/include/linux/slab.h
index 918f374e7156..883b7f56bf35 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -317,6 +317,7 @@ static __always_inline enum kmalloc_cache_type kmalloc_type(gfp_t flags)
 	int is_dma = 0;
 	int type_dma = 0;
 	int is_reclaimable;
+	int y;
 
 #ifdef CONFIG_ZONE_DMA
 	is_dma = !!(flags & __GFP_DMA);
@@ -329,7 +330,10 @@ static __always_inline enum kmalloc_cache_type kmalloc_type(gfp_t flags)
 	 * If an allocation is both __GFP_DMA and __GFP_RECLAIMABLE, return
 	 * KMALLOC_DMA and effectively ignore __GFP_RECLAIMABLE
 	 */
-	return type_dma + (is_reclaimable & !is_dma) * KMALLOC_RECLAIM;
+
+	y = (is_reclaimable & (is_dma == 0 ? 1 : 0));
+
+	return type_dma + y * KMALLOC_RECLAIM;
 }
 
 /*
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Suppress the sparse warning ./include/linux/slab.h:332:43: warning: dubious: x & !y
  2018-11-09  2:28 [PATCH] Suppress the sparse warning ./include/linux/slab.h:332:43: warning: dubious: x & !y Darryl T. Agostinelli
@ 2018-11-14 22:25 ` David Rientjes
  0 siblings, 0 replies; 2+ messages in thread
From: David Rientjes @ 2018-11-14 22:25 UTC (permalink / raw)
  To: Darryl T. Agostinelli
  Cc: linux-mm, cl, bvanassche, akpm, penberg, vbabka, iamjoonsoo.kim,
	linux-kernel

On Thu, 8 Nov 2018, Darryl T. Agostinelli wrote:

> Signed-off-by: Darryl T. Agostinelli <dagostinelli@gmail.com>
> ---
>  include/linux/slab.h | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/slab.h b/include/linux/slab.h
> index 918f374e7156..883b7f56bf35 100644
> --- a/include/linux/slab.h
> +++ b/include/linux/slab.h
> @@ -317,6 +317,7 @@ static __always_inline enum kmalloc_cache_type kmalloc_type(gfp_t flags)
>  	int is_dma = 0;
>  	int type_dma = 0;
>  	int is_reclaimable;
> +	int y;
>  
>  #ifdef CONFIG_ZONE_DMA
>  	is_dma = !!(flags & __GFP_DMA);
> @@ -329,7 +330,10 @@ static __always_inline enum kmalloc_cache_type kmalloc_type(gfp_t flags)
>  	 * If an allocation is both __GFP_DMA and __GFP_RECLAIMABLE, return
>  	 * KMALLOC_DMA and effectively ignore __GFP_RECLAIMABLE
>  	 */
> -	return type_dma + (is_reclaimable & !is_dma) * KMALLOC_RECLAIM;
> +
> +	y = (is_reclaimable & (is_dma == 0 ? 1 : 0));
> +
> +	return type_dma + y * KMALLOC_RECLAIM;
>  }
>  
>  /*

I agree with you that the function as written is less than pretty :)  How 
does the assembly change as a result of this code change, however?  This 
will be in the kmalloc() path so impacting the assembly to fix a sparse 
warning may not be warranted.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-11-14 22:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-09  2:28 [PATCH] Suppress the sparse warning ./include/linux/slab.h:332:43: warning: dubious: x & !y Darryl T. Agostinelli
2018-11-14 22:25 ` David Rientjes

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).