From patchwork Fri Mar 26 18:30:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 1458919 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4F6VsF1LZGz9sCD for ; Sat, 27 Mar 2021 05:30:40 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id CB4A24187E; Fri, 26 Mar 2021 18:30:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cQWtLxHy_s41; Fri, 26 Mar 2021 18:30:37 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTP id D7F7F404FE; Fri, 26 Mar 2021 18:30:36 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 983B1C000B; Fri, 26 Mar 2021 18:30:36 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id D0B56C000A for ; Fri, 26 Mar 2021 18:30:34 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id B1D6160D71 for ; Fri, 26 Mar 2021 18:30:34 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wYmYSgeLsyxm for ; Fri, 26 Mar 2021 18:30:34 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from relay12.mail.gandi.net (relay12.mail.gandi.net [217.70.178.232]) by smtp3.osuosl.org (Postfix) with ESMTPS id B2B47605E7 for ; Fri, 26 Mar 2021 18:30:33 +0000 (UTC) Received: from sigfpe.attlocal.net (75-54-222-30.lightspeed.rdcyca.sbcglobal.net [75.54.222.30]) (Authenticated sender: blp@ovn.org) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 3A1B4200005; Fri, 26 Mar 2021 18:30:29 +0000 (UTC) From: Ben Pfaff To: dev@openvswitch.org Date: Fri, 26 Mar 2021 11:30:22 -0700 Message-Id: <20210326183024.3214527-1-blp@ovn.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 1/3] ovs-lldp: Get rid of pointless null pointer check. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" 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 Acked-by: Ilya Maximets --- lib/lldp/lldpd.c | 2 +- lib/lldp/lldpd.h | 2 +- lib/ovs-lldp.c | 8 +------- 3 files changed, 3 insertions(+), 9 deletions(-) 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