From 3d0b8206376100f35812a31a6656cfa520f57492 Mon Sep 17 00:00:00 2001 From: nickcooper-zhangtonghao Date: Thu, 4 Aug 2016 04:50:03 -0700 Subject: [PATCH] ovn-controller: Simplify ofctrl_run(), pinctrl_run(). Before calling the function "ofctrl_run" and "pinctrl_run", the "br-int" has been checked. Remove the conditional statements in the function may make the code clearer. Signed-off-by: nickcooper-zhangtonghao Signed-off-by: Ben Pfaff --- ovn/controller/ofctrl.c | 15 +++++---------- ovn/controller/pinctrl.c | 16 +++++----------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/ovn/controller/ofctrl.c b/ovn/controller/ofctrl.c index 9388cb89b..e97115741 100644 --- a/ovn/controller/ofctrl.c +++ b/ovn/controller/ofctrl.c @@ -431,17 +431,12 @@ recv_S_UPDATE_FLOWS(const struct ofp_header *oh, enum ofptype type) enum mf_field_id ofctrl_run(const struct ovsrec_bridge *br_int) { - if (br_int) { - char *target; - target = xasprintf("unix:%s/%s.mgmt", ovs_rundir(), br_int->name); - if (strcmp(target, rconn_get_target(swconn))) { - VLOG_INFO("%s: connecting to switch", target); - rconn_connect(swconn, target, target); - } - free(target); - } else { - rconn_disconnect(swconn); + char *target = xasprintf("unix:%s/%s.mgmt", ovs_rundir(), br_int->name); + if (strcmp(target, rconn_get_target(swconn))) { + VLOG_INFO("%s: connecting to switch", target); + rconn_connect(swconn, target, target); } + free(target); rconn_run(swconn); diff --git a/ovn/controller/pinctrl.c b/ovn/controller/pinctrl.c index bd685fe41..ca49ca632 100644 --- a/ovn/controller/pinctrl.c +++ b/ovn/controller/pinctrl.c @@ -461,18 +461,12 @@ pinctrl_run(struct controller_ctx *ctx, const struct lport_index *lports, const char *chassis_id, struct hmap *local_datapaths) { - if (br_int) { - char *target; - - target = xasprintf("unix:%s/%s.mgmt", ovs_rundir(), br_int->name); - if (strcmp(target, rconn_get_target(swconn))) { - VLOG_INFO("%s: connecting to switch", target); - rconn_connect(swconn, target, target); - } - free(target); - } else { - rconn_disconnect(swconn); + char *target = xasprintf("unix:%s/%s.mgmt", ovs_rundir(), br_int->name); + if (strcmp(target, rconn_get_target(swconn))) { + VLOG_INFO("%s: connecting to switch", target); + rconn_connect(swconn, target, target); } + free(target); rconn_run(swconn); -- 2.39.5