Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2031751yba; Mon, 15 Apr 2019 03:36:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCU4ShLfVaLF36xUQ7BRmbkSftSgBHlRKsTvtQgcN0wPnDbyFOyVRPtDOzPBEVufN1CIN0 X-Received: by 2002:a17:902:bb84:: with SMTP id m4mr35151903pls.302.1555324561070; Mon, 15 Apr 2019 03:36:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555324561; cv=none; d=google.com; s=arc-20160816; b=0ZQVwNrSMADqzjd0xD7i6kiRUyQj7dbx4DewicxhS19E7uZi2c/VwJF1jzclVSVoRj N2fASQgeWtDWaRuMaLv5v3azTYx6fVvRl6jHiFmvl47hXzFpkIYL/zEc/G05xLJkN3qi F5LxyCWtjlhK+6k6ch/NCY/2j/NAYtSUnu5LgRyecDqU1esbh9Of2R7iriJ3e1h92EKt lGHGYDXNI6S6IyQV5DuL1g1KqqaBcMsYT9jss1vYrgOGUW6DoP9CBCxWs0UQ64zRRYT8 /Kqcld/wGCgcyPvuqWVl0Oo1+f0ItQXXcdIcUskczmULldX1uAmTpA1q+LG/S2VP6uan D7rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language:thread-index :content-transfer-encoding:mime-version:message-id:date:subject :in-reply-to:references:cc:to:from:dkim-signature; bh=1vfq3ttx5hP93ZfrC1vUP5TdLe70RqHeS9RzNW82+uo=; b=na9J4Psll0RtJ7h9jdOOoMrdzk5qvNwj7/zKccYa9ZKTjATEOSaNxikuZEP1+hj9Yv QkBMzp9hDojqNVL73b80PrNg2Rw3u7jpneSJahLCyK/OcWF0u5MO0SpxxDew+RHHglpJ Ucb3AGh/tX8n0gbN37XAt2vb6UDGn4kR+AepAk57XBptm85nYXSQpsR5CW/JEg68N7SU yAEN4x5F2rmo9qJO6yqYlgt5gsW+eEPgF8hLiigFIDvGO9pWRz3Qz8wlgfsVq/tBMb9d bszviCLScc1Y7zHuBtGC0iFaeeQNva1rx5kV6LTJ7Bsd8ubxf1UYnSGwV4YUsnY6bN81 Omsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@d-silva.org header.s=201810a header.b=EwBjsqWx; 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 a13si44214027pgh.139.2019.04.15.03.35.44; Mon, 15 Apr 2019 03:36:01 -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=pass header.i=@d-silva.org header.s=201810a header.b=EwBjsqWx; 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 S1727149AbfDOKd5 (ORCPT + 99 others); Mon, 15 Apr 2019 06:33:57 -0400 Received: from ushosting.nmnhosting.com ([167.160.173.127]:47088 "EHLO ushosting.nmnhosting.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726042AbfDOKd4 (ORCPT ); Mon, 15 Apr 2019 06:33:56 -0400 Received: from mail2.nmnhosting.com (unknown [202.169.106.97]) by ushosting.nmnhosting.com (Postfix) with ESMTPS id 9D7572F28FBB; Mon, 15 Apr 2019 06:33:54 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=d-silva.org; s=201810a; t=1555324435; bh=72lI9NwZgSFecdEJvPmdYhwBylZIqtjY6AZr2qW5LC0=; h=From:To:Cc:References:In-Reply-To:Subject:Date:From; b=EwBjsqWxQozr5w1lJlRrUp2D5MRPGXh/T7co5sbf+E8hadFRpBw6vctj7pgbDMQ0M vUkuSsXv0DkMzT99YmDYW279lCLac6pr6k+Ejl6Q/CrCo4W91mAYd4ufx7RRFh3pVZ kKAnFFgnJhJIJTZEqYrF1NBbZGsvt7r7riP9TapDFwB8maC+Vhhu5SWqdsxS8UU6y2 hZivCh9IgHt0isApMS04xSX+cpkT8LpS463Ac81akd1qYRvtshPkQPjNbTPFG20qf+ TELCtZhznvd1eryR3rWbUFdmQTVRaRcb4vNE2nL9ye+oP3m8xu4KxvuMLz8vzAkSDU TME2DgDraD0lbxfl/Vl/J8Sw7bWKQKznrFmg4ZsbQ3sg7rqHRGoxUcXg0jzrUAvjBw lA2XiiLQloaWnez0NnYYVBqpGWXJsIORe7f/UxlcGuVH+1nO0dVfjwXCPENX0X7YUs zg/nOXEC1OhkYKtaTdQp9WWyblKAyheYc2g8jiNHxH/LRvugedjqzJuyTFpIBCsz2H QkZFa7LezzA7paw7xtNyd49a1YmEbphLgnjQqt1dk5E1TJHmQzk1pkG05xV6qSX/jD L+xFIxw7v6i936nx9qbqc8WOnQIjC8g9T5xtUJ57hoMJn+hfYJ3s+TE5U5uN8OOFyx AoXGXh0QT4oyWmYonJgxfYkE= Received: from Hawking (ntp.lan [10.0.1.1]) (authenticated bits=0) by mail2.nmnhosting.com (8.15.2/8.15.2) with ESMTPSA id x3FAXnup038604 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 15 Apr 2019 20:33:49 +1000 (AEST) (envelope-from alastair@d-silva.org) From: "Alastair D'Silva" To: "'Petr Mladek'" 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'" , , , , , , , , , , 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> <20190415091812.s4e5zlwldbe62ego@pathway.suse.cz> In-Reply-To: <20190415091812.s4e5zlwldbe62ego@pathway.suse.cz> Subject: RE: [PATCH 2/4] lib/hexdump.c: Optionally suppress lines of filler bytes Date: Mon, 15 Apr 2019 20:33:47 +1000 Message-ID: <0db001d4f376$b598af80$20ca0e80$@d-silva.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQMagew30YCVD5mEhyHx4HPts9xr1AIaTVgFAud+bokCJYEOIgJRBvYio2YlwMA= Content-Language: en-au X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (mail2.nmnhosting.com [10.0.1.20]); Mon, 15 Apr 2019 20:33:49 +1000 (AEST) 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. > > > > > 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? Yes, but I don't have the content with me at the moment, so I can't share it. I'm dumping persistent memory labels, which are 64kB long, but only the first few hundred bytes are populated. > 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 agree that is better, I'll add that to V2. -- Alastair D'Silva mob: 0423 762 819 skype: alastair_dsilva msn: alastair@d-silva.org blog: http://alastair.d-silva.org Twitter: @EvilDeece