zebra: Remove goto's that do not do anything special

If we have this semantics:

int ret = FAILURE;

if (foo)
    goto done;

....

done:
    return ret;

This pattern does us no favors and makes it harder to figure out what is going
on.  Let's remove.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2022-10-03 13:13:50 -04:00
parent 7d83e13937
commit c7f0429e81

View File

@ -2784,7 +2784,7 @@ int dplane_ctx_route_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
struct dplane_intf_extra *if_extra;
if (!ctx || !rn || !re)
goto done;
return ret;
TAILQ_INIT(&ctx->u.rinfo.intf_extra_q);
@ -2875,8 +2875,7 @@ int dplane_ctx_route_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
/* Don't need some info when capturing a system notification */
if (op == DPLANE_OP_SYS_ROUTE_ADD ||
op == DPLANE_OP_SYS_ROUTE_DELETE) {
ret = AOK;
goto done;
return AOK;
}
/* Extract ns info - can't use pointers to 'core' structs */
@ -2897,14 +2896,12 @@ int dplane_ctx_route_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
* If its a delete we only use the prefix anyway, so this only
* matters for INSTALL/UPDATE.
*/
if (zebra_nhg_kernel_nexthops_enabled()
&& (((op == DPLANE_OP_ROUTE_INSTALL)
|| (op == DPLANE_OP_ROUTE_UPDATE))
&& !CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED)
&& !CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_QUEUED))) {
ret = ENOENT;
goto done;
}
if (zebra_nhg_kernel_nexthops_enabled() &&
(((op == DPLANE_OP_ROUTE_INSTALL) ||
(op == DPLANE_OP_ROUTE_UPDATE)) &&
!CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED) &&
!CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_QUEUED)))
return ENOENT;
re->nhe_installed_id = nhe->id;
}
@ -2916,10 +2913,7 @@ int dplane_ctx_route_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
re->dplane_sequence = zebra_router_get_next_sequence();
ctx->zd_seq = re->dplane_sequence;
ret = AOK;
done:
return ret;
return AOK;
}
static int dplane_ctx_tc_qdisc_init(struct zebra_dplane_ctx *ctx,
@ -3031,7 +3025,7 @@ int dplane_ctx_nexthop_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
int ret = EINVAL;
if (!ctx || !nhe)
goto done;
return ret;
ctx->zd_op = op;
ctx->zd_status = ZEBRA_DPLANE_REQUEST_SUCCESS;
@ -3066,7 +3060,6 @@ int dplane_ctx_nexthop_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
ret = AOK;
done:
return ret;
}
@ -3088,7 +3081,7 @@ int dplane_ctx_intf_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
bool set_pdown, unset_pdown;
if (!ctx || !ifp)
goto done;
return ret;
ctx->zd_op = op;
ctx->zd_status = ZEBRA_DPLANE_REQUEST_SUCCESS;
@ -3133,7 +3126,6 @@ int dplane_ctx_intf_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
ret = AOK;
done:
return ret;
}
@ -3161,10 +3153,8 @@ int dplane_ctx_lsp_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
/* This may be called to create/init a dplane context, not necessarily
* to copy an lsp object.
*/
if (lsp == NULL) {
ret = AOK;
goto done;
}
if (lsp == NULL)
return ret;
if (IS_ZEBRA_DEBUG_DPLANE_DETAIL)
zlog_debug("init dplane ctx %s: in-label %u ecmp# %d",
@ -3207,7 +3197,7 @@ int dplane_ctx_lsp_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
}
if (ret != AOK)
goto done;
return ret;
/* Capture backup nhlfes/nexthops */
frr_each(nhlfe_list, &lsp->backup_nhlfe_list, nhlfe) {
@ -3228,11 +3218,6 @@ int dplane_ctx_lsp_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
new_nhlfe->nexthop->flags = nhlfe->nexthop->flags;
}
/* On error the ctx will be cleaned-up, so we don't need to
* deal with any allocated nhlfe or nexthop structs here.
*/
done:
return ret;
}
@ -3293,11 +3278,11 @@ static int dplane_ctx_pw_init(struct zebra_dplane_ctx *ctx,
afi = (pw->af == AF_INET) ? AFI_IP : AFI_IP6;
table = zebra_vrf_table(afi, SAFI_UNICAST, pw->vrf_id);
if (table == NULL)
goto done;
return ret;
rn = route_node_match(table, &p);
if (rn == NULL)
goto done;
return ret;
re = NULL;
RNODE_FOREACH_RE(rn, re) {
@ -3365,10 +3350,7 @@ static int dplane_ctx_pw_init(struct zebra_dplane_ctx *ctx,
}
route_unlock_node(rn);
ret = AOK;
done:
return ret;
return AOK;
}
/**
@ -3943,12 +3925,11 @@ enum zebra_dplane_result dplane_route_add(struct route_node *rn,
enum zebra_dplane_result ret = ZEBRA_DPLANE_REQUEST_FAILURE;
if (rn == NULL || re == NULL)
goto done;
return ret;
ret = dplane_route_update_internal(rn, re, NULL,
DPLANE_OP_ROUTE_INSTALL);
done:
return ret;
}
@ -3962,11 +3943,11 @@ enum zebra_dplane_result dplane_route_update(struct route_node *rn,
enum zebra_dplane_result ret = ZEBRA_DPLANE_REQUEST_FAILURE;
if (rn == NULL || re == NULL)
goto done;
return ret;
ret = dplane_route_update_internal(rn, re, old_re,
DPLANE_OP_ROUTE_UPDATE);
done:
return ret;
}
@ -3979,12 +3960,11 @@ enum zebra_dplane_result dplane_route_delete(struct route_node *rn,
enum zebra_dplane_result ret = ZEBRA_DPLANE_REQUEST_FAILURE;
if (rn == NULL || re == NULL)
goto done;
return ret;
ret = dplane_route_update_internal(rn, re, NULL,
DPLANE_OP_ROUTE_DELETE);
done:
return ret;
}
@ -3997,18 +3977,16 @@ enum zebra_dplane_result dplane_sys_route_add(struct route_node *rn,
enum zebra_dplane_result ret = ZEBRA_DPLANE_REQUEST_FAILURE;
/* Ignore this event unless a provider plugin has requested it. */
if (!zdplane_info.dg_sys_route_notifs) {
ret = ZEBRA_DPLANE_REQUEST_SUCCESS;
goto done;
}
if (!zdplane_info.dg_sys_route_notifs)
return ZEBRA_DPLANE_REQUEST_SUCCESS;
if (rn == NULL || re == NULL)
goto done;
return ret;
ret = dplane_route_update_internal(rn, re, NULL,
DPLANE_OP_SYS_ROUTE_ADD);
done:
return ret;
}
@ -4021,18 +3999,15 @@ enum zebra_dplane_result dplane_sys_route_del(struct route_node *rn,
enum zebra_dplane_result ret = ZEBRA_DPLANE_REQUEST_FAILURE;
/* Ignore this event unless a provider plugin has requested it. */
if (!zdplane_info.dg_sys_route_notifs) {
ret = ZEBRA_DPLANE_REQUEST_SUCCESS;
goto done;
}
if (!zdplane_info.dg_sys_route_notifs)
return ZEBRA_DPLANE_REQUEST_SUCCESS;
if (rn == NULL || re == NULL)
goto done;
return ret;
ret = dplane_route_update_internal(rn, re, NULL,
DPLANE_OP_SYS_ROUTE_DELETE);
done:
return ret;
}
@ -6463,7 +6438,7 @@ int dplane_clean_ctx_queue(bool (*context_cb)(struct zebra_dplane_ctx *ctx,
TAILQ_INIT(&work_list);
if (context_cb == NULL)
goto done;
return AOK;
/* Walk the pending context queue under the dplane lock. */
DPLANE_LOCK();
@ -6487,9 +6462,7 @@ int dplane_clean_ctx_queue(bool (*context_cb)(struct zebra_dplane_ctx *ctx,
dplane_ctx_fini(&ctx);
}
done:
return 0;
return AOK;
}
/* Indicates zebra shutdown/exit is in progress. Some operations may be
@ -6553,10 +6526,8 @@ static bool dplane_work_pending(void)
}
DPLANE_UNLOCK();
if (ctx != NULL) {
ret = true;
goto done;
}
if (ctx != NULL)
return true;
while (prov) {
@ -6579,7 +6550,6 @@ static bool dplane_work_pending(void)
if (ctx != NULL)
ret = true;
done:
return ret;
}