[PATCH v2] kernel: resource: Remove unnecessary ‘0’ values from err

Li kunyu posted 1 patch 2 years, 6 months ago
kernel/resource.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
[PATCH v2] kernel: resource: Remove unnecessary ‘0’ values from err
Posted by Li kunyu 2 years, 6 months ago
err is assigned first, so it does not need to initialize the assignment.
Modify __find_resource execution syntax to make it more in line with
commonly used styles.

Signed-off-by: Li kunyu <kunyu@nfschina.com>
---
 v2:
   Modify __find_resource Execution Syntax.

 kernel/resource.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/resource.c b/kernel/resource.c
index b1763b2fd7ef..ee79e8f4f422 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -656,13 +656,14 @@ static int reallocate_resource(struct resource *root, struct resource *old,
 			       resource_size_t newsize,
 			       struct resource_constraint *constraint)
 {
-	int err=0;
+	int err;
 	struct resource new = *old;
 	struct resource *conflict;
 
 	write_lock(&resource_lock);
 
-	if ((err = __find_resource(root, old, &new, newsize, constraint)))
+	err = __find_resource(root, old, &new, newsize, constraint);
+	if (err)
 		goto out;
 
 	if (resource_contains(&new, old)) {
-- 
2.18.2
Re: [PATCH v2] kernel: resource: Remove unnecessary ‘0’ values from err
Posted by Randy Dunlap 2 years, 6 months ago

On 7/15/23 11:24, Li kunyu wrote:
> err is assigned first, so it does not need to initialize the assignment.
> Modify __find_resource execution syntax to make it more in line with
> commonly used styles.
> 
> Signed-off-by: Li kunyu <kunyu@nfschina.com>

Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Thanks.

> ---
>  v2:
>    Modify __find_resource Execution Syntax.
> 
>  kernel/resource.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/resource.c b/kernel/resource.c
> index b1763b2fd7ef..ee79e8f4f422 100644
> --- a/kernel/resource.c
> +++ b/kernel/resource.c
> @@ -656,13 +656,14 @@ static int reallocate_resource(struct resource *root, struct resource *old,
>  			       resource_size_t newsize,
>  			       struct resource_constraint *constraint)
>  {
> -	int err=0;
> +	int err;
>  	struct resource new = *old;
>  	struct resource *conflict;
>  
>  	write_lock(&resource_lock);
>  
> -	if ((err = __find_resource(root, old, &new, newsize, constraint)))
> +	err = __find_resource(root, old, &new, newsize, constraint);
> +	if (err)
>  		goto out;
>  
>  	if (resource_contains(&new, old)) {

-- 
~Randy
Re: [PATCH v2] kernel: resource: Remove unnecessary ‘0’ values from err
Posted by Andy Shevchenko 2 years, 6 months ago
On Sun, Jul 16, 2023 at 02:24:28AM +0800, Li kunyu wrote:
> err is assigned first, so it does not need to initialize the assignment.
> Modify __find_resource execution syntax to make it more in line with
> commonly used styles.

FWIW,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Signed-off-by: Li kunyu <kunyu@nfschina.com>
> ---
>  v2:
>    Modify __find_resource Execution Syntax.
> 
>  kernel/resource.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/resource.c b/kernel/resource.c
> index b1763b2fd7ef..ee79e8f4f422 100644
> --- a/kernel/resource.c
> +++ b/kernel/resource.c
> @@ -656,13 +656,14 @@ static int reallocate_resource(struct resource *root, struct resource *old,
>  			       resource_size_t newsize,
>  			       struct resource_constraint *constraint)
>  {
> -	int err=0;
> +	int err;
>  	struct resource new = *old;
>  	struct resource *conflict;
>  
>  	write_lock(&resource_lock);
>  
> -	if ((err = __find_resource(root, old, &new, newsize, constraint)))
> +	err = __find_resource(root, old, &new, newsize, constraint);
> +	if (err)
>  		goto out;
>  
>  	if (resource_contains(&new, old)) {
> -- 
> 2.18.2
> 

-- 
With Best Regards,
Andy Shevchenko