[PATCH] lib/test_string.c: return -ENOMEM on memset16_selftest allocation failure

Jiapeng Chong posted 1 patch 4 years, 4 months ago
lib/test_string.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] lib/test_string.c: return -ENOMEM on memset16_selftest allocation failure
Posted by Jiapeng Chong 4 years, 4 months ago
Clean up the following smatch warning:

lib/test_string.c:14 memset16_selftest() warn: returning -1 instead of
-ENOMEM is sloppy.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 lib/test_string.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/test_string.c b/lib/test_string.c
index 9dfd6f52de92..f23d6cd2d9c7 100644
--- a/lib/test_string.c
+++ b/lib/test_string.c
@@ -11,7 +11,7 @@ static __init int memset16_selftest(void)
 
 	p = kmalloc(256 * 2 * 2, GFP_KERNEL);
 	if (!p)
-		return -1;
+		return -ENOMEM;
 
 	for (i = 0; i < 256; i++) {
 		for (j = 0; j < 256; j++) {
-- 
2.20.1.7.g153144c

Re: [PATCH] lib/test_string.c: return -ENOMEM on memset16_selftest allocation failure
Posted by Andy Shevchenko 4 years, 4 months ago
On Mon, Feb 07, 2022 at 06:36:26PM +0800, Jiapeng Chong wrote:
> Clean up the following smatch warning:
> 
> lib/test_string.c:14 memset16_selftest() warn: returning -1 instead of
> -ENOMEM is sloppy.

It's not that makes much difference, but fine
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
>  lib/test_string.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/test_string.c b/lib/test_string.c
> index 9dfd6f52de92..f23d6cd2d9c7 100644
> --- a/lib/test_string.c
> +++ b/lib/test_string.c
> @@ -11,7 +11,7 @@ static __init int memset16_selftest(void)
>  
>  	p = kmalloc(256 * 2 * 2, GFP_KERNEL);
>  	if (!p)
> -		return -1;
> +		return -ENOMEM;
>  
>  	for (i = 0; i < 256; i++) {
>  		for (j = 0; j < 256; j++) {
> -- 
> 2.20.1.7.g153144c
> 

-- 
With Best Regards,
Andy Shevchenko