Skip to contentSkip to conversation

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

PATCH Superseded Li kunyu 2 participants 2 messages Jul 12, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Li kunyu

author
#0 lore raw

PATCH 1/1 kernel: resource: Remove unnecessary ‘0’ values from err

err is assigned first, so it does not need to initialize the assignment.

---
 kernel/resource.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/resource.c +1 -1
index b1763b2fd7ef..55a42f3c80be 100644
@@ -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;
 
Signature · 1 line
2.18.2
#1 lore raw
Quoted 1 line · Li kunyu

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.

kernel/resource.c static int reallocate_resource(struct resource *root, struct resource *old, · line 661

Quoted 4 lines
kernel/resource.c +1 -1
-	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)

Signature · 2 lines
With Best Regards,
Andy Shevchenko