Skip to content

Commit

Permalink
Eliminate thousands of warnings with gcc 3.2 build
Browse files Browse the repository at this point in the history
When building with gcc 3.2 I get thousands of warnings such as

include/linux/gfp.h: In function `allocflags_to_migratetype':
include/linux/gfp.h:105: warning: null format string

due to passing a NULL format string to warn_slowpath() in

#define __WARN()		warn_slowpath(__FILE__, __LINE__, NULL)

Split this case out into a separate call.  This also shrinks the kernel
slightly:

          text    data     bss     dec     hex filename
       4802274  707668  712704 6222646  5ef336 vmlinux
          text    data     bss     dec     hex filename
       4799027  703572  712704 6215303  5ed687 vmlinux

due to removeing one argument from the commonly-called __WARN().

[[email protected]: reduce scope of `empty']
Acked-by: Jesper Nilsson <[email protected]>
Acked-by: Johannes Weiner <[email protected]>
Acked-by: Arjan van de Ven <[email protected]>
Signed-off-by: Andi Kleen <[email protected]>
Cc: Hugh Dickins <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Andi Kleen authored and torvalds committed May 6, 2009
1 parent 429aa0f commit 57adc4d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
7 changes: 4 additions & 3 deletions include/asm-generic/bug.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@ struct bug_entry {
*/
#ifndef __WARN
#ifndef __ASSEMBLY__
extern void warn_slowpath(const char *file, const int line,
extern void warn_slowpath_fmt(const char *file, const int line,
const char *fmt, ...) __attribute__((format(printf, 3, 4)));
extern void warn_slowpath_null(const char *file, const int line);
#define WANT_WARN_ON_SLOWPATH
#endif
#define __WARN() warn_slowpath(__FILE__, __LINE__, NULL)
#define __WARN_printf(arg...) warn_slowpath(__FILE__, __LINE__, arg)
#define __WARN() warn_slowpath_null(__FILE__, __LINE__)
#define __WARN_printf(arg...) warn_slowpath_fmt(__FILE__, __LINE__, arg)
#else
#define __WARN_printf(arg...) do { printk(arg); __WARN(); } while (0)
#endif
Expand Down
13 changes: 10 additions & 3 deletions kernel/panic.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ void oops_exit(void)
}

#ifdef WANT_WARN_ON_SLOWPATH
void warn_slowpath(const char *file, int line, const char *fmt, ...)
void warn_slowpath_fmt(const char *file, int line, const char *fmt, ...)
{
va_list args;
char function[KSYM_SYMBOL_LEN];
Expand All @@ -356,7 +356,7 @@ void warn_slowpath(const char *file, int line, const char *fmt, ...)
if (board)
printk(KERN_WARNING "Hardware name: %s\n", board);

if (fmt) {
if (*fmt) {
va_start(args, fmt);
vprintk(fmt, args);
va_end(args);
Expand All @@ -367,7 +367,14 @@ void warn_slowpath(const char *file, int line, const char *fmt, ...)
print_oops_end_marker();
add_taint(TAINT_WARN);
}
EXPORT_SYMBOL(warn_slowpath);
EXPORT_SYMBOL(warn_slowpath_fmt);

void warn_slowpath_null(const char *file, int line)
{
static const char *empty = "";
warn_slowpath_fmt(file, line, empty);
}
EXPORT_SYMBOL(warn_slowpath_null);
#endif

#ifdef CONFIG_CC_STACKPROTECTOR
Expand Down

0 comments on commit 57adc4d

Please sign in to comment.