Skip to contentSkip to conversation

lockdep: Use different indentation in print_lock_class_header/print_lock_trace

PATCH New Joe Perches 1 participant 1 message May 20, 2020 Locking primitives

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 lockdep: Use different indentation in print_lock_class_header/print_lock_trace

This code that uses the printk return value in kernel/locking/lockdep.c is odd because the printk return value includes both the length of a KERN_<LEVEL> prefix and a newline. depth is also double counted.

Change the code to use depth + 3 + strlen.

---

v2: sigh: add missing close parenthesis, dunno what happened

 kernel/locking/lockdep.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
kernel/locking/lockdep.c +3 -5
index 2fadc2635946..265227edc550 100644
@@ -1960,11 +1960,9 @@ static void print_lock_class_header(struct lock_class *class, int depth)
 
 	for (bit = 0; bit < LOCK_USAGE_STATES; bit++) {
 		if (class->usage_mask & (1 << bit)) {
-			int len = depth;
-
-			len += printk("%*s   %s", depth, "", usage_str[bit]);
-			len += printk(KERN_CONT " at:\n");
-			print_lock_trace(class->usage_traces[bit], len);
+			printk("%*s   %s at:\n", depth, "", usage_str[bit]);
+			print_lock_trace(class->usage_traces[bit],
+					 depth + 3 + strlen(usage_str[bit]));
 		}
 	}
 	printk("%*s }\n", depth, "");