Skip to content

Commit

Permalink
printk: suppress empty continuation lines
Browse files Browse the repository at this point in the history
We have a fairly common pattern where you print several things as
continuations on one single line in a loop, and then at the end you do

	printk(KERN_CONT "\n");

to flush the buffered output.

But if the output was flushed by something else (concurrent printk
activity, or just system logging), we don't want that final flushing to
just print an empty line.

So just suppress empty continuation lines when they couldn't be merged
into the line they are a continuation of.

Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
torvalds committed Oct 19, 2016
1 parent 63ae602 commit 8835ca5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kernel/printk/printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1769,6 +1769,10 @@ static size_t log_output(int facility, int level, enum log_flags lflags, const c
cont_flush();
}

/* Skip empty continuation lines that couldn't be added - they just flush */
if (!text_len && (lflags & LOG_CONT))
return 0;

/* If it doesn't end in a newline, try to buffer the current line */
if (!(lflags & LOG_NEWLINE)) {
if (cont_add(facility, level, lflags, text, text_len))
Expand Down

0 comments on commit 8835ca5

Please sign in to comment.