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; struct zebra_pbr_iptable ipt;
uint16_t cmd = ZEBRA_IPTABLE_NOTIFY_OWNER; uint16_t cmd = ZEBRA_IPTABLE_NOTIFY_OWNER;
if (!dplane_ctx_get_pbr_iptable(ctx, &ipt)) dplane_ctx_get_pbr_iptable(ctx, &ipt);
return;
if (IS_ZEBRA_DEBUG_PACKET) if (IS_ZEBRA_DEBUG_PACKET)
zlog_debug("%s: Notifying %s id %u note %u", __func__, 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; struct zebra_pbr_ipset ipset;
uint16_t cmd = ZEBRA_IPSET_NOTIFY_OWNER; uint16_t cmd = ZEBRA_IPSET_NOTIFY_OWNER;
if (!dplane_ctx_get_pbr_ipset(ctx, &ipset)) dplane_ctx_get_pbr_ipset(ctx, &ipset);
return;
if (IS_ZEBRA_DEBUG_PACKET) if (IS_ZEBRA_DEBUG_PACKET)
zlog_debug("%s: Notifying %s id %u note %u", __func__, 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; struct zebra_pbr_ipset ipset;
uint16_t cmd = ZEBRA_IPSET_ENTRY_NOTIFY_OWNER; uint16_t cmd = ZEBRA_IPSET_ENTRY_NOTIFY_OWNER;
if (!dplane_ctx_get_pbr_ipset_entry(ctx, &ipent)) dplane_ctx_get_pbr_ipset_entry(ctx, &ipent);
return; dplane_ctx_get_pbr_ipset(ctx, &ipset);
if (!dplane_ctx_get_pbr_ipset(ctx, &ipset))
return;
if (IS_ZEBRA_DEBUG_PACKET) if (IS_ZEBRA_DEBUG_PACKET)
zlog_debug("%s: Notifying %s id %u note %u", __func__, 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 */ /* Accessors for PBR iptable information */
bool void dplane_ctx_get_pbr_iptable(const struct zebra_dplane_ctx *ctx,
dplane_ctx_get_pbr_iptable(const struct zebra_dplane_ctx *ctx, struct zebra_pbr_iptable *table)
struct zebra_pbr_iptable *table)
{ {
DPLANE_CTX_VALID(ctx); DPLANE_CTX_VALID(ctx);
memcpy(table, &ctx->u.iptable, sizeof(struct zebra_pbr_iptable)); 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) struct zebra_pbr_ipset *ipset)
{ {
DPLANE_CTX_VALID(ctx); DPLANE_CTX_VALID(ctx);
if (!ipset) assert(ipset);
return false;
if (ctx->zd_op == DPLANE_OP_IPSET_ENTRY_ADD || if (ctx->zd_op == DPLANE_OP_IPSET_ENTRY_ADD ||
ctx->zd_op == DPLANE_OP_IPSET_ENTRY_DELETE) { ctx->zd_op == DPLANE_OP_IPSET_ENTRY_DELETE) {
memset(ipset, 0, sizeof(struct zebra_pbr_ipset)); 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); ZEBRA_IPSET_NAME_SIZE);
} else } else
memcpy(ipset, &ctx->u.ipset, sizeof(struct zebra_pbr_ipset)); 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) struct zebra_pbr_ipset_entry *entry)
{ {
DPLANE_CTX_VALID(ctx); DPLANE_CTX_VALID(ctx);
if (!entry) assert(entry);
return false;
memcpy(entry, &ctx->u.ipset_entry.entry, sizeof(struct zebra_pbr_ipset_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: { case DPLANE_OP_IPTABLE_DELETE: {
struct zebra_pbr_iptable ipt; 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", 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; } break;
case DPLANE_OP_IPSET_ADD: case DPLANE_OP_IPSET_ADD:
case DPLANE_OP_IPSET_DELETE: { case DPLANE_OP_IPSET_DELETE: {
struct zebra_pbr_ipset ipset; 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", zlog_debug("Dplane ipset update op %s, unique(%u), ctx %p",
dplane_op2str(dplane_ctx_get_op(ctx)), dplane_op2str(dplane_ctx_get_op(ctx)), ipset.unique,
ipset.unique, ctx); ctx);
} break; } break;
case DPLANE_OP_IPSET_ENTRY_ADD: case DPLANE_OP_IPSET_ENTRY_ADD:
case DPLANE_OP_IPSET_ENTRY_DELETE: { case DPLANE_OP_IPSET_ENTRY_DELETE: {
struct zebra_pbr_ipset_entry ipent; struct zebra_pbr_ipset_entry ipent;
if (dplane_ctx_get_pbr_ipset_entry(ctx, &ipent)) dplane_ctx_get_pbr_ipset_entry(ctx, &ipent);
zlog_debug("Dplane ipset entry update op %s, unique(%u), ctx %p", zlog_debug(
dplane_op2str(dplane_ctx_get_op(ctx)), "Dplane ipset entry update op %s, unique(%u), ctx %p",
ipent.unique, ctx); dplane_op2str(dplane_ctx_get_op(ctx)), ipent.unique,
ctx);
} break; } break;
case DPLANE_OP_NEIGH_TABLE_UPDATE: case DPLANE_OP_NEIGH_TABLE_UPDATE:
zlog_debug("Dplane neigh table op %s, ifp %s, family %s", zlog_debug("Dplane neigh table op %s, ifp %s, family %s",
dplane_op2str(dplane_ctx_get_op(ctx)), dplane_op2str(dplane_ctx_get_op(ctx)),

View File

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

View File

@ -552,13 +552,12 @@ void zebra_pbr_process_iptable(struct zebra_dplane_ctx *ctx)
else else
mode = 0; 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) ret = hook_call(zebra_pbr_iptable_update, mode, &ipt);
dplane_ctx_set_status(ctx, if (ret)
ZEBRA_DPLANE_REQUEST_SUCCESS); dplane_ctx_set_status(ctx, ZEBRA_DPLANE_REQUEST_SUCCESS);
} else
if (!ret)
dplane_ctx_set_status(ctx, ZEBRA_DPLANE_REQUEST_FAILURE); 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; mode = 1;
else else
mode = 0; mode = 0;
if (dplane_ctx_get_pbr_ipset(ctx, &ipset)) {
ret = hook_call(zebra_pbr_ipset_update, mode, &ipset); dplane_ctx_get_pbr_ipset(ctx, &ipset);
if (ret)
dplane_ctx_set_status(ctx, ret = hook_call(zebra_pbr_ipset_update, mode, &ipset);
ZEBRA_DPLANE_REQUEST_SUCCESS); if (ret)
} dplane_ctx_set_status(ctx, ZEBRA_DPLANE_REQUEST_SUCCESS);
if (!ret) else
dplane_ctx_set_status(ctx, ZEBRA_DPLANE_REQUEST_FAILURE); 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 else
mode = 0; mode = 0;
if (!dplane_ctx_get_pbr_ipset_entry(ctx, &ipset_entry)) dplane_ctx_get_pbr_ipset_entry(ctx, &ipset_entry);
return; dplane_ctx_get_pbr_ipset(ctx, &ipset);
if (!dplane_ctx_get_pbr_ipset(ctx, &ipset))
return;
ipset_entry.backpointer = &ipset; ipset_entry.backpointer = &ipset;
ret = hook_call(zebra_pbr_ipset_entry_update, mode, &ipset_entry); ret = hook_call(zebra_pbr_ipset_entry_update, mode, &ipset_entry);