Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3063089ybi; Mon, 17 Jun 2019 15:47:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqxElNqMFvXWQ3LPs+f29DM3KT15wdwiX7tM/JLg9ogTk0cxKkm7J6harPCiXAouSdTb3np3 X-Received: by 2002:a62:d45d:: with SMTP id u29mr51880554pfl.135.1560811676084; Mon, 17 Jun 2019 15:47:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560811676; cv=none; d=google.com; s=arc-20160816; b=obU5Mm91nOTJ4F8tHJlG9aRQSAxN46f37VwK+sdhAS9+MEDVt/3kvtpzKBefLisoOi efjdAI4Bsb/RLZwZwv9dajShWgEgZdvZ7SXKLz9OvB7o/c/MIt5C3PCccMLSxXTbH9iq a/uFS6cmChmnMYGP/vvLvfKmyQ1qfA5z5BPCbmbVmdROWHQ9PNuEVAaPkhkLHtVzMbtT YYkJHy5xhRLPbrs8kxisLsIUXct+5e1E4PVzL0ZqP9wEW6dgrawlSvGo1+TOnK9IjigN HjRYg0pAP6sK+MuYSHCoeJFBPf0vxu6lSA9VhjNyZkrMG6RecKYZeInSTAP39Pd6o06c XsmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=oWCvapawJTmHWfTi4W/xQzd/vam+JtASkBkdfBDmQPA=; b=GgYc88eD+oBDrNGhzSze0g3V8IQhsIprU1+Se1C9/sKKQBCukq6W4wzKqx1Q0gZWLf zqzodal74v6GHpguDXTkOFlFOCOnSJ+mz5fw3dO4tHT0FlSH4tLF2XSU6QI5dH3SfmvV EGaZWCbw0xS0Ux1csWL2ayX5COhj0t4BIMnU6W0lQkeWmpcrMakcU8lfmkr9m8RZ4wZq uQYspc7WjWl2np5OmxxZapgGCGW1j7iaAcWokzC+/5CZJct4XXh8VZje7YDHtm3fRdnk 6FmhU9vf8RKNEi6S7ywrLD1CseVh2TSP1C5PaXLlT9dD5sd8GrRwqOL2z2WEOc50lT4N tx7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=n2EkBbCt; 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 k29si11904774pgl.157.2019.06.17.15.47.41; Mon, 17 Jun 2019 15:47:56 -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=fail header.i=@infradead.org header.s=merlin.20170209 header.b=n2EkBbCt; 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 S1728662AbfFQWr2 (ORCPT + 99 others); Mon, 17 Jun 2019 18:47:28 -0400 Received: from merlin.infradead.org ([205.233.59.134]:40474 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725839AbfFQWr1 (ORCPT ); Mon, 17 Jun 2019 18:47:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=oWCvapawJTmHWfTi4W/xQzd/vam+JtASkBkdfBDmQPA=; b=n2EkBbCtepqSck3LcKcBk9ucLP OopaIKVxH7Ft5pKUkNM6axeXE0K/dN0KlZBFHBkuZUjcuBojBVwA6eyj3zIf/SrSJ0AXP+ap36Tfr X0WYpzcQ34E0H9clamwWKVPA2G5AqZgtlebPbdol2VZl3hzV0WHHKTyO/DPw8RjqxrUZIc7QdVFKM vHCGFyYLYGCxZF9eADucfOb8FK17P9rwh5jOCnBGSKiVmNRqoUfswvbapl0LJeUcbgsSotAmzefsG BuQwk3FdoCSOiq6Zwz2/pJMld3yRBwfY9eWtfMYCawPt2uqyoLPRXHwia2hme5jMcDzrgP6F97p9i 1TAbXIzA==; Received: from static-50-53-52-16.bvtn.or.frontiernet.net ([50.53.52.16] helo=midway.dunlab) by merlin.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hd0P6-0004pi-Aw; Mon, 17 Jun 2019 22:47:08 +0000 Subject: Re: [PATCH v3 2/7] lib/hexdump.c: Relax rowsize checks in hex_dump_to_buffer To: Alastair D'Silva , alastair@d-silva.org Cc: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , Daniel Vetter , Dan Carpenter , Karsten Keil , Jassi Brar , Tom Lendacky , "David S. Miller" , Jose Abreu , Kalle Valo , Stanislaw Gruszka , Benson Leung , Enric Balletbo i Serra , "James E.J. Bottomley" , "Martin K. Petersen" , Greg Kroah-Hartman , Alexander Viro , Petr Mladek , Sergey Senozhatsky , Steven Rostedt , David Laight , Andrew Morton , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, linux-scsi@vger.kernel.org, linux-fbdev@vger.kernel.org, devel@driverdev.osuosl.org, linux-fsdevel@vger.kernel.org References: <20190617020430.8708-1-alastair@au1.ibm.com> <20190617020430.8708-3-alastair@au1.ibm.com> From: Randy Dunlap Message-ID: <94413756-c927-a4ca-dd59-47e3cc87d58d@infradead.org> Date: Mon, 17 Jun 2019 15:47:03 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20190617020430.8708-3-alastair@au1.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Just a comment style nit below... On 6/16/19 7:04 PM, Alastair D'Silva wrote: > From: Alastair D'Silva > > This patch removes the hardcoded row limits and allows for > other lengths. These lengths must still be a multiple of > groupsize. > > This allows structs that are not 16/32 bytes to display on > a single line. > > This patch also expands the self-tests to test row sizes > up to 64 bytes (though they can now be arbitrarily long). > > Signed-off-by: Alastair D'Silva > --- > lib/hexdump.c | 48 ++++++++++++++++++++++++++++-------------- > lib/test_hexdump.c | 52 ++++++++++++++++++++++++++++++++++++++-------- > 2 files changed, 75 insertions(+), 25 deletions(-) > > diff --git a/lib/hexdump.c b/lib/hexdump.c > index 81b70ed37209..3943507bc0e9 100644 > --- a/lib/hexdump.c > +++ b/lib/hexdump.c > @@ -246,17 +248,29 @@ void print_hex_dump(const char *level, const char *prefix_str, int prefix_type, > { > const u8 *ptr = buf; > int i, linelen, remaining = len; > - unsigned char linebuf[32 * 3 + 2 + 32 + 1]; > + unsigned char *linebuf; > + unsigned int linebuf_len; > > - if (rowsize != 16 && rowsize != 32) > - rowsize = 16; > + if (rowsize % groupsize) > + rowsize -= rowsize % groupsize; > + > + /* Worst case line length: > + * 2 hex chars + space per byte in, 2 spaces, 1 char per byte in, NULL > + */ According to Documentation/process/coding-style.rst: The preferred style for long (multi-line) comments is: .. code-block:: c /* * This is the preferred style for multi-line * comments in the Linux kernel source code. * Please use it consistently. * * Description: A column of asterisks on the left side, * with beginning and ending almost-blank lines. */ except in networking software. > + linebuf_len = rowsize * 3 + 2 + rowsize + 1; > + linebuf = kzalloc(linebuf_len, GFP_KERNEL); > + if (!linebuf) { > + printk("%s%shexdump: Could not alloc %u bytes for buffer\n", > + level, prefix_str, linebuf_len); > + return; > + } -- ~Randy