Merge pull request #9914 from donaldsharp/coverity_script

Do not return true/false in dplane_ctx_get_XXX functions
This commit is contained in:
Igor Ryzhov 2021-11-17 18:17:30 +03:00 committed by GitHub
commit aeeb9a8e96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 59 deletions

View File

@ -871,8 +871,7 @@ void zsend_iptable_notify_owner(const struct zebra_dplane_ctx *ctx,
struct zebra_pbr_iptable ipt;
uint16_t cmd = ZEBRA_IPTABLE_NOTIFY_OWNER;
if (!dplane_ctx_get_pbr_iptable(ctx, &ipt))
return;
dplane_ctx_get_pbr_iptable(ctx, &ipt);
if (IS_ZEBRA_DEBUG_PACKET)
zlog_debug("%s: Notifying %s id %u note %u", __func__,
@ -906,8 +905,7 @@ void zsend_ipset_notify_owner(const struct zebra_dplane_ctx *ctx,
struct zebra_pbr_ipset ipset;
uint16_t cmd = ZEBRA_IPSET_NOTIFY_OWNER;
if (!dplane_ctx_get_pbr_ipset(ctx, &ipset))
return;
dplane_ctx_get_pbr_ipset(ctx, &ipset);
if (IS_ZEBRA_DEBUG_PACKET)
zlog_debug("%s: Notifying %s id %u note %u", __func__,
@ -942,10 +940,8 @@ void zsend_ipset_entry_notify_owner(const struct zebra_dplane_ctx *ctx,
struct zebra_pbr_ipset ipset;
uint16_t cmd = ZEBRA_IPSET_ENTRY_NOTIFY_OWNER;
if (!dplane_ctx_get_pbr_ipset_entry(ctx, &ipent))
return;
if (!dplane_ctx_get_pbr_ipset(ctx, &ipset))
return;
dplane_ctx_get_pbr_ipset_entry(ctx, &ipent);
dplane_ctx_get_pbr_ipset(ctx, &ipset);
if (IS_ZEBRA_DEBUG_PACKET)
zlog_debug("%s: Notifying %s id %u note %u", __func__,

View File

@ -2145,23 +2145,21 @@ dplane_ctx_get_br_port_backup_nhg_id(const struct zebra_dplane_ctx *ctx)
}
/* Accessors for PBR iptable information */
bool
dplane_ctx_get_pbr_iptable(const struct zebra_dplane_ctx *ctx,
void dplane_ctx_get_pbr_iptable(const struct zebra_dplane_ctx *ctx,
struct zebra_pbr_iptable *table)
{
DPLANE_CTX_VALID(ctx);
memcpy(table, &ctx->u.iptable, sizeof(struct zebra_pbr_iptable));
return true;
}
bool dplane_ctx_get_pbr_ipset(const struct zebra_dplane_ctx *ctx,
void dplane_ctx_get_pbr_ipset(const struct zebra_dplane_ctx *ctx,
struct zebra_pbr_ipset *ipset)
{
DPLANE_CTX_VALID(ctx);
if (!ipset)
return false;
assert(ipset);
if (ctx->zd_op == DPLANE_OP_IPSET_ENTRY_ADD ||
ctx->zd_op == DPLANE_OP_IPSET_ENTRY_DELETE) {
memset(ipset, 0, sizeof(struct zebra_pbr_ipset));
@ -2171,18 +2169,16 @@ bool dplane_ctx_get_pbr_ipset(const struct zebra_dplane_ctx *ctx,
ZEBRA_IPSET_NAME_SIZE);
} else
memcpy(ipset, &ctx->u.ipset, sizeof(struct zebra_pbr_ipset));
return true;
}
bool dplane_ctx_get_pbr_ipset_entry(const struct zebra_dplane_ctx *ctx,
void dplane_ctx_get_pbr_ipset_entry(const struct zebra_dplane_ctx *ctx,
struct zebra_pbr_ipset_entry *entry)
{
DPLANE_CTX_VALID(ctx);
if (!entry)
return false;
assert(entry);
memcpy(entry, &ctx->u.ipset_entry.entry, sizeof(struct zebra_pbr_ipset_entry));
return true;
}
/*
@ -5060,29 +5056,30 @@ static void kernel_dplane_log_detail(struct zebra_dplane_ctx *ctx)
case DPLANE_OP_IPTABLE_DELETE: {
struct zebra_pbr_iptable ipt;
if (dplane_ctx_get_pbr_iptable(ctx, &ipt))
dplane_ctx_get_pbr_iptable(ctx, &ipt);
zlog_debug("Dplane iptable update op %s, unique(%u), ctx %p",
dplane_op2str(dplane_ctx_get_op(ctx)), ipt.unique, ctx);
dplane_op2str(dplane_ctx_get_op(ctx)), ipt.unique,
ctx);
} break;
case DPLANE_OP_IPSET_ADD:
case DPLANE_OP_IPSET_DELETE: {
struct zebra_pbr_ipset ipset;
if (dplane_ctx_get_pbr_ipset(ctx, &ipset))
dplane_ctx_get_pbr_ipset(ctx, &ipset);
zlog_debug("Dplane ipset update op %s, unique(%u), ctx %p",
dplane_op2str(dplane_ctx_get_op(ctx)),
ipset.unique, ctx);
dplane_op2str(dplane_ctx_get_op(ctx)), ipset.unique,
ctx);
} break;
case DPLANE_OP_IPSET_ENTRY_ADD:
case DPLANE_OP_IPSET_ENTRY_DELETE: {
struct zebra_pbr_ipset_entry ipent;
if (dplane_ctx_get_pbr_ipset_entry(ctx, &ipent))
zlog_debug("Dplane ipset entry update op %s, unique(%u), ctx %p",
dplane_op2str(dplane_ctx_get_op(ctx)),
ipent.unique, ctx);
dplane_ctx_get_pbr_ipset_entry(ctx, &ipent);
zlog_debug(
"Dplane ipset entry update op %s, unique(%u), ctx %p",
dplane_op2str(dplane_ctx_get_op(ctx)), ipent.unique,
ctx);
} break;
case DPLANE_OP_NEIGH_TABLE_UPDATE:
zlog_debug("Dplane neigh table op %s, ifp %s, family %s",
dplane_op2str(dplane_ctx_get_op(ctx)),

View File

@ -526,16 +526,13 @@ const struct prefix *
dplane_ctx_rule_get_old_dst_ip(const struct zebra_dplane_ctx *ctx);
/* Accessors for policy based routing iptable information */
struct zebra_pbr_iptable;
bool
dplane_ctx_get_pbr_iptable(const struct zebra_dplane_ctx *ctx,
void dplane_ctx_get_pbr_iptable(const struct zebra_dplane_ctx *ctx,
struct zebra_pbr_iptable *table);
struct zebra_pbr_ipset;
bool
dplane_ctx_get_pbr_ipset(const struct zebra_dplane_ctx *ctx,
void dplane_ctx_get_pbr_ipset(const struct zebra_dplane_ctx *ctx,
struct zebra_pbr_ipset *ipset);
struct zebra_pbr_ipset_entry;
bool
dplane_ctx_get_pbr_ipset_entry(const struct zebra_dplane_ctx *ctx,
void dplane_ctx_get_pbr_ipset_entry(const struct zebra_dplane_ctx *ctx,
struct zebra_pbr_ipset_entry *entry);
/* Accessors for bridge port information */
uint32_t dplane_ctx_get_br_port_flags(const struct zebra_dplane_ctx *ctx);

View File

@ -552,13 +552,12 @@ void zebra_pbr_process_iptable(struct zebra_dplane_ctx *ctx)
else
mode = 0;
if (dplane_ctx_get_pbr_iptable(ctx, &ipt)) {
dplane_ctx_get_pbr_iptable(ctx, &ipt);
ret = hook_call(zebra_pbr_iptable_update, mode, &ipt);
if (ret)
dplane_ctx_set_status(ctx,
ZEBRA_DPLANE_REQUEST_SUCCESS);
}
if (!ret)
dplane_ctx_set_status(ctx, ZEBRA_DPLANE_REQUEST_SUCCESS);
else
dplane_ctx_set_status(ctx, ZEBRA_DPLANE_REQUEST_FAILURE);
}
@ -571,13 +570,13 @@ void zebra_pbr_process_ipset(struct zebra_dplane_ctx *ctx)
mode = 1;
else
mode = 0;
if (dplane_ctx_get_pbr_ipset(ctx, &ipset)) {
dplane_ctx_get_pbr_ipset(ctx, &ipset);
ret = hook_call(zebra_pbr_ipset_update, mode, &ipset);
if (ret)
dplane_ctx_set_status(ctx,
ZEBRA_DPLANE_REQUEST_SUCCESS);
}
if (!ret)
dplane_ctx_set_status(ctx, ZEBRA_DPLANE_REQUEST_SUCCESS);
else
dplane_ctx_set_status(ctx, ZEBRA_DPLANE_REQUEST_FAILURE);
}
@ -592,10 +591,9 @@ void zebra_pbr_process_ipset_entry(struct zebra_dplane_ctx *ctx)
else
mode = 0;
if (!dplane_ctx_get_pbr_ipset_entry(ctx, &ipset_entry))
return;
if (!dplane_ctx_get_pbr_ipset(ctx, &ipset))
return;
dplane_ctx_get_pbr_ipset_entry(ctx, &ipset_entry);
dplane_ctx_get_pbr_ipset(ctx, &ipset);
ipset_entry.backpointer = &ipset;
ret = hook_call(zebra_pbr_ipset_entry_update, mode, &ipset_entry);