Skip to content

Commit 5cd2b45

Browse files
fenrus75torvalds
authored andcommitted
Use WARN() in lib/
Use WARN() instead of a printk+WARN_ON() pair; this way the message becomes part of the warning section for better reporting/collection. In addition, one of the if() clauses collapes into the WARN() entirely now. Signed-off-by: Arjan van de Ven <arjan@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent f810a5c commit 5cd2b45

4 files changed

Lines changed: 15 additions & 22 deletions

File tree

‎lib/debugobjects.c‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,8 @@ static void debug_print_object(struct debug_obj *obj, char *msg)
205205

206206
if (limit < 5 && obj->descr != descr_test) {
207207
limit++;
208-
printk(KERN_ERR "ODEBUG: %s %s object type: %s\n", msg,
208+
WARN(1, KERN_ERR "ODEBUG: %s %s object type: %s\n", msg,
209209
obj_states[obj->state], obj->descr->name);
210-
WARN_ON(1);
211210
}
212211
debug_objects_warnings++;
213212
}
@@ -733,26 +732,22 @@ check_results(void *addr, enum debug_obj_state state, int fixups, int warnings)
733732

734733
obj = lookup_object(addr, db);
735734
if (!obj && state != ODEBUG_STATE_NONE) {
736-
printk(KERN_ERR "ODEBUG: selftest object not found\n");
737-
WARN_ON(1);
735+
WARN(1, KERN_ERR "ODEBUG: selftest object not found\n");
738736
goto out;
739737
}
740738
if (obj && obj->state != state) {
741-
printk(KERN_ERR "ODEBUG: selftest wrong state: %d != %d\n",
739+
WARN(1, KERN_ERR "ODEBUG: selftest wrong state: %d != %d\n",
742740
obj->state, state);
743-
WARN_ON(1);
744741
goto out;
745742
}
746743
if (fixups != debug_objects_fixups) {
747-
printk(KERN_ERR "ODEBUG: selftest fixups failed %d != %d\n",
744+
WARN(1, KERN_ERR "ODEBUG: selftest fixups failed %d != %d\n",
748745
fixups, debug_objects_fixups);
749-
WARN_ON(1);
750746
goto out;
751747
}
752748
if (warnings != debug_objects_warnings) {
753-
printk(KERN_ERR "ODEBUG: selftest warnings failed %d != %d\n",
749+
WARN(1, KERN_ERR "ODEBUG: selftest warnings failed %d != %d\n",
754750
warnings, debug_objects_warnings);
755-
WARN_ON(1);
756751
goto out;
757752
}
758753
res = 0;

‎lib/iomap.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ static void bad_io_access(unsigned long port, const char *access)
4040
static int count = 10;
4141
if (count) {
4242
count--;
43-
printk(KERN_ERR "Bad IO access at port %#lx (%s)\n", port, access);
44-
WARN_ON(1);
43+
WARN(1, KERN_ERR "Bad IO access at port %#lx (%s)\n", port, access);
4544
}
4645
}
4746

‎lib/kobject_uevent.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,7 @@ int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...)
285285
int len;
286286

287287
if (env->envp_idx >= ARRAY_SIZE(env->envp)) {
288-
printk(KERN_ERR "add_uevent_var: too many keys\n");
289-
WARN_ON(1);
288+
WARN(1, KERN_ERR "add_uevent_var: too many keys\n");
290289
return -ENOMEM;
291290
}
292291

@@ -297,8 +296,7 @@ int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...)
297296
va_end(args);
298297

299298
if (len >= (sizeof(env->buf) - env->buflen)) {
300-
printk(KERN_ERR "add_uevent_var: buffer size too small\n");
301-
WARN_ON(1);
299+
WARN(1, KERN_ERR "add_uevent_var: buffer size too small\n");
302300
return -ENOMEM;
303301
}
304302

‎lib/plist.c‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@
3131
static void plist_check_prev_next(struct list_head *t, struct list_head *p,
3232
struct list_head *n)
3333
{
34-
if (n->prev != p || p->next != n) {
35-
printk("top: %p, n: %p, p: %p\n", t, t->next, t->prev);
36-
printk("prev: %p, n: %p, p: %p\n", p, p->next, p->prev);
37-
printk("next: %p, n: %p, p: %p\n", n, n->next, n->prev);
38-
WARN_ON(1);
39-
}
34+
WARN(n->prev != p || p->next != n,
35+
"top: %p, n: %p, p: %p\n"
36+
"prev: %p, n: %p, p: %p\n"
37+
"next: %p, n: %p, p: %p\n",
38+
t, t->next, t->prev,
39+
p, p->next, p->prev,
40+
n, n->next, n->prev);
4041
}
4142

4243
static void plist_check_list(struct list_head *top)

0 commit comments

Comments
 (0)