diff mbox series

[1/1] dm: core: remove redundant if statement

Message ID 20200215203848.17823-1-xypron.glpk@gmx.de
State Accepted
Commit f93a07dd4f2e9096208a3230b0eca669d9760397
Delegated to: Simon Glass
Headers show
Series [1/1] dm: core: remove redundant if statement | expand

Commit Message

Heinrich Schuchardt Feb. 15, 2020, 8:38 p.m. UTC
The value of parent is not changed in the first if statement. So we can
merge the two if statements depending on parent.

Indicated by cppcheck.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 drivers/core/device.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

--
2.25.0

Comments

Simon Glass Feb. 16, 2020, 7:03 p.m. UTC | #1
On Sat, 15 Feb 2020 at 13:38, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> The value of parent is not changed in the first if statement. So we can
> merge the two if statements depending on parent.
>
> Indicated by cppcheck.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
>  drivers/core/device.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
Simon Glass March 3, 2020, 2:46 a.m. UTC | #2
On Sat, 15 Feb 2020 at 13:38, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> The value of parent is not changed in the first if statement. So we can
> merge the two if statements depending on parent.
>
> Indicated by cppcheck.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
>  drivers/core/device.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-dm, thanks!
diff mbox series

Patch

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 89ea820d48..534cfa7314 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -143,11 +143,9 @@  static int device_bind_common(struct udevice *parent, const struct driver *drv,
 				goto fail_alloc3;
 			}
 		}
-	}
-
-	/* put dev into parent's successor list */
-	if (parent)
+		/* put dev into parent's successor list */
 		list_add_tail(&dev->sibling_node, &parent->child_head);
+	}

 	ret = uclass_bind_device(dev);
 	if (ret)