]> git.puffer.fish Git - matthieu/frr.git/commitdiff
*: fix coverity warnings - error handling issues
authorRenato Westphal <renato@opensourcerouting.org>
Mon, 23 Oct 2017 21:19:26 +0000 (19:19 -0200)
committerRenato Westphal <renato@opensourcerouting.org>
Tue, 24 Oct 2017 21:30:30 +0000 (19:30 -0200)
Ignore the return value of some functions in the places we know they
can't fail, and other small fixes.

Regarding the change in bgpd/rfapi/rfapi_rib.c, asserting that
rfapiRaddr2Qprefix() didn't fail is the common idiom inside the rfapi
code.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
bgpd/bgp_evpn.c
bgpd/bgp_route.c
bgpd/bgp_updgrp_adv.c
bgpd/bgp_updgrp_packet.c
bgpd/rfapi/rfapi_rib.c
eigrpd/eigrp_vty.c
vtysh/vtysh_main.c

index a09d966d7b0086f8f925060dee45450f8e8d608a..182a6c64f2b3aad2a4c7dfef627959b4b77fd0d9 100644 (file)
@@ -2542,7 +2542,7 @@ void bgp_evpn_derive_auto_rd(struct bgp *bgp, struct bgpevpn *vpn)
        vpn->prd.family = AF_UNSPEC;
        vpn->prd.prefixlen = 64;
        sprintf(buf, "%s:%hu", inet_ntoa(bgp->router_id), vpn->rd_id);
-       str2prefix_rd(buf, &vpn->prd);
+       (void)str2prefix_rd(buf, &vpn->prd);
        UNSET_FLAG(vpn->flags, VNI_FLAG_RD_CFGD);
 }
 
index 0c2a2f6fe9976203bb808ee874256244faeec3ad..af71088b7deba3346e24fd5a366bc4d99ea1036d 100644 (file)
@@ -10545,7 +10545,7 @@ DEFUN (show_bgp_afi_vpn_rd_route,
        afi_t afi = AFI_MAX;
        int idx = 0;
 
-       argv_find_and_parse_afi(argv, argc, &idx, &afi);
+       (void)argv_find_and_parse_afi(argv, argc, &idx, &afi);
        ret = str2prefix_rd(argv[5]->arg, &prd);
        if (!ret) {
                vty_out(vty, "%% Malformed Route Distinguisher\n");
index fbbeaee9b252ff24eee1d3cbb71cdf697ab2afd8..8a24cba5980394373ddf9499693f214bce315310 100644 (file)
@@ -687,11 +687,11 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
 
        attr.local_pref = bgp->default_local_pref;
 
-       if (afi == AFI_IP)
-               str2prefix("0.0.0.0/0", &p);
-       else if (afi == AFI_IP6) {
-               str2prefix("::/0", &p);
+       memset(&p, 0, sizeof(p));
+       p.family = afi2family(afi);
+       p.prefixlen = 0;
 
+       if (afi == AFI_IP6) {
                /* IPv6 global nexthop must be included. */
                attr.mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL;
 
@@ -759,10 +759,9 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
                         * clear adj_out for the 0.0.0.0/0 prefix in the BGP
                         * table.
                         */
-                       if (afi == AFI_IP)
-                               str2prefix("0.0.0.0/0", &p);
-                       else
-                               str2prefix("::/0", &p);
+                       memset(&p, 0, sizeof(p));
+                       p.family = afi2family(afi);
+                       p.prefixlen = 0;
 
                        rn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi,
                                              &p, NULL);
index 433c5ce512d9eee07c985d0e4dd5e8e20e6d8be0..a35d814e477cc8c00f4473135aefcdecf61a57f6 100644 (file)
@@ -1090,10 +1090,9 @@ void subgroup_default_update_packet(struct update_subgroup *subgrp,
        bpacket_attr_vec_arr_reset(&vecarr);
        addpath_encode = bgp_addpath_encode_tx(peer, afi, safi);
 
-       if (afi == AFI_IP)
-               str2prefix("0.0.0.0/0", &p);
-       else
-               str2prefix("::/0", &p);
+       memset(&p, 0, sizeof(p));
+       p.family = afi2family(afi);
+       p.prefixlen = 0;
 
        /* Logging the attribute. */
        if (bgp_debug_update(NULL, &p, subgrp->update_group, 0)) {
@@ -1176,10 +1175,9 @@ void subgroup_default_withdraw_packet(struct update_subgroup *subgrp)
        safi = SUBGRP_SAFI(subgrp);
        addpath_encode = bgp_addpath_encode_tx(peer, afi, safi);
 
-       if (afi == AFI_IP)
-               str2prefix("0.0.0.0/0", &p);
-       else
-               str2prefix("::/0", &p);
+       memset(&p, 0, sizeof(p));
+       p.family = afi2family(afi);
+       p.prefixlen = 0;
 
        if (bgp_debug_update(NULL, &p, subgrp->update_group, 0)) {
                char buf[PREFIX_STRLEN];
index 92cd1888ee267dee5b8c83da586cd4a8f5680fb4..36ae6e7273776644e6738bd5a7bdcb75513a981a 100644 (file)
@@ -1668,7 +1668,7 @@ void rfapiRibUpdatePendingNode(
 
                        struct prefix pfx_vn;
 
-                       rfapiRaddr2Qprefix(&rfd->vn_addr, &pfx_vn);
+                       assert(!rfapiRaddr2Qprefix(&rfd->vn_addr, &pfx_vn));
                        if (prefix_same(&pfx_vn, &pfx_nh))
                                continue;
                }
index 5fc78181668ffab168c13a18c5d5eff8e98fdfce..4e7642853574474c0f4e41651a2a7fe47bad02bd 100644 (file)
@@ -398,7 +398,7 @@ DEFUN (eigrp_network,
        struct prefix p;
        int ret;
 
-       str2prefix(argv[1]->arg, &p);
+       (void)str2prefix(argv[1]->arg, &p);
 
        ret = eigrp_network_set(eigrp, &p);
 
@@ -421,7 +421,7 @@ DEFUN (no_eigrp_network,
        struct prefix p;
        int ret;
 
-       str2prefix(argv[2]->arg, &p);
+       (void)str2prefix(argv[2]->arg, &p);
 
        ret = eigrp_network_unset(eigrp, &p);
 
index 8509a8a05ab06ef67bf0d97c9a691211e2882bb5..57042f8e620949a788f2ec65ccbe446d9861bcc4 100644 (file)
@@ -533,7 +533,7 @@ int main(int argc, char **argv, char **env)
 
                        fp = open(history_file, O_CREAT | O_EXCL,
                                  S_IRUSR | S_IWUSR);
-                       if (fp)
+                       if (fp != -1)
                                close(fp);
 
                        read_history(history_file);