Skip to contentSkip to conversation

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

PATCH In review Li kunyu 3 participants 3 messages Jul 14, 2023

lore
Share & tools
lore

Li kunyu

author
#0 lore raw

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

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.

---
v2:
Modify __find_resource Execution Syntax.

 kernel/resource.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/resource.c +3 -2
index b1763b2fd7ef..ee79e8f4f422 100644
@@ -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)) {
Signature · 1 line
2.18.2
Reviewed-by on v2 1/1
#1 lore raw
Quoted 5 lines · Li kunyu

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.

Thanks.

Quoted 28 lines

---
v2:
Modify __find_resource Execution Syntax.

 kernel/resource.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/resource.c +3 -2
index b1763b2fd7ef..ee79e8f4f422 100644
@@ -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)) {
Signature · 1 line
~Randy
Reviewed-by on v2 1/1
#2 lore raw
In reply to Li kunyu
Quoted 3 lines · Li kunyu

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,

Quoted 32 lines

---
v2:
Modify __find_resource Execution Syntax.

 kernel/resource.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/resource.c +3 -2
index b1763b2fd7ef..ee79e8f4f422 100644
@@ -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)) {
Signature · 1 line
2.18.2
Signature · 2 lines
With Best Regards,
Andy Shevchenko