linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wang Long <long.wanglong@huawei.com>
To: <akpm@linux-foundation.org>, <andriy.shevchenko@linux.intel.com>
Cc: <linux-kernel@vger.kernel.org>, <peifeiyue@huawei.com>,
	<long.wanglong@huawei.com>
Subject: [PATCH] test-hexdump: test the return value of the hex_dump_to_buffer
Date: Sun, 15 Feb 2015 09:50:13 +0000	[thread overview]
Message-ID: <1423993813-218469-1-git-send-email-long.wanglong@huawei.com> (raw)

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.

Signed-off-by: Wang Long <long.wanglong@huawei.com>
---
 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);
-- 
1.8.3.4


             reply	other threads:[~2015-02-15  9:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-15  9:50 Wang Long [this message]
2015-02-16  9:47 ` [PATCH] test-hexdump: test the return value of the hex_dump_to_buffer Andy Shevchenko
2015-02-26  3:31   ` long.wanglong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1423993813-218469-1-git-send-email-long.wanglong@huawei.com \
    --to=long.wanglong@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peifeiyue@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).