Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp461932yba; Fri, 12 Apr 2019 07:06:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqy5Kz/C5V/Nqg+kZPlIA9OT5LgvEm/ufVukDuuGBe1RMY+mh3+yoCIQbJ6lCIITPROcu9Uf X-Received: by 2002:a17:902:e391:: with SMTP id ch17mr58661476plb.196.1555077982427; Fri, 12 Apr 2019 07:06:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555077982; cv=none; d=google.com; s=arc-20160816; b=GWPFf/SYK9i1gq+LwTcPEbXNnJtPYNAng1BFJx9EXg9CRtW/CSyC/+LSOxcVM8Q5uO 0KcxYI+E6sgLGOh0s+GvNj1Gb2dw0TxqOtZ12xNiU2cZGIuT/8W/9ZzTAOaUm4itXw4V YwS4T3bWG6jnsbU0NaWoVepbTvRzIUXPhR4SM/BosIDy32y12lTMSBLBTZAsXECF1oZG rZFOA0nvPmEBDpUp6FegLWl+Aey2VMr5ES2ZYg/AgO97qkZ7bJli2xO/dDsOrzSMpFXT IqQz8CllUmHNS6y8OOG5Oq9d/ouk6MJJ/PZRuaO+rrPTR9dAkBbQRsKN6rlaCLmisb6B DsIg== 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=jsQGNH/tLdBoL1Gr/tyYJ8pO2tQaBhECrggv2D3u5QA=; b=1K4gBqfgu/8SSHwg6pmlEiNAo825jVVc1Dz/R7+6o8sJb0kJwyCLmUlnDCpEemsay4 yu3LZV1wlVTHtvpPxa0tbZjw/+7WutYr6htBISBD3LUNl0YO7S6IttBgxRUsrfPxMiI/ F7AEl8drZQAXk6+hA0jvJr0SoGUQhZ9u/9aoXMLavrrnmdgiLSCvpZXZlHQTcPJNMVQD 8ulFR4Et3sOq0Dn6oTtUJCpfgLY2hYVzXZjLtxeKaHyrp7//M4xyP6KQ1nG52fx1BRfU S5jbDdcqc/b8LHi/F5nyrM7I9P3GL+Zj0difHWqMR9xS1FLnLj0Wb6ruH0qO6EsTyBIc QoOA== 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 y8si28610468plt.119.2019.04.12.07.06.06; Fri, 12 Apr 2019 07:06:22 -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 S1727039AbfDLOD6 (ORCPT + 99 others); Fri, 12 Apr 2019 10:03:58 -0400 Received: from mx2.suse.de ([195.135.220.15]:51920 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726714AbfDLOD6 (ORCPT ); Fri, 12 Apr 2019 10:03:58 -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 D5469AD63; Fri, 12 Apr 2019 14:03:54 +0000 (UTC) Date: Fri, 12 Apr 2019 16:03:53 +0200 From: Petr Mladek 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 Message-ID: <20190412140353.mgvksn3yk6n65hbk@pathway.suse.cz> References: <20190410031720.11067-1-alastair@au1.ibm.com> <20190410031720.11067-3-alastair@au1.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190410031720.11067-3-alastair@au1.ibm.com> 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 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. I wonder how it would look like when we print something like: --- skipped XX lines full of 0x00 --- Then we might even remove the SUPPRESS_FIRST, SUPPRESS_LAST and the ambiguous QUIET flags. > + > + first_line = false; This should be above the if (skip). > + > hex_dump_to_buffer(ptr + i, linelen, rowsize, groupsize, > - linebuf, sizeof(linebuf), ascii); > + linebuf, sizeof(linebuf), > + flags & HEXDUMP_ASCII); > > switch (prefix_type) { > case DUMP_PREFIX_ADDRESS: > @@ -272,7 +316,7 @@ void print_hex_dump(const char *level, const char *prefix_str, int prefix_type, > } > } > } > -EXPORT_SYMBOL(print_hex_dump); > +EXPORT_SYMBOL(print_hex_dump_ext); We should still export even the original function that is still used everywhere. Best Regards, Petr