Re: [tip:core/urgent] WARN_ON_SMP(): Add comment to explain ({0;})

Steven Rostedt
2011-03-29T11:36:47Z

On Mon, 2011-03-28 at 21:18 +0300, Alexey Dobriyan wrote:
> On Mon, Mar 28, 2011 at 11:09:00AM -0400, Steven Rostedt wrote:
> > Geeze, I never expected such a fuss over a simple change ;)
>
> And it's still broken ;-)
>
> [spoiler space]

I didn't understand this "space" and never went down to look more.
Should have said "see below".

> WARN_ON_SMP(x) should expand to x, not 0.

No it should expand to zero, please READ THE COMMENT!

OK, it was not part of this patch, but it was in the patch that this
patch was added for.

+/*
+ * WARN_ON_SMP() is for cases that the warning is either
+ * meaningless for !SMP or may even cause failures.
+ * This is usually used for cases that we have
+ * WARN_ON(!spin_is_locked(&lock)) checks, as spin_is_locked()
+ * returns 0 for uniprocessor settings.
+ * It can also be used with values that are only defined
+ * on SMP:
+ *
+ * struct foo {
+ * [...]
+ * #ifdef CONFIG_SMP
+ * int bar;
+ * #endif
+ * };
+ *
+ * void func(struct foo *zoot)
+ * {
+ * WARN_ON_SMP(!zoot->bar);
+ *
+ * For CONFIG_SMP, WARN_ON_SMP() should act the same as WARN_ON(),
+ * and should be a nop and return false for uniprocessor.
+ *
+ * if (WARN_ON_SMP(x)) returns true only when CONFIG_SMP is set
+ * and x is true.
+ */

-- Steve