Re: [PATCH] x86, vsyscall: Fix build warning in vsyscall_64.c

From: Ingo Molnar
Date: Tue Jun 14 2011 - 17:16:31 EST



* Andy Lutomirski <luto@xxxxxxx> wrote:

> Aha! You have CONFIG_BUG=n. I'm not sure that fixing warnings for
> that case is worth it (or is even a good idea).

Especially since the warning is correct, CONFIG_BUG=n is mortally
broken!

A BUG() turned into NOP is 100% evil, full stop.

> Can you try this patch, though:
>
> Signed-off-by: Andy Lutomirski <luto@xxxxxxx>
>
> diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
> index dfb0ec6..f4083f4 100644
> --- a/include/asm-generic/bug.h
> +++ b/include/asm-generic/bug.h
> @@ -107,11 +107,11 @@ extern void warn_slowpath_null(const char
> *file, const int line);
>
> #else /* !CONFIG_BUG */
> #ifndef HAVE_ARCH_BUG
> -#define BUG() do {} while(0)
> +#define BUG() do { unreachable(); } while(0)
> #endif
>
> #ifndef HAVE_ARCH_BUG_ON
> -#define BUG_ON(condition) do { if (condition) ; } while(0)
> +#define BUG_ON(condition) do { if (condition) unreachable(); } while(0)
> #endif
>
> #ifndef HAVE_ARCH_WARN_ON
>
> It may silence a lot of warnings, although it'll come at a cost of
> increased code size with CONFIG_BUG=n on older gcc. On newer GCC,
> you'll get possibly faster and smaller code.

I sent such a patch ages ago but was shouted down by 'this will
increase code size'.

I think correctness trumps code size and turning BUG() and BUG_ON()
into a NOP is just crazy ...

Thanks,

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/