From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932234AbbBPJrx (ORCPT ); Mon, 16 Feb 2015 04:47:53 -0500 Received: from mga14.intel.com ([192.55.52.115]:5177 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752377AbbBPJrw (ORCPT ); Mon, 16 Feb 2015 04:47:52 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,586,1418112000"; d="scan'208";a="455191462" Message-ID: <1424080072.31903.557.camel@linux.intel.com> Subject: Re: [PATCH] test-hexdump: test the return value of the hex_dump_to_buffer From: Andy Shevchenko To: Wang Long Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, peifeiyue@huawei.com Date: Mon, 16 Feb 2015 11:47:52 +0200 In-Reply-To: <1423993813-218469-1-git-send-email-long.wanglong@huawei.com> References: <1423993813-218469-1-git-send-email-long.wanglong@huawei.com> Organization: Intel Finland Oy Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.9-1+b1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2015-02-15 at 09:50 +0000, Wang Long wrote: > As the function hex_dump_to_buffer returns the amount of bytes placed > in the buffer without terminating NUL. the test-hexdump should test > the return value of it. I don't think it's needed. When the prototype was changed the new test case had been introduced to cover the overflow cases, i.e. test_hexdump_overflow(). > > Signed-off-by: Wang Long > --- > lib/test-hexdump.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/lib/test-hexdump.c b/lib/test-hexdump.c > index daf29a39..9243be7 100644 > --- a/lib/test-hexdump.c > +++ b/lib/test-hexdump.c > @@ -52,8 +52,9 @@ static void __init test_hexdump(size_t len, int rowsize, int groupsize, > size_t l = len; > int gs = groupsize, rs = rowsize; > unsigned int i; > + int r; > > - hex_dump_to_buffer(data_b, l, rs, gs, real, sizeof(real), ascii); > + r = hex_dump_to_buffer(data_b, l, rs, gs, real, sizeof(real), ascii); > > if (rs != 16 && rs != 32) > rs = 16; > @@ -96,7 +97,7 @@ static void __init test_hexdump(size_t len, int rowsize, int groupsize, > > *p = '\0'; > > - if (strcmp(test, real)) { > + if (strcmp(test, real) || r != strlen(real)) { > pr_err("Len: %zu row: %d group: %d\n", len, rowsize, groupsize); > pr_err("Result: '%s'\n", real); > pr_err("Expect: '%s'\n", test); -- Andy Shevchenko Intel Finland Oy