From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D5D6C31E5C for ; Mon, 17 Jun 2019 22:47:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F4168208C0 for ; Mon, 17 Jun 2019 22:47:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="n2EkBbCt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728434AbfFQWr2 (ORCPT ); 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-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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