From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 8B90449E1 for ; Thu, 16 Aug 2018 18:34:14 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Aug 2018 09:34:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,247,1531810800"; d="scan'208";a="65457072" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga007.jf.intel.com with ESMTP; 16 Aug 2018 09:34:12 -0700 Received: from fmsmsx124.amr.corp.intel.com (10.18.125.39) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 16 Aug 2018 09:34:12 -0700 Received: from fmsmsx117.amr.corp.intel.com ([169.254.3.210]) by fmsmsx124.amr.corp.intel.com ([169.254.8.135]) with mapi id 14.03.0319.002; Thu, 16 Aug 2018 09:34:12 -0700 From: "Wiles, Keith" To: Stephen Hemminger CC: "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH 1/2] hexdump: whitespace cleanup Thread-Index: AQHUNXY5a9kC6BaKFUKmsFBfu3N+NaTDCFkA Date: Thu, 16 Aug 2018 16:34:12 +0000 Message-ID: References: <20180816153106.7608-1-stephen@networkplumber.org> <20180816153106.7608-2-stephen@networkplumber.org> In-Reply-To: <20180816153106.7608-2-stephen@networkplumber.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.255.73.153] Content-Type: text/plain; charset="us-ascii" Content-ID: <72BD621A1111554DB9E07BC795624829@intel.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [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: , X-List-Received-Date: Thu, 16 Aug 2018 16:34:15 -0000 > On Aug 16, 2018, at 10:31 AM, Stephen Hemminger wrote: >=20 > The hexdump code obviously came from somewhere else originally. > It is not formatted according to DPDK coding style. >=20 > Also, drop the comment which is not useful the docbock comment > is already in the rte_hexdump.h >=20 > Signed-off-by: Stephen Hemminger > --- > lib/librte_eal/common/eal_common_hexdump.c | 109 ++++++++------------- > 1 file changed, 43 insertions(+), 66 deletions(-) >=20 > 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 @@ >=20 > #define LINE_LEN 128 >=20 > -/***********************************************************************= ***//** > -* > -* 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 c= haracters > -* 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 i= nt len) I looked at the Coding Guide in section 1.7.2 and it states 1.7.2. Definitions - The function type should be on a line by itself preceding the function. - The opening brace of the function body should be on a line by itself. static char * function(int a1, int a2, float fl, int a4) { I have noticed some places are not following that rule in other parts of DP= DK. Function prototypes are on the same line. > { > - unsigned int i, out, ofs; > - const unsigned char *data =3D buf; > - char line[LINE_LEN]; /* space needed 8+16*3+3+16 =3D=3D 75 */ > + unsigned int i, out, ofs; > + const unsigned char *data =3D buf; > + char line[LINE_LEN]; /* space needed 8+16*3+3+16 =3D=3D 75 */ >=20 > - fprintf(f, "%s at [%p], len=3D%u\n", (title)? title : " Dump data"= , data, len); > - ofs =3D 0; > - while (ofs < len) { > - /* format the line in the buffer, then use printf to output to s= creen */ > - out =3D snprintf(line, LINE_LEN, "%08X:", ofs); > - for (i =3D 0; ((ofs + i) < len) && (i < 16); i++) > - out +=3D snprintf(line+out, LINE_LEN - out, " %02X", (data[o= fs+i] & 0xff)); > - for(; i <=3D 16; i++) > - out +=3D snprintf(line+out, LINE_LEN - out, " | "); > - for(i =3D 0; (ofs < len) && (i < 16); i++, ofs++) { > - unsigned char c =3D data[ofs]; > - if ( (c < ' ') || (c > '~')) > - c =3D '.'; > - out +=3D snprintf(line+out, LINE_LEN - out, "%c", c); > - } > - fprintf(f, "%s\n", line); > - } > - fflush(f); > -} > + fprintf(f, "%s at [%p], len=3D%u\n", (title) ? title : " Dump data", > + data, len); > + ofs =3D 0; > + while (ofs < len) { > + /* format the line in the buffer */ > + out =3D snprintf(line, LINE_LEN, "%08X:", ofs); > + for (i =3D 0; i < 16 && ofs + i < len; i++) > + out +=3D snprintf(line + out, LINE_LEN - out, > + " %02X", (data[ofs + i] & 0xff)); > + for (; i <=3D 16; i++) > + out +=3D snprintf(line + out, LINE_LEN - out, " | "); > + > + for (i =3D 0; (ofs < len) && (i < 16); i++, ofs++) { > + unsigned char c =3D data[ofs]; >=20 > -/***********************************************************************= ***//** > -* > -* 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 =3D '.'; > + out +=3D snprintf(line + out, LINE_LEN - out, "%c", c); > + } > + fprintf(f, "%s\n", line); > + } > + fflush(f); > +} >=20 > -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 i= nt len) > { > - unsigned int i, out; > - const unsigned char *data =3D buf; > - char line[LINE_LEN]; > + unsigned int i, out; > + const unsigned char *data =3D buf; > + char line[LINE_LEN]; >=20 > - if ( title ) > - fprintf(f, "%s: ", title); > + if (title) > + fprintf(f, "%s: ", title); >=20 > - line[0] =3D '\0'; > - for (i =3D 0, out =3D 0; i < len; i++) { > - // Make sure we do not overrun the line buffer length. > - if ( out >=3D (LINE_LEN - 4) ) { > + line[0] =3D '\0'; > + for (i =3D 0, out =3D 0; i < len; i++) { > + /* Make sure we do not overrun the line buffer length. */ > + if (out >=3D (LINE_LEN - 4)) { > fprintf(f, "%s", line); > out =3D 0; > line[out] =3D '\0'; > } > - out +=3D 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 +=3D snprintf(line + out, LINE_LEN - out, "%02x%s", > + (data[i] & 0xff), ((i + 1) < len) ? ":" : ""); > + } > + if (out > 0) > + fprintf(f, "%s", line); > + fprintf(f, "\n"); >=20 > - fflush(f); > + fflush(f); > } > --=20 > 2.18.0 >=20 Regards, Keith