From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1763278AbcJaIvw (ORCPT ); Mon, 31 Oct 2016 04:51:52 -0400 Received: from mx2.suse.de ([195.135.220.15]:42245 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1763219AbcJaIvv (ORCPT ); Mon, 31 Oct 2016 04:51:51 -0400 Date: Mon, 31 Oct 2016 09:51:47 +0100 From: David Sterba To: Petr Mladek Cc: Linus Torvalds , Chris Mason , Josef Bacik , Sergey Senozhatsky , Steven Rostedt , Andrew Morton , Joe Perches , Jaroslav Kysela , Takashi Iwai , linux-kernel@vger.kernel.org, Jason Wessel Subject: Re: [PATCH 1/4] printk/NMI: Handle continuous lines and missing newline Message-ID: <20161031085147.GN12522@suse.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, Petr Mladek , Linus Torvalds , Chris Mason , Josef Bacik , Sergey Senozhatsky , Steven Rostedt , Andrew Morton , Joe Perches , Jaroslav Kysela , Takashi Iwai , linux-kernel@vger.kernel.org, Jason Wessel References: <1477583574-30988-1-git-send-email-pmladek@suse.com> <1477583574-30988-2-git-send-email-pmladek@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1477583574-30988-2-git-send-email-pmladek@suse.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 27, 2016 at 05:52:51PM +0200, Petr Mladek wrote: > +static int printk_nmi_flush_buffer(unsigned char *start, size_t len) > { > - const char *buf = s->buffer + start; > + unsigned char *c, *end; > + bool header; > + > + c = start; > + end = start + len; > + header = true; > + > + /* Print line by line. */ > + while (c < end) { > + if (*c == '\n') { > + printk_nmi_flush_line(start, c - start + 1); > + start = ++c; > + header = true; > + continue; > + } > > - printk_nmi_flush_line(buf, (end - start) + 1); > + /* Handle continuous lines or missing new line. */ > + if ((c + 1 < end) && printk_get_level(c)) { > + if (header) { > + c += 2; > + continue; > + } > + > + printk_nmi_flush_line(start, c - start); > + start = c++; > + header = true; > + continue; > + } > + > + header = false; > + c++; > + } > + > + /* Check if there was a partial line. Ignore pure header. */ > + if (start < end && !header) { > + printk_nmi_flush_line(start, end - start); > + printk_nmi_flush_line("\n", strlen("\n")); Not introduced by this patch as it was in the original code and the compiler is smart enough to replace strlen("\n") with 1, but still it looks strange.