Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1977303yba; Mon, 15 Apr 2019 02:19:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxr3daec8ozq54do2lGIx/mUrsIPSPfE0f6ARkUahhbw2sUNTjVFB+prhdM+WHgxoSYtanu X-Received: by 2002:a63:d250:: with SMTP id t16mr67531875pgi.288.1555319970504; Mon, 15 Apr 2019 02:19:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555319970; cv=none; d=google.com; s=arc-20160816; b=Ci2PwirYxbY8K1YjEGUyOMAYTktobaPuPRfo1LjRrNGsMKIoteMvvXpo5YrWhSfj3h EWzOJP0/91kNeVH+/hYUT7Zk7wW6gGqhZaNsrCJgWJ9XeXG+QoJkj2mTPcv6SNY5OW4p fJn7DWO0LnbIG4LY/hJsB4gWYpsvqfoSoo84IxTpat7nMea/oC7jz1S29C4NnDZGrxfP nfpxj+D3HT79cXbvP/yu38WkvBL2Ie5HiKs48q3POQuepBKW8lqZHVan+tITJldP3wki ezD1NnWQeWeJ+J9T+28XxBTRsFDy2RlWvDeBPy5MQ3S2hbkNvmJkQ9C8ihH1hTDulS7Z ipqg== 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; bh=aOLaFnh9z+teMzc9njt3yVw5badOFO0+8dUNda9UcQU=; b=SVVShuWnihEzTRrzRVGn7SeMo/lJiBif8oj1sAGE8az427PVzliGrVjtImA9UD0GV7 wmbELEWb0HHPV2oO/1xdFDEyLMmIqlsyQBFLY0m7lkfORO0zyLV1RtAXFWGlUey6a+e8 UG2p+0lXvEjvyOtwRbm8W2T+kRilKg5zp99D0EvVCM2K9P2LrGeOGWSQGRwO2CBawoVA +8lli0/8PJ+lGmucwJxreL59IY/SFv6cQOhad2nXM+txKNUaKH1k/QwiAoYKAXUYqMQS eqoPgNmhi9jlnn3Rs1Ex2knGHtPP/1u6nSXWU/aR1l4fKDmQtLrCQGtXjrI/LdjK2JsP T7Rg== 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 v18si22133955plo.394.2019.04.15.02.19.14; Mon, 15 Apr 2019 02:19:30 -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 S1727114AbfDOJSS (ORCPT + 99 others); Mon, 15 Apr 2019 05:18:18 -0400 Received: from mx2.suse.de ([195.135.220.15]:52350 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725939AbfDOJSR (ORCPT ); Mon, 15 Apr 2019 05:18:17 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 69A23B008; Mon, 15 Apr 2019 09:18:14 +0000 (UTC) Date: Mon, 15 Apr 2019 11:18:12 +0200 From: Petr Mladek To: Alastair D'Silva Cc: 'Alastair D'Silva' , 'Jani Nikula' , 'Joonas Lahtinen' , 'Rodrigo Vivi' , 'David Airlie' , 'Daniel Vetter' , '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' , 'Sergey Senozhatsky' , 'Steven Rostedt' , '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 Subject: Re: [PATCH 2/4] lib/hexdump.c: Optionally suppress lines of filler bytes Message-ID: <20190415091812.s4e5zlwldbe62ego@pathway.suse.cz> References: <20190410031720.11067-1-alastair@au1.ibm.com> <20190410031720.11067-3-alastair@au1.ibm.com> <20190412140353.mgvksn3yk6n65hbk@pathway.suse.cz> <093101d4f187$612f0f20$238d2d60$@d-silva.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <093101d4f187$612f0f20$238d2d60$@d-silva.org> User-Agent: NeoMutt/20170912 (1.9.0) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat 2019-04-13 09:28:03, Alastair D'Silva wrote: > > -----Original Message----- > > From: Petr Mladek > > Sent: Saturday, 13 April 2019 12:04 AM > > To: Alastair D'Silva > > Cc: alastair@d-silva.org; Jani Nikula ; > Joonas > > Lahtinen ; Rodrigo Vivi > > ; David Airlie ; Daniel Vetter > > ; 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 > > ; Sergey Senozhatsky > > ; Steven Rostedt ; > > 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 > > Subject: Re: [PATCH 2/4] lib/hexdump.c: Optionally suppress lines of > filler > > bytes > > > > On Wed 2019-04-10 13:17:18, Alastair D'Silva wrote: > > > From: Alastair D'Silva > > > > > > Some buffers may only be partially filled with useful data, while the > > > rest is padded (typically with 0x00 or 0xff). > > > > > > This patch introduces flags which allow lines of padding bytes to be > > > suppressed, making the output easier to interpret: > > > HEXDUMP_SUPPRESS_0X00, HEXDUMP_SUPPRESS_0XFF > > > > > > The first and last lines are not suppressed by default, so the > > > function always outputs something. This behaviour can be further > > > controlled with the HEXDUMP_SUPPRESS_FIRST & > > HEXDUMP_SUPPRESS_LAST flags. > > > > > > An inline wrapper function is provided for backwards compatibility > > > with existing code, which maintains the original behaviour. > > > > > > > > diff --git a/lib/hexdump.c b/lib/hexdump.c index > > > b8a164814744..2f3bafb55a44 100644 > > > --- a/lib/hexdump.c > > > +++ b/lib/hexdump.c > > > +void print_hex_dump_ext(const char *level, const char *prefix_str, > > > + int prefix_type, int rowsize, int groupsize, > > > + const void *buf, size_t len, u64 flags) > > > { > > > const u8 *ptr = buf; > > > - int i, linelen, remaining = len; > > > + int i, remaining = len; > > > unsigned char linebuf[64 * 3 + 2 + 64 + 1]; > > > + bool first_line = true; > > > > > > if (rowsize != 16 && rowsize != 32 && rowsize != 64) > > > rowsize = 16; > > > > > > for (i = 0; i < len; i += rowsize) { > > > - linelen = min(remaining, rowsize); > > > + bool skip = false; > > > + int linelen = min(remaining, rowsize); > > > + > > > remaining -= rowsize; > > > > > > + if (flags & HEXDUMP_SUPPRESS_0X00) > > > + skip = buf_is_all(ptr + i, linelen, 0x00); > > > + > > > + if (!skip && (flags & HEXDUMP_SUPPRESS_0XFF)) > > > + skip = buf_is_all(ptr + i, linelen, 0xff); > > > + > > > + if (first_line && !(flags & HEXDUMP_SUPPRESS_FIRST)) > > > + skip = false; > > > + > > > + if (remaining <= 0 && !(flags & HEXDUMP_SUPPRESS_LAST)) > > > + skip = false; > > > + > > > + if (skip) > > > + continue; > > > > IMHO, quietly skipping lines could cause a lot of confusion, espcially > when the address is not printed. > > > It's up to the caller to decide how they want it displayed. I wonder who would want to quietly skip some data values. Are you using it yourself? Could you please provide an example? I do not see why we would need to complicate the API and code by this. The behavior proposed by Tvrtko Ursulin makes much more sense. I mean https://lkml.kernel.org/r/929244ed-cc7f-b0f3-b5ac-50e798e83188@linux.intel.com > > I wonder how it would look like when we print something like: > > > > --- skipped XX lines full of 0x00 --- > > This could be added as a later enhancement, with a new flag (eg. > HEXDUMP_SUPPRESS_VERBOSE). Who will add this later? Frankly, this looks like a half baked feature that it good enough for you. If you want it upstream, it must behave reasonably and it must be worth it. Best Regards, Petr