Message ID | 20210326183024.3214527-1-blp@ovn.org |
---|---|
State | Accepted |
Headers | show |
Series | [ovs-dev,1/3] ovs-lldp: Get rid of pointless null pointer check. | expand |
On 3/26/21 7:30 PM, Ben Pfaff wrote: > lldpd_alloc_hardware() always returns nonnull. > > At the same time, there's no reason that lldpd_alloc_hardware() doesn't > take a const char *, so change that. > > Signed-off-by: Ben Pfaff <blp@ovn.org> LGTM, Acked-by: Ilya Maximets <i.maximets@ovn.org>
On Wed, Apr 07, 2021 at 12:58:21PM +0200, Ilya Maximets wrote: > On 3/26/21 7:30 PM, Ben Pfaff wrote: > > lldpd_alloc_hardware() always returns nonnull. > > > > At the same time, there's no reason that lldpd_alloc_hardware() doesn't > > take a const char *, so change that. > > > > Signed-off-by: Ben Pfaff <blp@ovn.org> > > LGTM, > Acked-by: Ilya Maximets <i.maximets@ovn.org> Thanks, applied to master.
diff --git a/lib/lldp/lldpd.c b/lib/lldp/lldpd.c index 34738535dbd1..a024dc5e5835 100644 --- a/lib/lldp/lldpd.c +++ b/lib/lldp/lldpd.c @@ -77,7 +77,7 @@ lldpd_get_hardware(struct lldpd *cfg, char *name, int index, } struct lldpd_hardware * -lldpd_alloc_hardware(struct lldpd *cfg, char *name, int index) +lldpd_alloc_hardware(struct lldpd *cfg, const char *name, int index) { struct lldpd_hardware *hw; diff --git a/lib/lldp/lldpd.h b/lib/lldp/lldpd.h index 5267c112af5e..3f5be84a205e 100644 --- a/lib/lldp/lldpd.h +++ b/lib/lldp/lldpd.h @@ -76,7 +76,7 @@ lldpd_first_hardware(struct lldpd *lldpd) /* lldpd.c */ struct lldpd_hardware *lldpd_get_hardware(struct lldpd *, char *, int, struct lldpd_ops *); -struct lldpd_hardware *lldpd_alloc_hardware(struct lldpd *, char *, int); +struct lldpd_hardware *lldpd_alloc_hardware(struct lldpd *, const char *, int); void lldpd_hardware_cleanup(struct lldpd*, struct lldpd_hardware *); struct lldpd_mgmt *lldpd_alloc_mgmt(int family, void *addr, size_t addrsize, u_int32_t iface); diff --git a/lib/ovs-lldp.c b/lib/ovs-lldp.c index 05c1dd4344be..162311fa45c3 100644 --- a/lib/ovs-lldp.c +++ b/lib/ovs-lldp.c @@ -801,13 +801,7 @@ lldp_create(const struct netdev *netdev, ovs_list_init(&lldp->lldpd->g_chassis); ovs_list_push_back(&lldp->lldpd->g_chassis, &lchassis->list); - if ((hw = lldpd_alloc_hardware(lldp->lldpd, - (char *) netdev_get_name(netdev), - 0)) == NULL) { - VLOG_WARN("Unable to allocate space for %s", - (char *) netdev_get_name(netdev)); - out_of_memory(); - } + hw = lldpd_alloc_hardware(lldp->lldpd, netdev_get_name(netdev), 0); ovs_refcount_init(&lldp->ref_cnt); #ifndef _WIN32
lldpd_alloc_hardware() always returns nonnull. At the same time, there's no reason that lldpd_alloc_hardware() doesn't take a const char *, so change that. Signed-off-by: Ben Pfaff <blp@ovn.org> --- lib/lldp/lldpd.c | 2 +- lib/lldp/lldpd.h | 2 +- lib/ovs-lldp.c | 8 +------- 3 files changed, 3 insertions(+), 9 deletions(-)