Skip to contentSkip to conversation

Make more redeable the kmalloc function

PATCH In review Emmanuel Arias 2 participants 2 messages Jun 4, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Make more redeable the kmalloc function

The ``if```check of size > KMALLOC_MAX_CACHE_SIZE was between the same preprocessor directive. I join the the directives to be more redeable.

---
 include/linux/slab.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
include/linux/slab.h +1 -3
index 11b45f7ae405..90753231c191 100644
@@ -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)
Signature · 1 line
2.11.0
#1 lore raw
Quoted 5 lines · Emmanuel Arias

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

include/linux/slab.h static __always_inline void *kmalloc_large(size_t size, gfp_t flags) · line 538

Quoted 9 lines
include/linux/slab.h +1 -3
 	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?