Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp512393imm; Fri, 17 Aug 2018 01:45:57 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxShXMiQVsIAnILRviKmXVRhI79JZGI4Qe08gh0AgF83fj8jH9rF5t53rticw2ooTw7WG1v X-Received: by 2002:a62:8a4f:: with SMTP id y76-v6mr35821025pfd.233.1534495557384; Fri, 17 Aug 2018 01:45:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534495557; cv=none; d=google.com; s=arc-20160816; b=HL8XFGlXCIBAVXq9P4KcA5jHwQq+gJzO9/B9vlvYqiIa3DHYeTKE6dbmywAG0hwiAM sf20QkzdIeqUb8ajFion8v6H/LjWybE270aYfpUBbaNKO3vjd4O7KAsJiHYbCVeDgyKw BgtBvvOsakY9RIyLP0SzQBgjAv/atG48pBYNY9wf4blPNOjYt6toL/O9DhbJJ52CWTI0 eKDiLRqfkO12S9eGEqDcia1eAW5A/OF2zoFfX03+JsoVamFIjZG55Zk6rtax5wqytEbs edC1/aVvvZkyJxWVMDfjW3/7Ywqjso0NrtqmkWX0fdGRPRPMRLNeXOjIEMK3EBN+CVmO 6R5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=CrY+KJctFbw4AVPhHRgoye4LLjyBDIvZauxXJpZhsfQ=; b=yGjPguDBNaXIYlonqYUm6Xznt7Dfjhj0x8HQy1NjGr76vPEU+Q7TLG+37iGdMs3fe8 V2eVkyrS4ErvLhi/TDb7/+TN7LraB2QkI62+9GbuBvZUGiSmFAlJmB1Y15XP6yshkT8d 9MzvVWOjvTidrY2P8O+aJ46+yWx/v3xVJ75nT+Ax94ohwxYiyI2g9F80VP1kCSkCqteP CdQSv9lLtu+816GPKQP/uZtrm30gsWs8KbpBn+hm5XtqksYx4LdGdRFtySB3Zh1WvZGr 7wG+4qvF8Ktqq19+NzOO/254+HNsqqebHmBpsPCNm5pKzzGzIboFMWUjd26MOn+FMC7I mXCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LChmcydZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f26-v6si1593013pgm.428.2018.08.17.01.45.41; Fri, 17 Aug 2018 01:45:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LChmcydZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726450AbeHQLqk (ORCPT + 99 others); Fri, 17 Aug 2018 07:46:40 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:54120 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725992AbeHQLqk (ORCPT ); Fri, 17 Aug 2018 07:46:40 -0400 Received: by mail-wm0-f65.google.com with SMTP id s9-v6so6852340wmh.3 for ; Fri, 17 Aug 2018 01:44:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=CrY+KJctFbw4AVPhHRgoye4LLjyBDIvZauxXJpZhsfQ=; b=LChmcydZ7CbFnmSDmkbM7JRTPXxp1KeeKa+8PhxBHigAjVFmwq0uC4uSxd84FkdU8b waeuaTFj8Y/v+RLJRT3CMF6lfPkjvAQRCjuvMkn02fgQu4e5HbBCSbkUlzQbqYGUKiIB 0UoUT+d1zPZV1TtWz03ZtGKKQYTUPRzHBfyqU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=CrY+KJctFbw4AVPhHRgoye4LLjyBDIvZauxXJpZhsfQ=; b=A0cCys4QEpj+aawqCbBkBkbnYkQkxnsJLiQDujUbRv/uvrTe0xL9t4DGyqdXnoz4Eu wiRqM4TvbKh/WOrevFraqyreWflw/dmpqAPXJrhAXk0GsdRQQcA2klRwMySQ+ERwPCYI usOJ5hhobiCozv0XX8xHrBULrKI6Gu+Xi/6GETWdTOq6TOAg4QRXIrJvn73dlGP8ZyIa Ez//MeHKHyDQ3FfFxSC2AnY1tEE/jqEtwJ5k9O5Aa/jHyjKW0CyyIvGOp2szhuQ1ESa2 9yPXkEenONNPwsaNCaglkBLNXPLdv8pwt3kU5Xs+se/ncnH7t/DWmZu1wFrzTqSFFOet hSsA== X-Gm-Message-State: AOUpUlHeWyJaroprw08duwIJHlU/gVTlMCHJ3DRfyXw6hDr3Ww1GoBoQ ppJBEoqZK9T31OPBA4q2VkfOig== X-Received: by 2002:a1c:c7c1:: with SMTP id x184-v6mr17749891wmf.134.1534495446801; Fri, 17 Aug 2018 01:44:06 -0700 (PDT) Received: from holly.lan (89-145-231-170.xdsl.murphx.net. [89.145.231.170]) by smtp.gmail.com with ESMTPSA id s5-v6sm1290880wro.33.2018.08.17.01.44.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 17 Aug 2018 01:44:05 -0700 (PDT) Date: Fri, 17 Aug 2018 09:44:02 +0100 From: Daniel Thompson To: "Gustavo A. R. Silva" Cc: Jason Wessel , kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] kdb: kdb_main: refactor code in kdb_md_line Message-ID: <20180817084402.ccqulr3mei6mjxgs@holly.lan> References: <20180816140141.GA28913@embeddedor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180816140141.GA28913@embeddedor.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 16, 2018 at 09:01:41AM -0500, Gustavo A. R. Silva wrote: > Replace the whole switch statement with a for loop. > This makes the code much clear and easy to read. > > This also addresses the following Coverity warnings: > > Addresses-Coverity-ID: 115090 ("Missing break in switch") > Addresses-Coverity-ID: 115091 ("Missing break in switch") > Addresses-Coverity-ID: 114700 ("Missing break in switch") > > Suggested-by: Daniel Thompson > Signed-off-by: Gustavo A. R. Silva Reviewed-by: Daniel Thompson > --- > Changes in v2: > - Add new variable j and use it for the for loop. > > kernel/debug/kdb/kdb_main.c | 21 +++------------------ > 1 file changed, 3 insertions(+), 18 deletions(-) > > diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c > index 2ddfce8..a9ad288 100644 > --- a/kernel/debug/kdb/kdb_main.c > +++ b/kernel/debug/kdb/kdb_main.c > @@ -1493,6 +1493,7 @@ static void kdb_md_line(const char *fmtstr, unsigned long addr, > char cbuf[32]; > char *c = cbuf; > int i; > + int j; > unsigned long word; > > memset(cbuf, '\0', sizeof(cbuf)); > @@ -1538,25 +1539,9 @@ static void kdb_md_line(const char *fmtstr, unsigned long addr, > wc.word = word; > #define printable_char(c) \ > ({unsigned char __c = c; isascii(__c) && isprint(__c) ? __c : '.'; }) > - switch (bytesperword) { > - case 8: > + for (j = 0; j < bytesperword; j++) > *c++ = printable_char(*cp++); > - *c++ = printable_char(*cp++); > - *c++ = printable_char(*cp++); > - *c++ = printable_char(*cp++); > - addr += 4; > - case 4: > - *c++ = printable_char(*cp++); > - *c++ = printable_char(*cp++); > - addr += 2; > - case 2: > - *c++ = printable_char(*cp++); > - addr++; > - case 1: > - *c++ = printable_char(*cp++); > - addr++; > - break; > - } > + addr += bytesperword; > #undef printable_char > } > } > -- > 2.7.4 >