Skip to contentSkip to conversation

memory hotplug: fix warnings

PATCH In review Vincent Stehlé 3 participants 5 messages Apr 30, 2013 MM core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 memory hotplug: fix warnings

Fix the following compilation warnings:

mm/slab.c: In function ‘kmem_cache_init_late’:
mm/slab.c:1778:2: warning: statement with no effect [-Wunused-value]

mm/page_cgroup.c: In function ‘page_cgroup_init’:
mm/page_cgroup.c:305:2: warning: statement with no effect [-Wunused-value]

---
 include/linux/memory.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/memory.h +1 -1
index 73817af..85c31a8 100644
@@ -137,7 +137,7 @@ enum mem_add_context { BOOT, HOTPLUG };
 #define register_hotmemory_notifier(nb)		register_memory_notifier(nb)
 #define unregister_hotmemory_notifier(nb) 	unregister_memory_notifier(nb)
 #else
-#define hotplug_memory_notifier(fn, pri)	(0)
+#define hotplug_memory_notifier(fn, pri)	({ 0; })
 /* These aren't inline functions due to a GCC bug. */
 #define register_hotmemory_notifier(nb)    ({ (void)(nb); 0; })
 #define unregister_hotmemory_notifier(nb)  ({ (void)(nb); })
Signature · 1 line
1.7.10.4
#1 lore raw

include/linux/memory.h enum mem_add_context { BOOT, HOTPLUG }; · line 143

Quoted 13 lines · Vincent Stehlé
include/linux/memory.h +1 -1
index 73817af..85c31a8 100644
@@ -137,7 +137,7 @@ enum mem_add_context { BOOT, HOTPLUG };
 #define register_hotmemory_notifier(nb)		register_memory_notifier(nb)
 #define unregister_hotmemory_notifier(nb) 	unregister_memory_notifier(nb)
 #else
-#define hotplug_memory_notifier(fn, pri)	(0)
+#define hotplug_memory_notifier(fn, pri)	({ 0; })
 /* These aren't inline functions due to a GCC bug. */
 #define register_hotmemory_notifier(nb)    ({ (void)(nb); 0; })
 #define unregister_hotmemory_notifier(nb)  ({ (void)(nb); })

You can't use the standard do {} while (0)?

maintainer
#2 lore raw
Quoted 17 lines · On Tue, 30 Apr 2013 09:17:11 -0700 (PDT) David Rientjes <[email protected]>…

include/linux/memory.h enum mem_add_context { BOOT, HOTPLUG }; · line 143

Quoted 13 lines · Vincent Stehl__
include/linux/memory.h +1 -1
index 73817af..85c31a8 100644
@@ -137,7 +137,7 @@ enum mem_add_context { BOOT, HOTPLUG };
 #define register_hotmemory_notifier(nb)		register_memory_notifier(nb)
 #define unregister_hotmemory_notifier(nb) 	unregister_memory_notifier(nb)
 #else
-#define hotplug_memory_notifier(fn, pri)	(0)
+#define hotplug_memory_notifier(fn, pri)	({ 0; })
 /* These aren't inline functions due to a GCC bug. */
 #define register_hotmemory_notifier(nb)    ({ (void)(nb); 0; })
 #define unregister_hotmemory_notifier(nb)  ({ (void)(nb); })

You can't use the standard do {} while (0)?

register_memory_notifier() (and hence hotplug_memory_notifier()) returns an errno. Which nobody bothers checking.

#3 lore raw
Quoted 16 lines · Andrew Morton
Quoted 7 lines
Quoted 7 lines
include/linux/memory.h +0 -0
index 73817af..85c31a8 100644
@@ -137,7 +137,7 @@ enum mem_add_context { BOOT, HOTPLUG };
 #define register_hotmemory_notifier(nb)		register_memory_notifier(nb)
 #define unregister_hotmemory_notifier(nb) 	unregister_memory_notifier(nb)
Quoted 8 lines

include/linux/memory.h enum mem_add_context { BOOT, HOTPLUG }; · line 143

Quoted 6 lines
include/linux/memory.h +1 -1
 #else
-#define hotplug_memory_notifier(fn, pri)	(0)
+#define hotplug_memory_notifier(fn, pri)	({ 0; })
 /* These aren't inline functions due to a GCC bug. */
 #define register_hotmemory_notifier(nb)    ({ (void)(nb); 0; })
 #define unregister_hotmemory_notifier(nb)  ({ (void)(nb); })

You can't use the standard do {} while (0)?

Quoted 3 lines

register_memory_notifier() (and hence hotplug_memory_notifier()) returns an errno. Which nobody bothers checking.

The notifier itself is statically allocated so there's no memory allocations in this path, there's no chance it'll fail. Should we just make register_memory_notifier() return void?

maintainer
#4 lore raw
Quoted 18 lines · On Tue, 30 Apr 2013 09:54:18 -0700 (PDT) David Rientjes <[email protected]>…
Quoted 16 lines · Andrew Morton
Quoted 15 lines

include/linux/memory.h enum mem_add_context { BOOT, HOTPLUG }; · line 143

Quoted 13 lines
include/linux/memory.h +1 -1
index 73817af..85c31a8 100644
@@ -137,7 +137,7 @@ enum mem_add_context { BOOT, HOTPLUG };
 #define register_hotmemory_notifier(nb)		register_memory_notifier(nb)
 #define unregister_hotmemory_notifier(nb) 	unregister_memory_notifier(nb)
 #else
-#define hotplug_memory_notifier(fn, pri)	(0)
+#define hotplug_memory_notifier(fn, pri)	({ 0; })
 /* These aren't inline functions due to a GCC bug. */
 #define register_hotmemory_notifier(nb)    ({ (void)(nb); 0; })
 #define unregister_hotmemory_notifier(nb)  ({ (void)(nb); })

You can't use the standard do {} while (0)?

Quoted 7 lines
Quoted 3 lines

register_memory_notifier() (and hence hotplug_memory_notifier()) returns an errno. Which nobody bothers checking.

The notifier itself is statically allocated so there's no memory allocations in this path, there's no chance it'll fail. Should we just make register_memory_notifier() return void?

Drill down and we end up in notifier_chain_register(), which unconditionally returns 0.

So we can either leave things as they are under the assumption that notifier_chain_register() might one day be changed to return an errno or we can change everything to return void.