kernel/resource: Remove unnecessary initial values of variables

Message ID 20230926014548.31523-1-kunyu@nfschina.com
State New
Headers
Series kernel/resource: Remove unnecessary initial values of variables |

Commit Message

Li kunyu Sept. 26, 2023, 1:45 a.m. UTC
  err, new_res and dr is assigned first, so it does not need to initialize
 the assignment.

Signed-off-by: Li kunyu <kunyu@nfschina.com>
---
 kernel/resource.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Comments

Ira Weiny Sept. 26, 2023, 7:56 p.m. UTC | #1
Li kunyu wrote:
> err, new_res and dr is assigned first, so it does not need to initialize
>  the assignment.

A good commit message will explain _why_ this change is required or
desired.  Changing code just for the sake of changing it is not
productive.

Ira

> 
> Signed-off-by: Li kunyu <kunyu@nfschina.com>
> ---
>  kernel/resource.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/resource.c b/kernel/resource.c
> index b1763b2fd7ef..bbd7c113307a 100644
> --- a/kernel/resource.c
> +++ b/kernel/resource.c
> @@ -656,7 +656,7 @@ 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;
>  
> @@ -1310,7 +1310,7 @@ EXPORT_SYMBOL(__release_region);
>  void release_mem_region_adjustable(resource_size_t start, resource_size_t size)
>  {
>  	struct resource *parent = &iomem_resource;
> -	struct resource *new_res = NULL;
> +	struct resource *new_res;
>  	bool alloc_nofail = false;
>  	struct resource **p;
>  	struct resource *res;
> @@ -1556,7 +1556,7 @@ struct resource *
>  __devm_request_region(struct device *dev, struct resource *parent,
>  		      resource_size_t start, resource_size_t n, const char *name)
>  {
> -	struct region_devres *dr = NULL;
> +	struct region_devres *dr;
>  	struct resource *res;
>  
>  	dr = devres_alloc(devm_region_release, sizeof(struct region_devres),
> -- 
> 2.18.2
>
  

Patch

diff --git a/kernel/resource.c b/kernel/resource.c
index b1763b2fd7ef..bbd7c113307a 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -656,7 +656,7 @@  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;
 
@@ -1310,7 +1310,7 @@  EXPORT_SYMBOL(__release_region);
 void release_mem_region_adjustable(resource_size_t start, resource_size_t size)
 {
 	struct resource *parent = &iomem_resource;
-	struct resource *new_res = NULL;
+	struct resource *new_res;
 	bool alloc_nofail = false;
 	struct resource **p;
 	struct resource *res;
@@ -1556,7 +1556,7 @@  struct resource *
 __devm_request_region(struct device *dev, struct resource *parent,
 		      resource_size_t start, resource_size_t n, const char *name)
 {
-	struct region_devres *dr = NULL;
+	struct region_devres *dr;
 	struct resource *res;
 
 	dr = devres_alloc(devm_region_release, sizeof(struct region_devres),