From patchwork Thu Aug 16 15:31:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 43748 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 A07E04C8E; Thu, 16 Aug 2018 17:31:15 +0200 (CEST) Received: from mail-pl0-f53.google.com (mail-pl0-f53.google.com [209.85.160.53]) by dpdk.org (Postfix) with ESMTP id 1AEA844C3 for ; Thu, 16 Aug 2018 17:31:11 +0200 (CEST) Received: by mail-pl0-f53.google.com with SMTP id j8-v6so2252956pll.12 for ; Thu, 16 Aug 2018 08:31:11 -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=G0voSONN9Y5814Lch2Ae9ypVIgYuPXbeatiJyfWKl1E=; b=tzQhlNvsTe78pyPEr7HNZ8Y8dGIUehOW6MWVt5e0+FQr9TQ3F1iWIDJdDzMfirCHh9 GO/0FN10z+kwUkLcjpRFTu3yP4YfGy6Gn1mfNJoJ4jo1T5ttygvFGg53Q/zfYB8BDKn7 tbtt8VUeRrJjargyzdAu1ecGfkZ7YW8/Grgi+WS91t8oGsWbd+f6cKh/qg4ot15Oa4AX bZFrhZ7SPyem/51FHfglxF/HOqm1HVhhNmbPEj4TX8aWuX87K1lN72WXuGKEi4a/npIz wVUaOIBtDrxHwNY+NSl/Nh7mhoyAhq8n3Tf15N2tvIuRwCYUPJcV4WTJIsDhvb+6wUju 3+Og== 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=G0voSONN9Y5814Lch2Ae9ypVIgYuPXbeatiJyfWKl1E=; b=Wkuy4cqPdwjn2SkBwenyH3SP7n83zAwdcOZAo8wD/HU2hOZ/RL51m+yUQJO0wjSs/g 9FE68hPJ7040yJELDQ9PGk32v0RwPzwYhcfhh+DgSeW9PD9CGAUssATL9582Mk3GLZ3O Pc/W9oTe3lIGLhYhz4JxRLlQO9EzmeXxRpjQOf+Ku/Z4e4trt4br/8tdDCvEhnMGCP6c e+p4G2f8uFb7u+RyJP3VUGSPvktPf2mctzmNQ9AiphagRH56SE//WhFgQWvDclfT7I98 XWQPIb+gEcrY33NIKJacLtVo+sqsCxVcIejCh4lA+4yHntwVZhCR78TEXI0rMScahIoi J2hg== X-Gm-Message-State: AOUpUlEpEe0/DjFMlk8vh9bJnV58rYZj4eJr4h+GqrgB5T8m75w1Pm9T e4kHNyHYjcd/3wESfjbPz2QBY0i80gv0og== X-Google-Smtp-Source: AA+uWPxeqpHSa3PjiwWHqDqY/q5WQbbYCoFKmMIqq3EMZ62A+Jxj01NNGhSugGoHKOQstVv7dI8/fA== X-Received: by 2002:a17:902:bd82:: with SMTP id q2-v6mr29508579pls.178.1534433470807; Thu, 16 Aug 2018 08:31:10 -0700 (PDT) Received: from xeon-e3.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id p5-v6sm30002104pfn.57.2018.08.16.08.31.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 08:31:09 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Thu, 16 Aug 2018 08:31:05 -0700 Message-Id: <20180816153106.7608-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180816153106.7608-1-stephen@networkplumber.org> References: <20180816153106.7608-1-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH 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 --- lib/librte_eal/common/eal_common_hexdump.c | 109 ++++++++------------- 1 file changed, 43 insertions(+), 66 deletions(-) diff --git a/lib/librte_eal/common/eal_common_hexdump.c b/lib/librte_eal/common/eal_common_hexdump.c index 9ca7c511c062..980cf73ac337 100644 --- a/lib/librte_eal/common/eal_common_hexdump.c +++ b/lib/librte_eal/common/eal_common_hexdump.c @@ -10,82 +10,59 @@ #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) +void 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) ? 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) +void 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); }