Commit 54160ef6 authored by Alexander Aring's avatar Alexander Aring Committed by David S. Miller

net: sched: sch_api: rearrange init handling

This patch fixes the following checkpatch error:

ERROR: do not use assignment in if condition

by rearranging the if condition to execute init callback only if init
callback exists. The whole setup afterwards is called in any case,
doesn't matter if init callback is set or not. This patch has the same
behaviour as before, just without assign err variable in if condition.
It also makes the code easier to read.
Reviewed-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
Cc: David Ahern <dsahern@gmail.com>
Signed-off-by: default avatarAlexander Aring <aring@mojatatu.com>
Acked-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0ac4bd68
...@@ -1060,7 +1060,12 @@ static struct Qdisc *qdisc_create(struct net_device *dev, ...@@ -1060,7 +1060,12 @@ static struct Qdisc *qdisc_create(struct net_device *dev,
netdev_info(dev, "Caught tx_queue_len zero misconfig\n"); netdev_info(dev, "Caught tx_queue_len zero misconfig\n");
} }
if (!ops->init || (err = ops->init(sch, tca[TCA_OPTIONS])) == 0) { if (ops->init) {
err = ops->init(sch, tca[TCA_OPTIONS]);
if (err != 0)
goto err_out5;
}
if (qdisc_is_percpu_stats(sch)) { if (qdisc_is_percpu_stats(sch)) {
sch->cpu_bstats = sch->cpu_bstats =
netdev_alloc_pcpu_stats(struct gnet_stats_basic_cpu); netdev_alloc_pcpu_stats(struct gnet_stats_basic_cpu);
...@@ -1107,7 +1112,8 @@ static struct Qdisc *qdisc_create(struct net_device *dev, ...@@ -1107,7 +1112,8 @@ static struct Qdisc *qdisc_create(struct net_device *dev,
qdisc_hash_add(sch, false); qdisc_hash_add(sch, false);
return sch; return sch;
}
err_out5:
/* ops->init() failed, we call ->destroy() like qdisc_create_dflt() */ /* ops->init() failed, we call ->destroy() like qdisc_create_dflt() */
if (ops->destroy) if (ops->destroy)
ops->destroy(sch); ops->destroy(sch);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment