Skip to content

Commit

Permalink
Example use of WARN()
Browse files Browse the repository at this point in the history
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>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Arjan van de Ven authored and Linus Torvalds committed Jul 25, 2008
1 parent 7a2c477 commit d955c78
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/kobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -583,12 +582,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);
}
}
Expand Down

0 comments on commit d955c78

Please sign in to comment.