提交 d955c78a 编写于 作者: A Arjan van de Ven 提交者: Linus Torvalds

Example use of WARN()

Now that WARN() exists, we can fold some of the printk's into it.
Signed-off-by: NArjan van de Ven <arjan@linux.intel.com>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 7a2c4770
...@@ -164,9 +164,8 @@ static int kobject_add_internal(struct kobject *kobj) ...@@ -164,9 +164,8 @@ static int kobject_add_internal(struct kobject *kobj)
return -ENOENT; return -ENOENT;
if (!kobj->name || !kobj->name[0]) { 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); "name!\n", kobj);
WARN_ON(1);
return -EINVAL; return -EINVAL;
} }
...@@ -583,12 +582,10 @@ static void kobject_release(struct kref *kref) ...@@ -583,12 +582,10 @@ static void kobject_release(struct kref *kref)
void kobject_put(struct kobject *kobj) void kobject_put(struct kobject *kobj)
{ {
if (kobj) { if (kobj) {
if (!kobj->state_initialized) { if (!kobj->state_initialized)
printk(KERN_WARNING "kobject: '%s' (%p): is not " WARN(1, KERN_WARNING "kobject: '%s' (%p): is not "
"initialized, yet kobject_put() is being " "initialized, yet kobject_put() is being "
"called.\n", kobject_name(kobj), kobj); "called.\n", kobject_name(kobj), kobj);
WARN_ON(1);
}
kref_put(&kobj->kref, kobject_release); kref_put(&kobj->kref, kobject_release);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册