From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl0-f68.google.com (mail-pl0-f68.google.com [209.85.160.68]) by dpdk.org (Postfix) with ESMTP id 653CB47CD for ; Thu, 16 Aug 2018 17:50:52 +0200 (CEST) Received: by mail-pl0-f68.google.com with SMTP id ba4-v6so2280990plb.11 for ; Thu, 16 Aug 2018 08:50:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:subject:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=4imsHLxJaR1MnYv5mjnn3oTQkI7r2x4eHBDUGWcLHiE=; b=f9Dt7qQvhUeuBk2mXG6E7f34kViQAAUrf05bURx3nrIslHPfrZ6Vwc6bGdnWN3BtjZ OBXZ5kv58c9qjZumzOQzJSdfOzG5B0a37VRS9psZOVqaeNVnk62t7sCazMsoO6g+oTV2 Akt1Pw9+bSzbQ5WYAvWhWg+Lvl5luZBjspnwO6HbhAUNx4D5PLjXU+2R6bUbY0+ozGQH T7jb5sUoWy6HNSCMJ60v8HzMEZWYRAvf94Q9e4CbTyuD7VqO2J2abf+WN7lvw2yz3w9j fLmWwMHaKdoViscoPpTyngq4kVJJECYDRoUjqRzpJngsrdWlsr2h4d0zBicAeVc57pNB W4ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4imsHLxJaR1MnYv5mjnn3oTQkI7r2x4eHBDUGWcLHiE=; b=N+5Zgd4okda867T1vwPMOOp/UOA9R0obfWpOZHmdSVww+xW+z9Ks7VcnBFsCUsep8g oG8t255Tl9pLR33QX8z4j9ZhAces5CtxPQg3n5qwckdRiJxVckkag3pjZ3SikLx8ni/Q vEm2C+R9slTV4Gaq8DHkywbXNsZs+2AvwmN/Cx1EX8HMMOgU82/aBa1GqCVX8bqTebct UJJ175C/pjryr3iSSNwbn2O90Z8sq2+fm/nSfVpCxw7xNCEC8CEOsLy02qaL1enLmPoi wuCuorJBV4dMwV67PhcyOwnPNTejIcSo/yzp8WfokVGx5Nk+RIhG++UyfGSD6PogvuL6 aMkg== X-Gm-Message-State: AOUpUlGhK+dtdg+n43SaxlNc9NZDi/ZqJUU0LbGyPhwJCn1qw5yE/Io+ sSImaWqxfRuf03WoebEj+H5NafBXuhCraQ== X-Google-Smtp-Source: AA+uWPxDonn0FjJpryI+tJoJU0xfwiacqeisu/h3gU0o9FcBssXqlFVL+fvduPOtoG3Z4e6r4Avd/Q== X-Received: by 2002:a17:902:760b:: with SMTP id k11-v6mr29669179pll.91.1534434651390; Thu, 16 Aug 2018 08:50:51 -0700 (PDT) Received: from xeon-e3 (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id 2-v6sm50175693pfs.58.2018.08.16.08.50.51 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Aug 2018 08:50:51 -0700 (PDT) Date: Thu, 16 Aug 2018 08:50:49 -0700 From: Stephen Hemminger To: dev@dpdk.org Message-ID: <20180816085049.1339e17f@xeon-e3> In-Reply-To: <20180816153106.7608-3-stephen@networkplumber.org> References: <20180816153106.7608-1-stephen@networkplumber.org> <20180816153106.7608-3-stephen@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH 2/2] hexdump: align output of string X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Aug 2018 15:50:52 -0000 On Thu, 16 Aug 2018 08:31:06 -0700 Stephen Hemminger wrote: > This fixes the issue where if the length of the output is not > a multiple of 16 the formatting was off. > > Before: > 00000000: 45 00 00 1C 12 34 2C E0 40 06 B8 2E C0 A8 01 12 | E....4,.@....... > 00000010: C0 A8 01 37 | | | | | | | | | | | | | ...7 > > After: > 00000000: 45 00 00 1C 12 34 2C E0 40 06 B8 2E C0 A8 01 12 | E....4,.@....... > 00000010: C0 A8 01 37 | ...7 > > Signed-off-by: Stephen Hemminger > --- > lib/librte_eal/common/eal_common_hexdump.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/lib/librte_eal/common/eal_common_hexdump.c b/lib/librte_eal/common/eal_common_hexdump.c > index 980cf73ac337..19c2d86c693e 100644 > --- a/lib/librte_eal/common/eal_common_hexdump.c > +++ b/lib/librte_eal/common/eal_common_hexdump.c > @@ -22,9 +22,16 @@ void rte_hexdump(FILE *f, const char *title, const void *buf, unsigned int len) > while (ofs < len) { > /* format the line in the buffer */ > out = snprintf(line, LINE_LEN, "%08X:", ofs); > - for (i = 0; i < 16 && ofs + i < len; i++) > - out += snprintf(line + out, LINE_LEN - out, > + for (i = 0; i < 16; i++) { > + if (ofs + i < len) > + snprintf(line + out, LINE_LEN - out, > " %02X", (data[ofs + i] & 0xff)); > + else > + strcpy(line + out, " "); > + out += 3; > + } > + > + > for (; i <= 16; i++) > out += snprintf(line + out, LINE_LEN - out, " | "); > Nevermind, this version. The last two lines are dead code after tha patch and could be dropped.