Dont treat bools as a magic number and simplify negated tests where possible

This commit is contained in:
Hamish Coleman 2023-09-06 13:34:41 +01:00
parent 1a598fa43b
commit beb14c8d70
4 changed files with 5 additions and 5 deletions

View File

@ -607,7 +607,7 @@ void readFromMgmtSocket (n2n_edge_t *eee) {
msg_len += snprintf((char *) (udp_buf + msg_len), (N2N_PKT_BUF_SIZE - msg_len),
"%-19s %1s%1s | %-17s | %-21s | %-15s | %9s | %10s\n",
peer->version,
(peer->purgeable == false) ? "l" : "",
(peer->purgeable) ? "" : "l",
(peer == eee->curr_sn) ? (eee->sn_wait ? "." : "*" ) : "",
is_null_mac(peer->mac_addr) ? "" : macaddr_str(mac_buf, peer->mac_addr),
sock_to_cstr(sockbuf, &(peer->sock)),

View File

@ -688,7 +688,7 @@ size_t clear_peer_list (struct peer_info ** peer_list) {
size_t retval = 0;
HASH_ITER(hh, *peer_list, scan, tmp) {
if (scan->purgeable == false && scan->ip_addr) {
if (!scan->purgeable && scan->ip_addr) {
free(scan->ip_addr);
}
HASH_DEL(*peer_list, scan);

View File

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

View File

@ -1483,7 +1483,7 @@ static int purge_expired_communities (n2n_sn_t *sss,
}
}
if((comm->edges == NULL) && (comm->purgeable == true)) {
if((comm->edges == NULL) && (comm->purgeable)) {
traceEvent(TRACE_INFO, "purging idle community %s", comm->community);
if(NULL != comm->header_encryption_ctx_static) {
/* this should not happen as 'purgeable' and thus only communities w/o encrypted header here */