[PATCH 3/3] lib/test_vmalloc.c: use unsigned long constant

Martin Kaiser posted 3 patches 1 year, 11 months ago
[PATCH 3/3] lib/test_vmalloc.c: use unsigned long constant
Posted by Martin Kaiser 1 year, 11 months ago
Use an unsigned long constant instead of an int constant and a cast. This
fixes the checkpatch warning

WARNING: Unnecessary typecast of c90 int constant - '(unsigned long) 1' could be '1UL'
+     align = ((unsigned long) 1) << i;

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
 lib/test_vmalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/test_vmalloc.c b/lib/test_vmalloc.c
index d0c0cbe1913d..4ddf769861ff 100644
--- a/lib/test_vmalloc.c
+++ b/lib/test_vmalloc.c
@@ -117,7 +117,7 @@ static int align_shift_alloc_test(void)
 	int i;
 
 	for (i = 0; i < BITS_PER_LONG; i++) {
-		align = ((unsigned long) 1) << i;
+		align = 1UL << i;
 
 		ptr = __vmalloc_node(PAGE_SIZE, align, GFP_KERNEL|__GFP_ZERO, 0,
 				__builtin_return_address(0));
-- 
2.39.2
Re: [PATCH 3/3] lib/test_vmalloc.c: use unsigned long constant
Posted by Uladzislau Rezki 1 year, 11 months ago
On Mon, Feb 26, 2024 at 08:11:59PM +0100, Martin Kaiser wrote:
> Use an unsigned long constant instead of an int constant and a cast. This
> fixes the checkpatch warning
> 
> WARNING: Unnecessary typecast of c90 int constant - '(unsigned long) 1' could be '1UL'
> +     align = ((unsigned long) 1) << i;
> 
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> ---
>  lib/test_vmalloc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/test_vmalloc.c b/lib/test_vmalloc.c
> index d0c0cbe1913d..4ddf769861ff 100644
> --- a/lib/test_vmalloc.c
> +++ b/lib/test_vmalloc.c
> @@ -117,7 +117,7 @@ static int align_shift_alloc_test(void)
>  	int i;
>  
>  	for (i = 0; i < BITS_PER_LONG; i++) {
> -		align = ((unsigned long) 1) << i;
> +		align = 1UL << i;
>  
>  		ptr = __vmalloc_node(PAGE_SIZE, align, GFP_KERNEL|__GFP_ZERO, 0,
>  				__builtin_return_address(0));
> -- 
> 2.39.2
> 
Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>

--
Uladzislau Rezki