diff mbox series

Make more redeable the kmalloc function

Message ID 20190604014454.6652-1-eamanu@eamanu.com (mailing list archive)
State New, archived
Headers show
Series Make more redeable the kmalloc function | expand

Commit Message

Emmanuel Arias June 4, 2019, 1:44 a.m. UTC
The ``if```check of size > KMALLOC_MAX_CACHE_SIZE was between the same
preprocessor directive. I join the the directives to be more redeable.

Signed-off-by: Emmanuel Arias <eamanu@eamanu.com>
---
 include/linux/slab.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Matthew Wilcox June 4, 2019, 11:48 a.m. UTC | #1
On Mon, Jun 03, 2019 at 10:44:54PM -0300, Emmanuel Arias wrote:
> The ``if```check of size > KMALLOC_MAX_CACHE_SIZE was between the same
> preprocessor directive. I join the the directives to be more redeable.

>  static __always_inline void *kmalloc(size_t size, gfp_t flags)
>  {
>  	if (__builtin_constant_p(size)) {
> -#ifndef CONFIG_SLOB
> -		unsigned int index;
> -#endif
>  		if (size > KMALLOC_MAX_CACHE_SIZE)
>  			return kmalloc_large(size, flags);
>  #ifndef CONFIG_SLOB
> +		unsigned int index;
>  		index = kmalloc_index(size);

You didn't get a new warning from -Wdeclaration-after-statement?
diff mbox series

Patch

diff --git a/include/linux/slab.h b/include/linux/slab.h
index 11b45f7ae405..90753231c191 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -531,12 +531,10 @@  static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
 static __always_inline void *kmalloc(size_t size, gfp_t flags)
 {
 	if (__builtin_constant_p(size)) {
-#ifndef CONFIG_SLOB
-		unsigned int index;
-#endif
 		if (size > KMALLOC_MAX_CACHE_SIZE)
 			return kmalloc_large(size, flags);
 #ifndef CONFIG_SLOB
+		unsigned int index;
 		index = kmalloc_index(size);
 
 		if (!index)