Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp32901yba; Fri, 12 Apr 2019 16:29:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqwhNJUhh566tSIGyF4ETYrWgJytNBddxcw3IuVe9yKZvo1oDIet2dPVo+ZmZ8OD7N2qeSmU X-Received: by 2002:a63:c45:: with SMTP id 5mr56789927pgm.385.1555111758731; Fri, 12 Apr 2019 16:29:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555111758; cv=none; d=google.com; s=arc-20160816; b=0SoTh7a0VfyjaYqZ7ULzk5SrVvYB2AIwdD1tPv03byFCdRrFsTo4TJY8nSFVNB2uCN XugCCSpps9fK3TOjW4faLPBI+YwDusfiOi8XJpbnx5HHMaeYPy8uuCxiknDBpPWdmXNI 6RiqxW5mgBPbc9Q2zp3SbpUSCPjK/JUx+NBGymwQ3JgRubX2lhn1x4FSKDAxuFbggHk6 XH7dTtplOD/onwLFv+zpJps+nmf29f8q8IIo5MjK6YoZw/Tzo8QvUfOUaKaxoeL8NTvM YkiorWN5FlX+w8xRVQXFQk+qehI+Xn8fdoTI0EwiJJeZqkj0fqD1zi8a3yeEad2HiBdi o0DA== 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=5antF+/lPilfPQL+G9N4NRvRFEcKDqLqFdn2XCHU1Xw=; b=lSZ3sp7mWj2GGh2t7nOb1J7VZ/77VzIbDy1W+xZz1KBoqhEDnnaldQyc3EHBeDi/AF BYtZdLvOVqAtcYaIfqBnqtqVnc3dtA9NnshF6b/d4q7t7cg8AyjUWFo4LVWsAvd0VTms QXcASqKj3G6hVsgEW/mXTCSTFoaMqXTlfc0RcZ3a4N6PBiGAyQ9N+ZcekTSnfqiuA/or hKVF5ZFyqyJHBExUxm41IqhZC56Z3OD9/cuVUPrvGDN6/WDkc6WAM7AEZZ8vacL2oVry MXNii6rjMYUCe6ZDGbwbUnEVI+3l3HgCwN/uwsU6kKY5C84p30DQfqnL7ja4VRONYsLm LNkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@d-silva.org header.s=201810a header.b=BPuvw68s; 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 j16si38662483pgl.335.2019.04.12.16.29.01; Fri, 12 Apr 2019 16:29:18 -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=BPuvw68s; 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 S1727047AbfDLX2Q (ORCPT + 99 others); Fri, 12 Apr 2019 19:28:16 -0400 Received: from ushosting.nmnhosting.com ([167.160.173.127]:52634 "EHLO ushosting.nmnhosting.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726925AbfDLX2P (ORCPT ); Fri, 12 Apr 2019 19:28:15 -0400 Received: from mail2.nmnhosting.com (unknown [202.169.106.97]) by ushosting.nmnhosting.com (Postfix) with ESMTPS id 4F9FF2F28FBD; Fri, 12 Apr 2019 19:28:10 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=d-silva.org; s=201810a; t=1555111690; bh=VgWLlyshljl98K0ypGNqKx0d62WSBvCH8NIxBzaHhak=; h=From:To:Cc:References:In-Reply-To:Subject:Date:From; b=BPuvw68smjn1JByoFoL8q1LPc54llaJtgGfFbJlZcDiDi5y77sKOyI1/8/W5DFNPa /Nv2fqVkweHd40344J2PYYo2BW8hxo+AqNhmZT9PB/VNWHASY4bSfQX9Z9L4WX0PEY v6JGqh15sI9uHBZPKC0Zmpb60hAdNikpE5T0W4KIoSbMJXwM1NE9Hw/9JZbBgsk1+y fovHMb6tCbRfb0D2xD65rk/sMRiFMUNcWfugTsHLjlnwx2rh+xPnw+sTXKZ7FLG6u1 rUvTrGjEHh93EMZSBGmeDnaY0BNLga7Th43VqM33UtCDaC1g3Sd+UmgiUVv9jqAHer 0MWmU947eNNkD1CnZ5ANluJDOo050loocjm6JJo97JV1REpgQRL9x2gdEMYRO/ZBHS MSU97doZ1eW/60HsKAaIkVY0iP45YA0enfSksvPeCtQM6GVpViR8ErBvi67emFbv69 LUYOTGDKZmZtx0bO7je8fU6BQs+DwYTkdvPq3Nde2GHNeDdrHoW37HK6/AY+iYbPWA 4q0Vp7R8xnfTEqP4W+sUIjBvdc1hejUkIWdzhxwtFrV4X+qMZ7fiCaS+6OO2ZohoWa EeGFuKFmOyK4LxYCv6vy2Ui3jd/GU4tqaVMECK5jwRhRAWRRXRmfyTFxhfPPkewQBL hw4q16R8L+HqOnFuyE21WxxQ= 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 x3CNS3k6018835 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 13 Apr 2019 09:28:04 +1000 (AEST) (envelope-from alastair@d-silva.org) From: "Alastair D'Silva" To: "'Petr Mladek'" , "'Alastair D'Silva'" Cc: "'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> In-Reply-To: <20190412140353.mgvksn3yk6n65hbk@pathway.suse.cz> Subject: RE: [PATCH 2/4] lib/hexdump.c: Optionally suppress lines of filler bytes Date: Sat, 13 Apr 2019 09:28:03 +1000 Message-ID: <093101d4f187$612f0f20$238d2d60$@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+bomjhfstAA== 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]); Sat, 13 Apr 2019 09:28:05 +1000 (AEST) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----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 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). > > 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. It's replaced with an inline wrapper function, there's no need to export it. -- Alastair D'Silva mob: 0423 762 819 skype: alastair_dsilva msn: alastair@d-silva.org blog: http://alastair.d-silva.org Twitter: @EvilDeece