Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp912574imm; Wed, 15 Aug 2018 08:13:14 -0700 (PDT) X-Google-Smtp-Source: AA+uWPx6ns37dEU/5ELEfNeGGcRjIa9hgfmMFdJhWo2XlPpQCUuubomcLzL5bqP+f7u9SNJ16PqM X-Received: by 2002:aa7:82c3:: with SMTP id f3-v6mr28190448pfn.136.1534345994924; Wed, 15 Aug 2018 08:13:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534345994; cv=none; d=google.com; s=arc-20160816; b=F3z1EcGh8abjFcKz1O0jAQhNcn6/A6ihSISNyEetZ2IvwrVaEbfwbFQuy3Bmt1/vRw u7ZVd1XS1PFAiDzRFkb3bpsgWNUv4pbTXfhnaIdkDTL3XCStCH0mjvKKq1NrmiNbdtqS 4kJqO6N9wozh7pGFlHjrk3oEWpK+4GRhbGkt0FqQgpi4umrC+K5oM4y/sSH8P/IcMnfp 2C0eRmft1Bn1a90ZW72aDRFscOgeLE+WaNN0pBI2WseCBK00B5PWpF4FNoMybPGwBLpr Tw6e4gvx+OG1iYVYNMNEge9wh89Qx8UjlQ3X7lnZ5biTSzitpGZ9CqOWNQhItGzyT72s jhSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date :arc-authentication-results; bh=hzPEvDbpIrfCrXNwrk69y1afXx0/9WXsxNW+3mcM6nw=; b=ZSG0hgS9HeTJwWksMPv7llG3ZxuRO7Ulfs9sM0uHxE9DNtSPs8OqT6DxAxDV8+AMjT mRZtIGrmajXf4hJsBCiyqPgfqommmQ7RFfiLazuUCYzFJrIAe3coH+Hxn2qwj4XlheW4 lbF43+IcYAb66kq+fPzFZkPRnAThqGvOhI+9137ut+yUJE8NV0IV6I6ZcrlN6Fjy+8LK rIRLiJPkR1x1s56rSblJhuMGm9ud2Drch1BqbaYmXp18/PvJjmTJSL33ab/mEZHMK74L tdtjnSMoxziof9K4Knc1ODMbx+vFoYb+NAlU+MLuhsyUgQG+DEj1/YE4foIl0Ixl1YoX 5h/g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b13-v6si24027249pgb.356.2018.08.15.08.13.00; Wed, 15 Aug 2018 08:13:14 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729527AbeHOR7e (ORCPT + 99 others); Wed, 15 Aug 2018 13:59:34 -0400 Received: from gateway33.websitewelcome.com ([192.185.146.80]:15681 "EHLO gateway33.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729329AbeHOR7e (ORCPT ); Wed, 15 Aug 2018 13:59:34 -0400 Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway33.websitewelcome.com (Postfix) with ESMTP id 7B1371D3BB4 for ; Wed, 15 Aug 2018 10:07:02 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id pxNJfinjfbXuJpxNkf6Wvw; Wed, 15 Aug 2018 10:07:02 -0500 X-Authority-Reason: nr=8 Received: from [189.250.37.72] (port=58842 helo=embeddedor) by gator4166.hostgator.com with esmtpa (Exim 4.91) (envelope-from ) id 1fpxNJ-0036rO-2U; Wed, 15 Aug 2018 10:06:17 -0500 Date: Wed, 15 Aug 2018 10:06:16 -0500 From: "Gustavo A. R. Silva" To: Daniel Thompson , Jason Wessel Cc: kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] kdb: kdb_main: refactor code in kdb_md_line Message-ID: <20180815150616.GA31173@embeddedor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 189.250.37.72 X-Source-L: No X-Exim-ID: 1fpxNJ-0036rO-2U X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedor) [189.250.37.72]:58842 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 4 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- kernel/debug/kdb/kdb_main.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c index 2ddfce8..4b896a6 100644 --- a/kernel/debug/kdb/kdb_main.c +++ b/kernel/debug/kdb/kdb_main.c @@ -1538,25 +1538,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 (i = 0; i < bytesperword; i++) *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