From: Arjan van de Ven <arjan@infradead.org>
To: Arjan van de Ven <arjan@infradead.org>
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org
Subject: [patch 3/3] Example use of WARN()
Date: Tue, 6 May 2008 23:21:56 -0700 [thread overview]
Message-ID: <20080506232156.159ed493@infradead.org> (raw)
In-Reply-To: <20080506232113.7f066c26@infradead.org>
From: Arjan van de Ven <arjan@linux.intel.com>
Subject: Example use of WARN()
now that WARN() exists, we can fold some of the printk's into it
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
---
lib/kobject.c | 9 +++------
1 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/lib/kobject.c b/lib/kobject.c
index 718e510..960f4ed 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -164,9 +164,8 @@ static int kobject_add_internal(struct kobject *kobj)
return -ENOENT;
if (!kobj->name || !kobj->name[0]) {
- pr_debug("kobject: (%p): attempted to be registered with empty "
+ WARN(1, "kobject: (%p): attempted to be registered with empty "
"name!\n", kobj);
- WARN_ON(1);
return -EINVAL;
}
@@ -576,12 +575,10 @@ static void kobject_release(struct kref *kref)
void kobject_put(struct kobject *kobj)
{
if (kobj) {
- if (!kobj->state_initialized) {
- printk(KERN_WARNING "kobject: '%s' (%p): is not "
+ if (!kobj->state_initialized)
+ WARN(1, KERN_WARNING "kobject: '%s' (%p): is not "
"initialized, yet kobject_put() is being "
"called.\n", kobject_name(kobj), kobj);
- WARN_ON(1);
- }
kref_put(&kobj->kref, kobject_release);
}
}
--
1.5.4.5
next prev parent reply other threads:[~2008-05-07 6:22 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 ` Arjan van de Ven [this message]
2008-05-14 4:36 ` [patch 3/3] Example use of WARN() 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 ` [patch 2/3] Add a WARN() macro; this is WARN_ON() + printk arguments Vegard Nossum
2008-05-07 13:37 ` 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=20080506232156.159ed493@infradead.org \
--to=arjan@infradead.org \
--cc=akpm@linux-foundation.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®