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);
if (shutdown == false) {
if (!shutdown) {
if (!BFD_CHECK_FLAG(bs->flags, BFD_SESS_FLAG_SHUTDOWN))
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);
if (echo == false) {
if (!echo) {
if (!BFD_CHECK_FLAG(bs->flags, BFD_SESS_FLAG_ECHO))
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;
if (use_json == false) {
if (!use_json) {
bvt.vty = vty;
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 bgp_path_info *old_pi, *nextpi;
bool set_flag = 0;
bool set_flag = false;
struct bgp *bgp = NULL;
struct bgp_table *table = NULL;
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)
&& (old_pi->sub_type == BGP_ROUTE_NORMAL)) {
set_flag = 1;
set_flag = true;
} else {
/* If the peer is graceful restart capable and peer is
* 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)
&& (old_pi
&& old_pi->sub_type == BGP_ROUTE_NORMAL)) {
set_flag = 1;
set_flag = true;
}
}
if (set_flag)

View File

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

View File

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

View File

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

View File

@ -58,7 +58,7 @@ static const char *execname = NULL;
void frrmod_init(struct frrmod_runtime *modinfo)
{
modinfo->finished_loading = 1;
modinfo->finished_loading = true;
*frrmod_last = modinfo;
frrmod_last = &modinfo->next;
@ -134,7 +134,7 @@ struct frrmod_runtime *frrmod_load(const char *spec, const char *dir, char *err,
goto out_fail;
}
rtinfo->finished_loading = 1;
rtinfo->finished_loading = true;
*frrmod_last = rtinfo;
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
* successfully.
*/
if (event == NB_EV_ABORT && change->prepare_ok == false)
if (event == NB_EV_ABORT && !change->prepare_ok)
break;
/* 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.tail == NULL);
master->seqnum = 1;
master->seqnum = true;
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) {
if (skip_match_clause == false) {
if (!skip_match_clause) {
/* Apply this index. */
match_ret = route_map_apply_match(&index->match_list,
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);
if (!(cur & SEQLOCK_HELD))
return 1;
return true;
cur = SEQLOCK_VAL(cur) - val - 1;
assert(cur < 0x40000000 || cur > 0xc0000000);
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,
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);
pmi->pbrm = NULL;

View File

@ -255,7 +255,7 @@ bool pim_nexthop_match(struct pim_instance *pim, struct in_addr addr,
int num_ifindex;
if (addr.s_addr == INADDR_NONE)
return 0;
return false;
memset(nexthop_tab, 0,
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(
"%s %s: could not find nexthop ifindex for address %s",
__FILE__, __PRETTY_FUNCTION__, addr_str);
return 0;
return false;
}
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
== ip_src.s_addr)
return 1;
return true;
i++;
}
return 0;
return false;
}
/* 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);
if (!pnc || !pnc->nexthop_num)
return 0;
return false;
for (nh_node = pnc->nexthop; nh_node; nh_node = nh_node->next) {
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)
return 1;
return true;
}
return 0;
return false;
}
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 ) )
* }
*/
int pim_upstream_evaluate_join_desired(struct pim_instance *pim,
bool pim_upstream_evaluate_join_desired(struct pim_instance *pim,
struct pim_upstream *up)
{
bool empty_imm_oil;

View File

@ -303,8 +303,8 @@ struct pim_upstream *pim_upstream_del(struct pim_instance *pim,
struct pim_upstream *up,
const char *name);
int pim_upstream_evaluate_join_desired(struct pim_instance *pim,
struct pim_upstream *up);
bool pim_upstream_evaluate_join_desired(struct pim_instance *pim,
struct pim_upstream *up);
int pim_upstream_evaluate_join_desired_interface(struct pim_upstream *up,
struct pim_ifchannel *ch,
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(
master, vrrp_master_down_timer_expire, r,
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) {
if (r->vr->version == 3) {
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,
r->master_down_interval * CS2MS,
&r->t_master_down_timer);
} else if (r->vr->preempt_mode == true
} else if (r->vr->preempt_mode
&& pkt->hdr.priority < r->priority) {
/* Discard advertisement */
DEBUGD(&vrrp_dbg_proto,
@ -1834,7 +1834,7 @@ static int vrrp_autoconfig_if_add(struct interface *ifp)
created = true;
}
if (!vr || vr->autoconf == false)
if (!vr || !vr->autoconf)
return 0;
if (!created) {
@ -2347,11 +2347,11 @@ static bool vrrp_hash_cmp(const void *arg1, const void *arg2)
const struct vrrp_vrouter *vr2 = arg2;
if (vr1->ifp != vr2->ifp)
return 0;
return false;
if (vr1->vrid != vr2->vrid)
return 0;
return false;
return 1;
return true;
}
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();
if (zrouter.mlag_info.role != MLAG_ROLE_NONE) {
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)
zebra_mlag_spawn_pthread();
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);
}
} else {
if (test_mlag_in_progress == true) {
if (test_mlag_in_progress) {
test_mlag_in_progress = false;
zrouter.mlag_info.clients_interested_cnt--;
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);
}
}
if (cleanup == false) {
if (!cleanup) {
Bulk_msg.mroute_add = pay_load;
len = zebra_mlag_mroute_add_bulk__pack(&Bulk_msg,
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);
if (cleanup == true)
if (cleanup)
return -1;
} break;
case MLAG_MROUTE_DEL_BULK: {