From patchwork Tue Apr 2 15:23:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 52117 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9AAB94C93; Tue, 2 Apr 2019 17:24:00 +0200 (CEST) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by dpdk.org (Postfix) with ESMTP id D4609316B for ; Tue, 2 Apr 2019 17:23:57 +0200 (CEST) Received: by mail-pg1-f193.google.com with SMTP id 85so6746379pgc.3 for ; Tue, 02 Apr 2019 08:23:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RAWcnhNKVBXceKuUJeKnwvxh3JIqXUY8sWg5IGiiKDo=; b=idMXxf4XrMOfeoFwkbakY2o8x87rONaDgfVeIv+uwwyVQ7NcxkPTLFSmdMvvFuXWYT B2P2O7Yb47yH605vgPBvmCeI8EeVwmNL1ivGQvSBbF06exlRwx52AwQyk7uDDebhgKb3 PP8UF+Ni00lvSe8QUxJ9bLSm8cZxmoB3JiVrCYvi0M99zWtf6+AnC7uLj9loT3BJ+u7K lwjyGUN99bjx9B7Ux7oLqBAJ6ZVlWbnSluoMIdNV00zQw1B00LEy7Yb7OWxbWUwSZcic zRnhz8BTAMPpa/DE7iyXAGDHyKtQbWZ+3fH+qHuzBHgLE3ElOmjO6Xm8yUS+gRKIng+u tO4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RAWcnhNKVBXceKuUJeKnwvxh3JIqXUY8sWg5IGiiKDo=; b=ZVAPJhJGQf/5WLqcKcz+l+XcuoX7QeEqmsAJlebQCAhJRd1lVIE60RR0GD4crBCmAn XLfxiTlEhMUz5c8xwBRpiGCOYwbL1BOEgALI3ralf2jsCE+Qr3e7ZXWQVqAptFOhUBY4 NT1exiMNoIWZLCK0Ll5RVGK1TOWxAdNtxn09RUyf4mlKycfjk99tXOTLX7HCiXBofD5d amcWGOZ34oEhFjJcuvNBEjVvGMjbckZ/9JznnSfWeh0GCEVyjeyqEznaWdCnspRqLHT3 5oppUfbfpHZK3Htq63WhgRX9DSMyp1D/qxW9eJ+CY/TLBoFq1HMaglqZGTkr+nwY1gaV uJxA== X-Gm-Message-State: APjAAAX2spDSTz2rGGK0poF9sdigEeFHux8lQoWX+zdCFqzOKnqCDqZs IYZ9LyiZC/A4080tMF1QPqhB4iV6XenNIQ== X-Google-Smtp-Source: APXvYqwdp6twUtV27nDkFxsktXEEJA/nu+rmIM51VBIOIQMh7vkxIkuAds0Bx8KJfHhwy+q1Ctc2yA== X-Received: by 2002:a62:b61a:: with SMTP id j26mr12113001pff.203.1554218636689; Tue, 02 Apr 2019 08:23:56 -0700 (PDT) Received: from shemminger-XPS-13-9360.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id p6sm5302514pfd.122.2019.04.02.08.23.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Apr 2019 08:23:55 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 2 Apr 2019 08:23:49 -0700 Message-Id: <20190402152350.17572-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190402152350.17572-1-stephen@networkplumber.org> References: <20180816153106.7608-1-stephen@networkplumber.org> <20190402152350.17572-1-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH v2 1/2] hexdump: whitespace cleanup 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The hexdump code obviously came from somewhere else originally. It is not formatted according to DPDK coding style. Also, drop the comment which is not useful the docbock comment is already in the rte_hexdump.h Signed-off-by: Stephen Hemminger --- v2 - keep BSD style function definition lib/librte_eal/common/eal_common_hexdump.c | 107 +++++++++------------ 1 file changed, 43 insertions(+), 64 deletions(-) diff --git a/lib/librte_eal/common/eal_common_hexdump.c b/lib/librte_eal/common/eal_common_hexdump.c index 9ca7c511c062..6af818beb3cb 100644 --- a/lib/librte_eal/common/eal_common_hexdump.c +++ b/lib/librte_eal/common/eal_common_hexdump.c @@ -10,82 +10,61 @@ #define LINE_LEN 128 -/**************************************************************************//** -* -* rte_hexdump - Dump out memory in a special hex dump format. -* -* DESCRIPTION -* Dump out the message buffer in a special hex dump output format with characters -* printed for each line of 16 hex values. -* -* RETURNS: N/A -* -* SEE ALSO: -*/ - void -rte_hexdump(FILE *f, const char * title, const void * buf, unsigned int len) +rte_hexdump(FILE *f, const char *title, const void *buf, unsigned int len) { - unsigned int i, out, ofs; - const unsigned char *data = buf; - char line[LINE_LEN]; /* space needed 8+16*3+3+16 == 75 */ + unsigned int i, out, ofs; + const unsigned char *data = buf; + char line[LINE_LEN]; /* space needed 8+16*3+3+16 == 75 */ - fprintf(f, "%s at [%p], len=%u\n", (title)? title : " Dump data", data, len); - ofs = 0; - while (ofs < len) { - /* format the line in the buffer, then use printf to output to screen */ - out = snprintf(line, LINE_LEN, "%08X:", ofs); - for (i = 0; ((ofs + i) < len) && (i < 16); i++) - out += snprintf(line+out, LINE_LEN - out, " %02X", (data[ofs+i] & 0xff)); - for(; i <= 16; i++) - out += snprintf(line+out, LINE_LEN - out, " | "); - for(i = 0; (ofs < len) && (i < 16); i++, ofs++) { - unsigned char c = data[ofs]; - if ( (c < ' ') || (c > '~')) - c = '.'; - out += snprintf(line+out, LINE_LEN - out, "%c", c); - } - fprintf(f, "%s\n", line); - } - fflush(f); -} + fprintf(f, "%s at [%p], len=%u\n", + title ? : " Dump data", data, len); + ofs = 0; + 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, + " %02X", (data[ofs + i] & 0xff)); + for (; i <= 16; i++) + out += snprintf(line + out, LINE_LEN - out, " | "); + + for (i = 0; ofs < len && i < 16; i++, ofs++) { + unsigned char c = data[ofs]; -/**************************************************************************//** -* -* rte_memdump - Dump out memory in hex bytes with colons. -* -* DESCRIPTION -* Dump out the message buffer in hex bytes with colons xx:xx:xx:xx:... -* -* RETURNS: N/A -* -* SEE ALSO: -*/ + if (c < ' ' || c > '~') + c = '.'; + out += snprintf(line + out, LINE_LEN - out, "%c", c); + } + fprintf(f, "%s\n", line); + } + fflush(f); +} void -rte_memdump(FILE *f, const char * title, const void * buf, unsigned int len) +rte_memdump(FILE *f, const char *title, const void *buf, unsigned int len) { - unsigned int i, out; - const unsigned char *data = buf; - char line[LINE_LEN]; + unsigned int i, out; + const unsigned char *data = buf; + char line[LINE_LEN]; - if ( title ) - fprintf(f, "%s: ", title); + if (title) + fprintf(f, "%s: ", title); - line[0] = '\0'; - for (i = 0, out = 0; i < len; i++) { - // Make sure we do not overrun the line buffer length. - if ( out >= (LINE_LEN - 4) ) { + line[0] = '\0'; + for (i = 0, out = 0; i < len; i++) { + /* Make sure we do not overrun the line buffer length. */ + if (out >= LINE_LEN - 4) { fprintf(f, "%s", line); out = 0; line[out] = '\0'; } - out += snprintf(line+out, LINE_LEN - out, "%02x%s", - (data[i] & 0xff), ((i+1) < len)? ":" : ""); - } - if ( out > 0 ) - fprintf(f, "%s", line); - fprintf(f, "\n"); + out += snprintf(line + out, LINE_LEN - out, "%02x%s", + (data[i] & 0xff), ((i + 1) < len) ? ":" : ""); + } + if (out > 0) + fprintf(f, "%s", line); + fprintf(f, "\n"); - fflush(f); + fflush(f); }