Re: [NET]: Shut up warnings in net/core/flow.c

From: David S. Miller
Date: Wed Nov 23 2005 - 18:20:27 EST

From: Linus Torvalds <torvalds@xxxxxxxx>
Date: Wed, 23 Nov 2005 08:54:46 -0800 (PST)

> The way to handle it is to do
> static inline int maybe_ignored(int arg, ...)
> {
> return arg;
> }
> #define smp_call_function(func,info,retry,wait) \
> maybe_ignored(0, info, retry, wait)
> which is a very useful way to say: we don't care about "func", but we want
> to avoid unused warnings for "info", "retry" and "wait", and we want to
> return 0 regardless and compile it all away.
> If somebody tests this, puts the "maybe_ignored()" function in some nice
> generic header file, I'll apply it.

I quickly hacked this up and did a UP test build (patch at the end),
but there is another consequence to consider.

With this, we have to either:

1) Mark all IPI functions with ifdef CONFIG_SMP, or
2) Mark them with __attribute__((__unused__))) which is what
the net/core/flow.c case does

Because if we just leave the static IPI functions there without the
CONFIG_SMP ifdef and without the unused attribute, this new
smp_call_function() will generate an unused static function warning.

What we could do is hide that detail behind some kind of
"DEFINE_IPI_FUNC()" macro, and put the gore into a header file.

I'm sure there are other clean ways of handling it.

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index b1e407a..1876d3c 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -286,6 +286,11 @@ extern void dump_stack(void);
1; \

+static inline int maybe_ignored(int arg, ...)
+ return arg;
#endif /* __KERNEL__ */

#define SI_LOAD_SHIFT 16
diff --git a/include/linux/smp.h b/include/linux/smp.h
index 9dfa3ee..2a513fe 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -94,7 +94,8 @@ void smp_prepare_boot_cpu(void);
#define raw_smp_processor_id() 0
#define hard_smp_processor_id() 0
-#define smp_call_function(func,info,retry,wait) ({ 0; })
+#define smp_call_function(func,info,retry,wait) \
+ maybe_ignored(0, info, retry, wait)
#define on_each_cpu(func,info,retry,wait) ({ func(info); 0; })
static inline void smp_send_reschedule(int cpu) { }
#define num_booting_cpus() 1
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at