From 822e4ae5ca6c11cca692bf8f2a084622006bda52 Mon Sep 17 00:00:00 2001 From: claudio Date: Fri, 25 Feb 2022 12:56:12 +0000 Subject: [PATCH] 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@ --- usr.sbin/bgpd/rde_prefix.c | 5 ++--- 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 @@ -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 @@ -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) -- 2.20.1