From: "Vegard Nossum" <vegard.nossum@gmail.com>
To: "Arjan van de Ven" <arjan@infradead.org>
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org
Subject: Re: [patch 2/3] Add a WARN() macro; this is WARN_ON() + printk arguments
Date: Wed, 7 May 2008 08:41:31 +0200 [thread overview]
Message-ID: <19f34abd0805062341x21caa29dld03d838057d498e3@mail.gmail.com> (raw)
In-Reply-To: <20080506232113.7f066c26@infradead.org>
Hi!
On Wed, May 7, 2008 at 8:21 AM, Arjan van de Ven <arjan@infradead.org> wrote:
> Subject: Add a WARN() macro; this is WARN_ON() + printk arguments
> From: Arjan van de Ven <arjan@linux.intel.com>
>
> Add a WARN() macro that acts like WARN_ON(), with the added feature that
> it takes a printk like argument that is printed as part of the warning
> message.
[...]
> +#ifndef WARN
> +#define WARN(condition, format...) ({ \
> + int __ret_warn_on = !!(condition); \
> + if (unlikely(__ret_warn_on)) \
> + __WARN_printf(format); \
> + unlikely(__ret_warn_on); \
> +})
> +#endif
Is there a good reason why this is not a static inline function? If
I've understood correctly, we want to turn as many macros as possible
into functions, and I don't see an immediate reason why this one can't
be one.
> +void warn_slowpath(const char *file, int line, const char *fmt, ...)
> +{
> + va_list args;
> +
> +
> + char function[KSYM_SYMBOL_LEN];
> + unsigned long caller = (unsigned long) __builtin_return_address(0);
If WARN() is made a static inline, you can call
__builtin_return_address(0) there and pass it into here instead. This
seems like a kind of low-level internal function anyway, because of
the file/line info.
OTOH, why can't you use __FUNCTION__ or __func__ to determine the
caller (in WARN) rather than doing it here, at run-time? If it's to
save space (or something like that), I think it should be documented?
> + sprint_symbol(function, caller);
> +
> + printk(KERN_WARNING "------------[ cut here ]------------\n");
> + printk(KERN_WARNING "WARNING: at %s:%d %s()\n", file,
> + line, function);
> + va_start(args, fmt);
> + vprintk(fmt, args);
> + va_end(args);
> +
> + print_modules();
> + dump_stack();
> + print_oops_end_marker();
> + add_taint(TAINT_WARN);
> +}
> +EXPORT_SYMBOL(warn_slowpath);
> #endif
Vegard
--
"The animistic metaphor of the bug that maliciously sneaked in while
the programmer was not looking is intellectually dishonest as it
disguises that the error is the programmer's own creation."
-- E. W. Dijkstra, EWD1036
next prev parent reply other threads:[~2008-05-07 6:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-07 6:20 [patch 1/3] Rename WARN() to WARNING() to clear the namespace Arjan van de Ven
2008-05-07 6:21 ` [patch 2/3] Add a WARN() macro; this is WARN_ON() + printk arguments Arjan van de Ven
2008-05-07 6:21 ` [patch 3/3] Example use of WARN() Arjan van de Ven
2008-05-14 4:36 ` Andrew Morton
2008-05-14 4:51 ` Arjan van de Ven
2008-05-15 3:43 ` Arjan van de Ven
2008-05-07 6:41 ` Vegard Nossum [this message]
2008-05-07 13:37 ` [patch 2/3] Add a WARN() macro; this is WARN_ON() + printk arguments Arjan van de Ven
2008-05-07 7:31 ` Jiri Slaby
2008-05-07 12:46 ` [patch 1/3] Rename WARN() to WARNING() to clear the namespace Johannes Weiner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=19f34abd0805062341x21caa29dld03d838057d498e3@mail.gmail.com \
--to=vegard.nossum@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=arjan@infradead.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®