kernel: resource: Remove unnecessary ‘0’ values from err

Message ID 20230713235339.3090-1-kunyu@nfschina.com
State New
Headers
Series kernel: resource: Remove unnecessary ‘0’ values from err |

Commit Message

Li kunyu July 13, 2023, 11:53 p.m. UTC
  err is assigned first, so it does not need to initialize the assignment.

Signed-off-by: Li kunyu <kunyu@nfschina.com>
---
 kernel/resource.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Andy Shevchenko July 12, 2023, 3:57 p.m. UTC | #1
On Fri, Jul 14, 2023 at 07:53:39AM +0800, Li kunyu wrote:
> err is assigned first, so it does not need to initialize the assignment.

While this is fine, I would go further to make it more explicit, i.e.

> -	int err=0;
> +	int err;
>  	struct resource new = *old;
>  	struct resource *conflict;

-	if ((err = __find_resource(root, old, &new, newsize, constraint)))
+	err = __find_resource(root, old, &new, newsize, constraint);
+	if (err)
  

Patch

diff --git a/kernel/resource.c b/kernel/resource.c
index b1763b2fd7ef..55a42f3c80be 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;