diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2022-02-25 12:56:13 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2022-02-25 12:56:13 +0000 |
commit | 922a42aee45ee33973e6533e8f6b73fd0e248b51 (patch) | |
tree | 2f548f72f03a8b192167039e9b74dfafafd86cdc | |
parent | b314ba1923285a39e180318c5a6fac040f99e214 (diff) |
The pointer returned by pt_fill() can be directly used in most cases.
There is no need for an extra local variable.
Noticed by and OK tb@
-rw-r--r-- | usr.sbin/bgpd/rde_prefix.c | 5 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_rib.c | 14 |
2 files changed, 6 insertions, 13 deletions
diff --git a/usr.sbin/bgpd/rde_prefix.c b/usr.sbin/bgpd/rde_prefix.c index 2883d6bcfbc..6e0805dda7d 100644 --- a/usr.sbin/bgpd/rde_prefix.c +++ b/usr.sbin/bgpd/rde_prefix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_prefix.c,v 1.40 2021/01/18 12:15:36 claudio Exp $ */ +/* $OpenBSD: rde_prefix.c,v 1.41 2022/02/25 12:56:12 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> @@ -171,8 +171,7 @@ pt_add(struct bgpd_addr *prefix, int prefixlen) { struct pt_entry *p = NULL; - p = pt_fill(prefix, prefixlen); - p = pt_alloc(p); + p = pt_alloc(pt_fill(prefix, prefixlen)); if (RB_INSERT(pt_tree, &pttable, p) != NULL) fatalx("pt_add: insert failed"); diff --git a/usr.sbin/bgpd/rde_rib.c b/usr.sbin/bgpd/rde_rib.c index 837aef479c8..5774da25cb9 100644 --- a/usr.sbin/bgpd/rde_rib.c +++ b/usr.sbin/bgpd/rde_rib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_rib.c,v 1.226 2022/02/25 11:36:54 claudio Exp $ */ +/* $OpenBSD: rde_rib.c,v 1.227 2022/02/25 12:56:12 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> @@ -297,11 +297,9 @@ struct rib_entry * rib_get(struct rib *rib, struct bgpd_addr *prefix, int prefixlen) { struct rib_entry xre, *re; - struct pt_entry *pte; - pte = pt_fill(prefix, prefixlen); memset(&xre, 0, sizeof(xre)); - xre.prefix = pte; + xre.prefix = pt_fill(prefix, prefixlen); re = RB_FIND(rib_tree, rib_tree(rib), &xre); if (re && re->rib_id != rib->id) @@ -921,11 +919,9 @@ prefix_adjout_get(struct rde_peer *peer, uint32_t path_id, struct bgpd_addr *prefix, int prefixlen) { struct prefix xp; - struct pt_entry *pte; memset(&xp, 0, sizeof(xp)); - pte = pt_fill(prefix, prefixlen); - xp.pt = pte; + xp.pt = pt_fill(prefix, prefixlen); xp.path_id_tx = path_id; return RB_FIND(prefix_index, &peer->adj_rib_out, &xp); @@ -940,11 +936,9 @@ prefix_adjout_lookup(struct rde_peer *peer, struct bgpd_addr *prefix, int prefixlen) { struct prefix xp, *np; - struct pt_entry *pte; memset(&xp, 0, sizeof(xp)); - pte = pt_fill(prefix, prefixlen); - xp.pt = pte; + xp.pt = pt_fill(prefix, prefixlen); np = RB_NFIND(prefix_index, &peer->adj_rib_out, &xp); if (np != NULL && pt_prefix_cmp(np->pt, xp.pt) != 0) |