Merge pull request #5907 from ton31337/fix/replace_sizeof_coccinelle

Bool related stuff
This commit is contained in:
Quentin Young 2020-03-04 19:05:05 -05:00 committed by GitHub
commit ea16e19080
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 127 additions and 45 deletions

View File

@ -383,7 +383,7 @@ int bfdd_bfd_sessions_single_hop_administrative_down_modify(
bs = nb_running_get_entry(dnode, NULL, true); bs = nb_running_get_entry(dnode, NULL, true);
if (shutdown == false) { if (!shutdown) {
if (!BFD_CHECK_FLAG(bs->flags, BFD_SESS_FLAG_SHUTDOWN)) if (!BFD_CHECK_FLAG(bs->flags, BFD_SESS_FLAG_SHUTDOWN))
return NB_OK; return NB_OK;
@ -447,7 +447,7 @@ int bfdd_bfd_sessions_single_hop_echo_mode_modify(enum nb_event event,
bs = nb_running_get_entry(dnode, NULL, true); bs = nb_running_get_entry(dnode, NULL, true);
if (echo == false) { if (!echo) {
if (!BFD_CHECK_FLAG(bs->flags, BFD_SESS_FLAG_ECHO)) if (!BFD_CHECK_FLAG(bs->flags, BFD_SESS_FLAG_ECHO))
return NB_OK; return NB_OK;

View File

@ -500,7 +500,7 @@ static void _display_peers_brief(struct vty *vty, const char *vrfname, bool use_
bvt.vrfname = vrfname; bvt.vrfname = vrfname;
if (use_json == false) { if (!use_json) {
bvt.vty = vty; bvt.vty = vty;
vty_out(vty, "Session count: %lu\n", bfd_get_session_count()); vty_out(vty, "Session count: %lu\n", bfd_get_session_count());

View File

@ -299,7 +299,7 @@ static int bgp_node_set_defer_flag(struct bgp_node *rn, bool delete)
{ {
struct peer *peer; struct peer *peer;
struct bgp_path_info *old_pi, *nextpi; struct bgp_path_info *old_pi, *nextpi;
bool set_flag = 0; bool set_flag = false;
struct bgp *bgp = NULL; struct bgp *bgp = NULL;
struct bgp_table *table = NULL; struct bgp_table *table = NULL;
afi_t afi = 0; afi_t afi = 0;
@ -339,7 +339,7 @@ static int bgp_node_set_defer_flag(struct bgp_node *rn, bool delete)
*/ */
if (CHECK_FLAG(old_pi->flags, BGP_PATH_STALE) if (CHECK_FLAG(old_pi->flags, BGP_PATH_STALE)
&& (old_pi->sub_type == BGP_ROUTE_NORMAL)) { && (old_pi->sub_type == BGP_ROUTE_NORMAL)) {
set_flag = 1; set_flag = true;
} else { } else {
/* If the peer is graceful restart capable and peer is /* If the peer is graceful restart capable and peer is
* restarting mode, set the flag BGP_NODE_SELECT_DEFER * restarting mode, set the flag BGP_NODE_SELECT_DEFER
@ -349,7 +349,7 @@ static int bgp_node_set_defer_flag(struct bgp_node *rn, bool delete)
&& BGP_PEER_RESTARTING_MODE(peer) && BGP_PEER_RESTARTING_MODE(peer)
&& (old_pi && (old_pi
&& old_pi->sub_type == BGP_ROUTE_NORMAL)) { && old_pi->sub_type == BGP_ROUTE_NORMAL)) {
set_flag = 1; set_flag = true;
} }
} }
if (set_flag) if (set_flag)

View File

@ -9440,7 +9440,7 @@ static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty,
bool use_json, bool use_json,
json_object *json) json_object *json)
{ {
bool rbit_status = 0; bool rbit_status = false;
if (!use_json) if (!use_json)
vty_out(vty, "\n R bit: "); vty_out(vty, "\n R bit: ");
@ -9450,9 +9450,9 @@ static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty,
&& (p->status == Established)) { && (p->status == Established)) {
if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV)) if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV))
rbit_status = 1; rbit_status = true;
else else
rbit_status = 0; rbit_status = false;
} }
if (rbit_status) { if (rbit_status) {

View File

@ -3148,7 +3148,7 @@ int bgp_handle_socket(struct bgp *bgp, struct vrf *vrf, vrf_id_t old_vrf_id,
/* /*
* suppress vrf socket * suppress vrf socket
*/ */
if (create == false) { if (!create) {
bgp_close_vrf_socket(bgp); bgp_close_vrf_socket(bgp);
return 0; return 0;
} }

View File

@ -177,7 +177,7 @@ int funcname_frrzmq_thread_add_read(struct thread_master *master,
else { else {
cb = XCALLOC(MTYPE_ZEROMQ_CB, sizeof(struct frrzmq_cb)); cb = XCALLOC(MTYPE_ZEROMQ_CB, sizeof(struct frrzmq_cb));
cb->write.cancelled = 1; cb->write.cancelled = true;
*cbp = cb; *cbp = cb;
} }
@ -187,7 +187,7 @@ int funcname_frrzmq_thread_add_read(struct thread_master *master,
cb->read.cb_msg = msgfunc; cb->read.cb_msg = msgfunc;
cb->read.cb_part = partfunc; cb->read.cb_part = partfunc;
cb->read.cb_error = errfunc; cb->read.cb_error = errfunc;
cb->read.cancelled = 0; cb->read.cancelled = false;
if (events & ZMQ_POLLIN) { if (events & ZMQ_POLLIN) {
if (cb->read.thread) { if (cb->read.thread) {
@ -285,7 +285,7 @@ int funcname_frrzmq_thread_add_write(struct thread_master *master,
else { else {
cb = XCALLOC(MTYPE_ZEROMQ_CB, sizeof(struct frrzmq_cb)); cb = XCALLOC(MTYPE_ZEROMQ_CB, sizeof(struct frrzmq_cb));
cb->read.cancelled = 1; cb->read.cancelled = true;
*cbp = cb; *cbp = cb;
} }
@ -295,7 +295,7 @@ int funcname_frrzmq_thread_add_write(struct thread_master *master,
cb->write.cb_msg = msgfunc; cb->write.cb_msg = msgfunc;
cb->write.cb_part = NULL; cb->write.cb_part = NULL;
cb->write.cb_error = errfunc; cb->write.cb_error = errfunc;
cb->write.cancelled = 0; cb->write.cancelled = false;
if (events & ZMQ_POLLOUT) { if (events & ZMQ_POLLOUT) {
if (cb->write.thread) { if (cb->write.thread) {
@ -316,7 +316,7 @@ void frrzmq_thread_cancel(struct frrzmq_cb **cb, struct cb_core *core)
{ {
if (!cb || !*cb) if (!cb || !*cb)
return; return;
core->cancelled = 1; core->cancelled = true;
if (core->thread) { if (core->thread) {
thread_cancel(core->thread); thread_cancel(core->thread);
core->thread = NULL; core->thread = NULL;

View File

@ -383,7 +383,7 @@ static int frr_opt(int opt)
exit(0); exit(0);
break; break;
case 'd': case 'd':
di->daemon_mode = 1; di->daemon_mode = true;
break; break;
case 'M': case 'M':
oc = XMALLOC(MTYPE_TMP, sizeof(*oc)); oc = XMALLOC(MTYPE_TMP, sizeof(*oc));
@ -467,12 +467,12 @@ static int frr_opt(int opt)
case 'C': case 'C':
if (di->flags & FRR_NO_CFG_PID_DRY) if (di->flags & FRR_NO_CFG_PID_DRY)
return 1; return 1;
di->dryrun = 1; di->dryrun = true;
break; break;
case 't': case 't':
if (di->flags & FRR_NO_CFG_PID_DRY) if (di->flags & FRR_NO_CFG_PID_DRY)
return 1; return 1;
di->terminal = 1; di->terminal = true;
break; break;
case 'z': case 'z':
di->zpathspace = true; di->zpathspace = true;

View File

@ -58,7 +58,7 @@ static const char *execname = NULL;
void frrmod_init(struct frrmod_runtime *modinfo) void frrmod_init(struct frrmod_runtime *modinfo)
{ {
modinfo->finished_loading = 1; modinfo->finished_loading = true;
*frrmod_last = modinfo; *frrmod_last = modinfo;
frrmod_last = &modinfo->next; frrmod_last = &modinfo->next;
@ -134,7 +134,7 @@ struct frrmod_runtime *frrmod_load(const char *spec, const char *dir, char *err,
goto out_fail; goto out_fail;
} }
rtinfo->finished_loading = 1; rtinfo->finished_loading = true;
*frrmod_last = rtinfo; *frrmod_last = rtinfo;
frrmod_last = &rtinfo->next; frrmod_last = &rtinfo->next;

View File

@ -996,7 +996,7 @@ static int nb_transaction_process(enum nb_event event,
* Only try to release resources that were allocated * Only try to release resources that were allocated
* successfully. * successfully.
*/ */
if (event == NB_EV_ABORT && change->prepare_ok == false) if (event == NB_EV_ABORT && !change->prepare_ok)
break; break;
/* Call the appropriate callback. */ /* Call the appropriate callback. */

View File

@ -2039,7 +2039,7 @@ static void prefix_list_reset_afi(afi_t afi, int orf)
assert(master->str.head == NULL); assert(master->str.head == NULL);
assert(master->str.tail == NULL); assert(master->str.tail == NULL);
master->seqnum = 1; master->seqnum = true;
master->recent = NULL; master->recent = NULL;
} }

View File

@ -2447,7 +2447,7 @@ route_map_result_t route_map_apply(struct route_map *map,
} }
for (; index; index = index->next) { for (; index; index = index->next) {
if (skip_match_clause == false) { if (!skip_match_clause) {
/* Apply this index. */ /* Apply this index. */
match_ret = route_map_apply_match(&index->match_list, match_ret = route_map_apply_match(&index->match_list,
prefix, type, object); prefix, type, object);

View File

@ -254,7 +254,7 @@ bool seqlock_check(struct seqlock *sqlo, seqlock_val_t val)
cur = atomic_load_explicit(&sqlo->pos, memory_order_relaxed); cur = atomic_load_explicit(&sqlo->pos, memory_order_relaxed);
if (!(cur & SEQLOCK_HELD)) if (!(cur & SEQLOCK_HELD))
return 1; return true;
cur = SEQLOCK_VAL(cur) - val - 1; cur = SEQLOCK_VAL(cur) - val - 1;
assert(cur < 0x40000000 || cur > 0xc0000000); assert(cur < 0x40000000 || cur > 0xc0000000);
return cur < 0x80000000; return cur < 0x80000000;

View File

@ -202,7 +202,7 @@ void pbr_map_reason_string(unsigned int reason, char *buf, int size)
void pbr_map_final_interface_deletion(struct pbr_map *pbrm, void pbr_map_final_interface_deletion(struct pbr_map *pbrm,
struct pbr_map_interface *pmi) struct pbr_map_interface *pmi)
{ {
if (pmi->delete == true && !pbr_map_interface_is_installed(pbrm, pmi)) { if (pmi->delete && !pbr_map_interface_is_installed(pbrm, pmi)) {
listnode_delete(pbrm->incoming, pmi); listnode_delete(pbrm->incoming, pmi);
pmi->pbrm = NULL; pmi->pbrm = NULL;

View File

@ -255,7 +255,7 @@ bool pim_nexthop_match(struct pim_instance *pim, struct in_addr addr,
int num_ifindex; int num_ifindex;
if (addr.s_addr == INADDR_NONE) if (addr.s_addr == INADDR_NONE)
return 0; return false;
memset(nexthop_tab, 0, memset(nexthop_tab, 0,
sizeof(struct pim_zlookup_nexthop) * MULTIPATH_NUM); sizeof(struct pim_zlookup_nexthop) * MULTIPATH_NUM);
@ -268,7 +268,7 @@ bool pim_nexthop_match(struct pim_instance *pim, struct in_addr addr,
zlog_warn( zlog_warn(
"%s %s: could not find nexthop ifindex for address %s", "%s %s: could not find nexthop ifindex for address %s",
__FILE__, __PRETTY_FUNCTION__, addr_str); __FILE__, __PRETTY_FUNCTION__, addr_str);
return 0; return false;
} }
while (i < num_ifindex) { while (i < num_ifindex) {
@ -319,12 +319,12 @@ bool pim_nexthop_match(struct pim_instance *pim, struct in_addr addr,
if (nexthop_tab[i].nexthop_addr.u.prefix4.s_addr if (nexthop_tab[i].nexthop_addr.u.prefix4.s_addr
== ip_src.s_addr) == ip_src.s_addr)
return 1; return true;
i++; i++;
} }
return 0; return false;
} }
/* Given a source address and a neighbor address, check if the neighbor is one /* Given a source address and a neighbor address, check if the neighbor is one
@ -348,7 +348,7 @@ bool pim_nexthop_match_nht_cache(struct pim_instance *pim, struct in_addr addr,
pnc = pim_nexthop_cache_find(pim, &rpf); pnc = pim_nexthop_cache_find(pim, &rpf);
if (!pnc || !pnc->nexthop_num) if (!pnc || !pnc->nexthop_num)
return 0; return false;
for (nh_node = pnc->nexthop; nh_node; nh_node = nh_node->next) { for (nh_node = pnc->nexthop; nh_node; nh_node = nh_node->next) {
first_ifindex = nh_node->ifindex; first_ifindex = nh_node->ifindex;
@ -398,10 +398,10 @@ bool pim_nexthop_match_nht_cache(struct pim_instance *pim, struct in_addr addr,
} }
if (nh_node->gate.ipv4.s_addr == ip_src.s_addr) if (nh_node->gate.ipv4.s_addr == ip_src.s_addr)
return 1; return true;
} }
return 0; return false;
} }
void pim_rp_nexthop_del(struct rp_info *rp_info) void pim_rp_nexthop_del(struct rp_info *rp_info)

View File

@ -1151,7 +1151,7 @@ static inline bool pim_upstream_is_msdp_peer_sa(struct pim_upstream *up)
* AND inherited_olist(S,G) != NULL ) ) * AND inherited_olist(S,G) != NULL ) )
* } * }
*/ */
int pim_upstream_evaluate_join_desired(struct pim_instance *pim, bool pim_upstream_evaluate_join_desired(struct pim_instance *pim,
struct pim_upstream *up) struct pim_upstream *up)
{ {
bool empty_imm_oil; bool empty_imm_oil;

View File

@ -303,8 +303,8 @@ struct pim_upstream *pim_upstream_del(struct pim_instance *pim,
struct pim_upstream *up, struct pim_upstream *up,
const char *name); const char *name);
int pim_upstream_evaluate_join_desired(struct pim_instance *pim, bool pim_upstream_evaluate_join_desired(struct pim_instance *pim,
struct pim_upstream *up); struct pim_upstream *up);
int pim_upstream_evaluate_join_desired_interface(struct pim_upstream *up, int pim_upstream_evaluate_join_desired_interface(struct pim_upstream *up,
struct pim_ifchannel *ch, struct pim_ifchannel *ch,
struct pim_ifchannel *starch); struct pim_ifchannel *starch);

View File

@ -0,0 +1,13 @@
@@
bool b;
@@
(
b =
- 0
+ false
|
b =
- 1
+ true
)

View File

@ -0,0 +1,29 @@
@@
bool t;
@@
(
- t == true
+ t
|
- true == t
+ t
|
- t != true
+ !t
|
- true != t
+ !t
|
- t == false
+ !t
|
- false == t
+ !t
|
- t != false
+ t
|
- false != t
+ t
)

View File

@ -0,0 +1,21 @@
@@
identifier fn;
typedef bool;
symbol false;
symbol true;
@@
bool fn ( ... )
{
<...
return
(
- 0
+ false
|
- 1
+ true
)
;
...>
}

View File

@ -0,0 +1,19 @@
@@
identifier fn;
typedef bool;
symbol false;
symbol true;
@@
- int
+ bool
fn (...)
{
?...
return
(
true
|
false
);
}

View File

@ -953,7 +953,7 @@ static int vrrp_recv_advertisement(struct vrrp_router *r, struct ipaddr *src,
thread_add_timer_msec( thread_add_timer_msec(
master, vrrp_master_down_timer_expire, r, master, vrrp_master_down_timer_expire, r,
r->skew_time * CS2MS, &r->t_master_down_timer); r->skew_time * CS2MS, &r->t_master_down_timer);
} else if (r->vr->preempt_mode == false } else if (!r->vr->preempt_mode
|| pkt->hdr.priority >= r->priority) { || pkt->hdr.priority >= r->priority) {
if (r->vr->version == 3) { if (r->vr->version == 3) {
r->master_adver_interval = r->master_adver_interval =
@ -965,7 +965,7 @@ static int vrrp_recv_advertisement(struct vrrp_router *r, struct ipaddr *src,
vrrp_master_down_timer_expire, r, vrrp_master_down_timer_expire, r,
r->master_down_interval * CS2MS, r->master_down_interval * CS2MS,
&r->t_master_down_timer); &r->t_master_down_timer);
} else if (r->vr->preempt_mode == true } else if (r->vr->preempt_mode
&& pkt->hdr.priority < r->priority) { && pkt->hdr.priority < r->priority) {
/* Discard advertisement */ /* Discard advertisement */
DEBUGD(&vrrp_dbg_proto, DEBUGD(&vrrp_dbg_proto,
@ -1834,7 +1834,7 @@ static int vrrp_autoconfig_if_add(struct interface *ifp)
created = true; created = true;
} }
if (!vr || vr->autoconf == false) if (!vr || !vr->autoconf)
return 0; return 0;
if (!created) { if (!created) {
@ -2347,11 +2347,11 @@ static bool vrrp_hash_cmp(const void *arg1, const void *arg2)
const struct vrrp_vrouter *vr2 = arg2; const struct vrrp_vrouter *vr2 = arg2;
if (vr1->ifp != vr2->ifp) if (vr1->ifp != vr2->ifp)
return 0; return false;
if (vr1->vrid != vr2->vrid) if (vr1->vrid != vr2->vrid)
return 0; return false;
return 1; return true;
} }
void vrrp_init(void) void vrrp_init(void)

View File

@ -605,7 +605,7 @@ int32_t zebra_mlag_test_mlag_internal(const char *none, const char *primary,
zsend_capabilities_all_clients(); zsend_capabilities_all_clients();
if (zrouter.mlag_info.role != MLAG_ROLE_NONE) { if (zrouter.mlag_info.role != MLAG_ROLE_NONE) {
if (zrouter.mlag_info.clients_interested_cnt == 0 if (zrouter.mlag_info.clients_interested_cnt == 0
&& test_mlag_in_progress == false) { && !test_mlag_in_progress) {
if (zrouter.mlag_info.zebra_pth_mlag == NULL) if (zrouter.mlag_info.zebra_pth_mlag == NULL)
zebra_mlag_spawn_pthread(); zebra_mlag_spawn_pthread();
zrouter.mlag_info.clients_interested_cnt++; zrouter.mlag_info.clients_interested_cnt++;
@ -613,7 +613,7 @@ int32_t zebra_mlag_test_mlag_internal(const char *none, const char *primary,
hook_call(zebra_mlag_private_open_channel); hook_call(zebra_mlag_private_open_channel);
} }
} else { } else {
if (test_mlag_in_progress == true) { if (test_mlag_in_progress) {
test_mlag_in_progress = false; test_mlag_in_progress = false;
zrouter.mlag_info.clients_interested_cnt--; zrouter.mlag_info.clients_interested_cnt--;
hook_call(zebra_mlag_private_close_channel); hook_call(zebra_mlag_private_close_channel);
@ -790,7 +790,7 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type)
vrf_name_len); vrf_name_len);
} }
} }
if (cleanup == false) { if (!cleanup) {
Bulk_msg.mroute_add = pay_load; Bulk_msg.mroute_add = pay_load;
len = zebra_mlag_mroute_add_bulk__pack(&Bulk_msg, len = zebra_mlag_mroute_add_bulk__pack(&Bulk_msg,
tmp_buf); tmp_buf);
@ -804,7 +804,7 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type)
XFREE(MTYPE_MLAG_PBUF, pay_load[i]); XFREE(MTYPE_MLAG_PBUF, pay_load[i]);
} }
XFREE(MTYPE_MLAG_PBUF, pay_load); XFREE(MTYPE_MLAG_PBUF, pay_load);
if (cleanup == true) if (cleanup)
return -1; return -1;
} break; } break;
case MLAG_MROUTE_DEL_BULK: { case MLAG_MROUTE_DEL_BULK: {