diff mbox series

[OpenWrt-Devel] procd: simplify code in procd_inittab_run

Message ID 20181205231303.23088-1-mhei@heimpold.de
State Changes Requested
Delegated to: John Crispin
Headers show
Series [OpenWrt-Devel] procd: simplify code in procd_inittab_run | expand

Commit Message

Michael Heimpold Dec. 5, 2018, 11:13 p.m. UTC
This is a trial to make it more obvious what the historically
grown code is actually doing.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
---
 inittab.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

Jo-Philipp Wich Dec. 6, 2018, 6:32 a.m. UTC | #1
Hi,

> This is a trial to make it more obvious what the historically
> grown code is actually doing.

when we already refactor the code...

> Signed-off-by: Michael Heimpold <mhei@heimpold.de>
> ---
>  inittab.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/inittab.c b/inittab.c
> index 55554b9..41816b7 100644
> --- a/inittab.c
> +++ b/inittab.c
> @@ -259,12 +259,11 @@ void procd_inittab_run(const char *handler)
>  
>  	list_for_each_entry(a, &actions, list)
>  		if (!strcmp(a->handler->name, handler)) {
> -			if (a->handler->multi) {
> -				a->handler->cb(a);
> -				continue;
> -			}
>  			a->handler->cb(a);
> -			break;
> +			if (a->handler->multi)
> +				continue;
> +			else
> +				break;

... why not just change this to:

if (!a->handler->multi)
        break;

>  		}
>  }
>  
> 


Regards,
Jo
diff mbox series

Patch

diff --git a/inittab.c b/inittab.c
index 55554b9..41816b7 100644
--- a/inittab.c
+++ b/inittab.c
@@ -259,12 +259,11 @@  void procd_inittab_run(const char *handler)
 
 	list_for_each_entry(a, &actions, list)
 		if (!strcmp(a->handler->name, handler)) {
-			if (a->handler->multi) {
-				a->handler->cb(a);
-				continue;
-			}
 			a->handler->cb(a);
-			break;
+			if (a->handler->multi)
+				continue;
+			else
+				break;
 		}
 }