From 38eda16a24b5839b104a878ea5052dd2919cbda5 Mon Sep 17 00:00:00 2001 From: anlan_cs Date: Sun, 6 Feb 2022 23:47:49 -0500 Subject: [PATCH] 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 --- zebra/zebra_evpn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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),