Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752557AbdLHSeW (ORCPT ); Fri, 8 Dec 2017 13:34:22 -0500 Received: from mail.windriver.com ([147.11.1.11]:38769 "EHLO mail.windriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751268AbdLHSeV (ORCPT ); Fri, 8 Dec 2017 13:34:21 -0500 Subject: Re: [PATCH 2/3] kdb: drop newline in unknown command output To: Randy Dunlap , LKML , CC: Daniel Thompson References: <3ca9b50e-b297-8995-c93c-e56fb91c3a47@infradead.org> From: Jason Wessel Message-ID: <5165029d-3b50-2c35-518a-f7ab80b63f36@windriver.com> Date: Fri, 8 Dec 2017 12:33:38 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <3ca9b50e-b297-8995-c93c-e56fb91c3a47@infradead.org> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1863 Lines: 61 On 12/08/2017 12:19 PM, Randy Dunlap wrote: > From: Randy Dunlap > Thanks for the series Randy. I'll get these applied, but I will take a look at changing this patch slightly. > When an unknown command is entered, kdb prints "Unknown kdb command:" > and then the unknown text, including the newline character. This > causes the ending single-quote mark to be printed on the next line > by itself, so just change the ending newline character to a null > character (end of string) so that it won't be "printed." > > Signed-off-by: Randy Dunlap > Cc: Daniel Thompson > Cc: Jason Wessel > Cc: kgdb-bugreport@lists.sourceforge.net > --- > kernel/debug/kdb/kdb_main.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > --- lnx-415-rc1.orig/kernel/debug/kdb/kdb_main.c > +++ lnx-415-rc1/kernel/debug/kdb/kdb_main.c > @@ -1150,6 +1150,16 @@ void kdb_set_current_task(struct task_st > kdb_current_regs = NULL; > } > > +static void drop_newline(char *buf) > +{ > + size_t len = strlen(buf); > + > + if (len == 0) > + return; > + if (*(buf + len - 1) == '\n') > + *(buf + len - 1) = '\0'; > +} > + > /* > * kdb_local - The main code for kdb. This routine is invoked on a > * specific processor, it is not global. The main kdb() routine > @@ -1327,6 +1337,7 @@ do_full_getstr: > cmdptr = cmd_head; > diag = kdb_parse(cmdbuf); > if (diag == KDB_NOTFOUND) { > + drop_newline(cmdbuf); We might be able to get away with just adjusting the pointer in the kdb_parse instead of adding the drop_newline because we are returning error anyway and the parse needs to be called again in the future for a new command. Thanks, Jason. > kdb_printf("Unknown kdb command: '%s'\n", cmdbuf); > diag = 0; > } > >