diff options
| author | anlan_cs <vic.lan@pica8.com> | 2022-02-06 23:47:49 -0500 |
|---|---|---|
| committer | anlan_cs <vic.lan@pica8.com> | 2022-03-05 06:57:35 +0800 |
| commit | 38eda16a24b5839b104a878ea5052dd2919cbda5 (patch) | |
| tree | a362a6dc67d70bc5760271d550cd2c360ec53c2f | |
| parent | 2821405a69838f8c144620a9a59aff56d51bd761 (diff) | |
zebra: Delay the usage of one variable until need
In the loop, local variable `ip` is always set even if the check condition
is not satisfied.
Avoid the redundant set, move this set exactly after the check condition is
satisfied. Set `ip` only if the check condition is met, otherwise needn't.
Signed-off-by: anlan_cs <vic.lan@pica8.com>
| -rw-r--r-- | zebra/zebra_evpn.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/zebra/zebra_evpn.c b/zebra/zebra_evpn.c index 13b9cc2002..21fb5299bc 100644 --- a/zebra/zebra_evpn.c +++ b/zebra/zebra_evpn.c @@ -344,10 +344,10 @@ int zebra_evpn_add_macip_for_intf(struct interface *ifp, for (ALL_LIST_ELEMENTS(ifp->connected, cnode, cnnode, c)) { struct ipaddr ip; - memset(&ip, 0, sizeof(struct ipaddr)); if (!CHECK_FLAG(c->conf, ZEBRA_IFC_REAL)) continue; + memset(&ip, 0, sizeof(struct ipaddr)); if (c->address->family == AF_INET) { ip.ipa_type = IPADDR_V4; memcpy(&(ip.ipaddr_v4), &(c->address->u.prefix4), |
