[OpenWrt-Devel] [PATCH V2] procd: simplify code in procd_inittab_run

Bjørn Mork bjorn at mork.no
Mon Dec 17 06:01:01 EST 2018


John Crispin <john at phrozen.org> writes:
> On 09/12/2018 22:54, Michael Heimpold wrote:
>> This is a trial to make it more obvious what the historically
>> grown code is actually doing.
>>
>> Signed-off-by: Michael Heimpold <mhei at heimpold.de>
>> ---
>> V2: use Jo-Philipp Wich's proposal
>>
>>   inittab.c | 7 ++-----
>>   1 file changed, 2 insertions(+), 5 deletions(-)
>>
>> diff --git a/inittab.c b/inittab.c
>> index 55554b9..c9e6c13 100644
>> --- a/inittab.c
>> +++ b/inittab.c
>> @@ -259,12 +259,9 @@ 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)
>> +				break;
>
> this changes the logic. the cb() needs to be below and not above the
> if clause

I don't think it does?  The original code calls cb() in two places to
achieve the same effect.  The proposed patch makes this a lot cleaner
and clearer IMHO



Bjørn

_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list