linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] test-hexdump: test the return value of the hex_dump_to_buffer
@ 2015-02-15  9:50 Wang Long
  2015-02-16  9:47 ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Wang Long @ 2015-02-15  9:50 UTC (permalink / raw)
  To: akpm, andriy.shevchenko; +Cc: linux-kernel, peifeiyue, long.wanglong

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] test-hexdump: test the return value of the hex_dump_to_buffer
  2015-02-15  9:50 [PATCH] test-hexdump: test the return value of the hex_dump_to_buffer Wang Long
@ 2015-02-16  9:47 ` Andy Shevchenko
  2015-02-26  3:31   ` long.wanglong
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2015-02-16  9:47 UTC (permalink / raw)
  To: Wang Long; +Cc: akpm, linux-kernel, peifeiyue

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 <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);


-- 
Andy Shevchenko <andriy.shevchenko@intel.com>
Intel Finland Oy


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] test-hexdump: test the return value of the hex_dump_to_buffer
  2015-02-16  9:47 ` Andy Shevchenko
@ 2015-02-26  3:31   ` long.wanglong
  0 siblings, 0 replies; 3+ messages in thread
From: long.wanglong @ 2015-02-26  3:31 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: akpm, linux-kernel, peifeiyue

On 2015/2/16 17:47, Andy Shevchenko wrote:
> 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().
> 

ok, thanks.

>>
>> 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);
> 
> 



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-02-26  3:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-15  9:50 [PATCH] test-hexdump: test the return value of the hex_dump_to_buffer Wang Long
2015-02-16  9:47 ` Andy Shevchenko
2015-02-26  3:31   ` long.wanglong

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).