Skip to content

Commit beb14c8

Browse files
committed
Dont treat bools as a magic number and simplify negated tests where possible
1 parent 1a598fa commit beb14c8

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

src/edge_management.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ void readFromMgmtSocket (n2n_edge_t *eee) {
607607
msg_len += snprintf((char *) (udp_buf + msg_len), (N2N_PKT_BUF_SIZE - msg_len),
608608
"%-19s %1s%1s | %-17s | %-21s | %-15s | %9s | %10s\n",
609609
peer->version,
610-
(peer->purgeable == false) ? "l" : "",
610+
(peer->purgeable) ? "" : "l",
611611
(peer == eee->curr_sn) ? (eee->sn_wait ? "." : "*" ) : "",
612612
is_null_mac(peer->mac_addr) ? "" : macaddr_str(mac_buf, peer->mac_addr),
613613
sock_to_cstr(sockbuf, &(peer->sock)),

src/n2n.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ size_t clear_peer_list (struct peer_info ** peer_list) {
688688
size_t retval = 0;
689689

690690
HASH_ITER(hh, *peer_list, scan, tmp) {
691-
if (scan->purgeable == false && scan->ip_addr) {
691+
if (!scan->purgeable && scan->ip_addr) {
692692
free(scan->ip_addr);
693693
}
694694
HASH_DEL(*peer_list, scan);

src/sn_management.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ int process_mgmt (n2n_sn_t *sss,
371371

372372
ressize += snprintf(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize,
373373
"%s '%s'\n",
374-
(community->is_federation) ? "FEDERATION" : ((community->purgeable == false) ? "FIXED NAME COMMUNITY" : "COMMUNITY"),
374+
(community->is_federation) ? "FEDERATION" : ((community->purgeable) ? "COMMUNITY" : "FIXED NAME COMMUNITY"),
375375
(community->is_federation) ? "-/-" : community->community);
376376
sendto_mgmt(sss, sender_sock, sock_size, (const uint8_t *) resbuf, ressize);
377377
ressize = 0;
@@ -382,7 +382,7 @@ int process_mgmt (n2n_sn_t *sss,
382382
ressize += snprintf(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize,
383383
"%4u | %-19s | %-17s | %-21s %-3s | %-15s | %9s\n",
384384
++num,
385-
(peer->dev_addr.net_addr == 0) ? ((peer->purgeable == false) ? "-l" : "") : ip_subnet_to_str(ip_bit_str, &peer->dev_addr),
385+
(peer->dev_addr.net_addr == 0) ? ((peer->purgeable) ? "" : "-l") : ip_subnet_to_str(ip_bit_str, &peer->dev_addr),
386386
(is_null_mac(peer->mac_addr)) ? "" : macaddr_str(mac_buf, peer->mac_addr),
387387
sock_to_cstr(sockbuf, &(peer->sock)),
388388
((peer->socket_fd >= 0) && (peer->socket_fd != sss->sock)) ? "TCP" : "",

src/sn_utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1483,7 +1483,7 @@ static int purge_expired_communities (n2n_sn_t *sss,
14831483
}
14841484
}
14851485

1486-
if((comm->edges == NULL) && (comm->purgeable == true)) {
1486+
if((comm->edges == NULL) && (comm->purgeable)) {
14871487
traceEvent(TRACE_INFO, "purging idle community %s", comm->community);
14881488
if(NULL != comm->header_encryption_ctx_static) {
14891489
/* this should not happen as 'purgeable' and thus only communities w/o encrypted header here */

0 commit comments

Comments
 (0)