]> git.puffer.fish Git - mirror/frr.git/commitdiff
*: use proper bool initializers & fix comparisons
authorQuentin Young <qlyoung@cumulusnetworks.com>
Mon, 25 Feb 2019 18:51:33 +0000 (18:51 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Mon, 25 Feb 2019 23:00:16 +0000 (23:00 +0000)
- bools should be initialized with true/false
- bools do not need to be compared

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
bfdd/bfd_packet.c
bfdd/bfdd_vty.c
bgpd/bgp_lcommunity.c
bgpd/bgp_pbr.c
bgpd/bgpd.c
isisd/isis_pdu.c
lib/command_graph.c
lib/libfrr.c
lib/northbound_confd.c
lib/yang_wrappers.c
pbrd/pbr_nht.c

index 45c5f5dbdc415a1143d900ad5f5a15d0dd94e364..8601bd2e4090ef32f79375b3e39b510364da8d53 100644 (file)
@@ -544,7 +544,7 @@ int bfd_recv_cb(struct thread *t)
        }
 
        /* Validate packet TTL. */
-       if ((is_mhop == false) && (ttl != BFD_TTL_VAL)) {
+       if ((!is_mhop) && (ttl != BFD_TTL_VAL)) {
                cp_debug(is_mhop, &peer, &local, ifindex, vrfid,
                         "invalid TTL: %d expected %d", ttl, BFD_TTL_VAL);
                return 0;
index 0041f9cc2e968ea4b1df4fb4a1d41f4c74e2c814..c77cd08be8033d514ffdcc43fbd52c173c8a0f36 100644 (file)
@@ -564,7 +564,7 @@ static void _display_all_peers(struct vty *vty, bool use_json)
 {
        struct json_object *jo;
 
-       if (use_json == false) {
+       if (!use_json) {
                vty_out(vty, "BFD Peers:\n");
                bfd_id_iterate(_display_peer_iter, vty);
                return;
@@ -647,7 +647,7 @@ static void _display_peers_counter(struct vty *vty, bool use_json)
 {
        struct json_object *jo;
 
-       if (use_json == false) {
+       if (!use_json) {
                vty_out(vty, "BFD Peers:\n");
                bfd_id_iterate(_display_peer_counter_iter, vty);
                return;
index cfc9af7777e81a0827bb606c1e12c571849733b7..06281e16c62bed0abe20b4d5a907412f33cd7e45 100644 (file)
@@ -180,7 +180,7 @@ static void set_lcommunity_string(struct lcommunity *lcom, bool make_json)
 {
        int i;
        int len;
-       bool first = 1;
+       bool first = true;
        char *str_buf;
        char *str_pnt;
        uint8_t *pnt;
@@ -218,7 +218,7 @@ static void set_lcommunity_string(struct lcommunity *lcom, bool make_json)
 
        for (i = 0; i < lcom->size; i++) {
                if (first)
-                       first = 0;
+                       first = false;
                else
                        *str_pnt++ = ' ';
 
index 4c51db8e143d28fc308a9b4a35198a71c4868880..c0be36ed3f4ad3b9b7d8483bc275dc2ed1cfacbf 100644 (file)
@@ -333,7 +333,7 @@ static bool bgp_pbr_extract_enumerate_unary(struct bgp_pbr_match_val list[],
                                                 unary_operator, and_valmask,
                                                 or_valmask, list[i].value,
                                                 type_entry);
-                               if (ret == false)
+                               if (!ret)
                                        return ret;
                                continue;
                        }
@@ -441,7 +441,7 @@ static bool bgp_pbr_extract(struct bgp_pbr_match_val list[],
                                range->min_port = list[i].value;
                        exact_match = true;
                }
-               if (exact_match == true && i > 0)
+               if (exact_match && i > 0)
                        return false;
                if (list[i].compare_operator ==
                    (OPERATOR_COMPARE_GREATER_THAN +
@@ -545,7 +545,7 @@ static int bgp_pbr_validate_policy_route(struct bgp_pbr_entry_main *api)
                                           "too complex. ignoring.");
                        return 0;
                } else if (api->match_icmp_type_num > 1 &&
-                          enumerate_icmp == false) {
+                          !enumerate_icmp) {
                        if (BGP_DEBUG(pbr, PBR))
                                zlog_debug("BGP: match icmp code is enumerate"
                                           ", and icmp type is not."
index 6091ddcdfa299a5762804705591e43e74e853884..d69b7fcc09d0fc9f103118c53178ddd9207e7086 100644 (file)
@@ -116,7 +116,7 @@ static int bgp_check_main_socket(bool create, struct bgp *bgp)
 {
        static int bgp_server_main_created;
 
-       if (create == true) {
+       if (create) {
                if (bgp_server_main_created)
                        return 0;
                if (bgp_socket(bgp, bm->port, bm->address) < 0)
index 330da9b216b62a5c760200dacf64f6bb0b3adf57..af35ed2e3c7e203b353061a887a088ce8d32bb06 100644 (file)
@@ -2146,11 +2146,11 @@ int send_csnp(struct isis_circuit *circuit, int level)
                 * stop lsp_id in this current CSNP.
                 */
                memcpy(start, stop, ISIS_SYS_ID_LEN + 2);
-               loop = 0;
+               loop = false;
                for (int i = ISIS_SYS_ID_LEN + 1; i >= 0; --i) {
                        if (start[i] < (uint8_t)0xff) {
                                start[i] += 1;
-                               loop = 1;
+                               loop = true;
                                break;
                        }
                }
index 0e8669c4b5aed451718f7e47a7bd5eeba0b08003..4757fd951f665d890de648cef60546d5dbdb47fc 100644 (file)
@@ -471,7 +471,7 @@ void cmd_graph_node_print_cb(struct graph_node *gn, struct buffer *buf)
        struct cmd_token *tok = gn->data;
        const char *color;
 
-       if (wasend == true) {
+       if (wasend) {
                wasend = false;
                return;
        }
index 9119b04992aabb62f5c96121686c6576da61d212..1afe30d618486594fe454f1d8816bdb3e7ca2a0f 100644 (file)
@@ -61,7 +61,7 @@ static char dbfile_default[512];
 #endif
 static char vtypath_default[256];
 
-bool debug_memstats_at_exit = 0;
+bool debug_memstats_at_exit = false;
 static bool nodetach_term, nodetach_daemon;
 
 static char comb_optstr[256];
index a8e00178194c16bff91f0318e20929e35973bc1c..a499d48c12ad4889ada85ed352c5df0425e0a205 100644 (file)
@@ -1383,7 +1383,7 @@ error:
 
 static int frr_confd_finish(void)
 {
-       if (confd_connected == false)
+       if (!confd_connected)
                return 0;
 
        frr_confd_finish_cdb();
index 6273dff3ce8e83cf929e77336b71599b0fb11feb..7ecea5f445469bbbb736b19e62c1f510ba1e31bf 100644 (file)
@@ -62,7 +62,7 @@ bool yang_str2bool(const char *value)
 
 struct yang_data *yang_data_new_bool(const char *xpath, bool value)
 {
-       return yang_data_new(xpath, (value == true) ? "true" : "false");
+       return yang_data_new(xpath, (value) ? "true" : "false");
 }
 
 bool yang_dnode_get_bool(const struct lyd_node *dnode, const char *xpath_fmt,
index 2cba657f65e1b7a8e6a92c4a42a4177b0f5b40d6..6a025fd72482a3cf9544ab259f2f48c0e82b959d 100644 (file)
@@ -740,7 +740,7 @@ uint32_t pbr_nht_get_next_tableid(bool peek)
        bool found = false;
 
        for (i = pbr_nhg_low_table; i <= pbr_nhg_high_table; i++) {
-               if (nhg_tableid[i] == false) {
+               if (!nhg_tableid[i]) {
                        found = true;
                        break;
                }