From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 37313A034E; Wed, 9 Feb 2022 20:21:53 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D6E5A4272C; Wed, 9 Feb 2022 20:18:38 +0100 (CET) Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by mails.dpdk.org (Postfix) with ESMTP id E907A4273A for ; Wed, 9 Feb 2022 20:18:35 +0100 (CET) Received: by mail-pf1-f178.google.com with SMTP id i21so4488704pfd.13 for ; Wed, 09 Feb 2022 11:18:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fldoq/9KezHmsprI9nXVwNL/WLtkf236ENhnQEhfljw=; b=Ena2o+s4uKJeUlKn2GHQpZItiQArI/5BxiHrMfWqZVRIa2bVWOACZpFXhZTFDGTIWy 0RbPBRZbTJzsVPhvNwCPpEuhwUoYoN7kHX+iNsZJ/QKcxyJaK3wImwH4wzhloyKJh7f8 Vp2jZb+wO2zb79keiVzxSy7LNX3Q99lOUa/Dx8HriX2aeIMC0c+DMy6YA3FzGXD1mMpP EAQms20iSusmsX92BbuUsxI8MBcWt7BczHFxCDQKlxCKgik9QzcZs+yg6RXtVae9jwq8 ixjatKiRpPt7R7yM6Ts0FpSEpyf/30WVW+qZSnktQCy7wjvKipQY1/lDTjqstsJZjAOq nrjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fldoq/9KezHmsprI9nXVwNL/WLtkf236ENhnQEhfljw=; b=bqt71YYLVOy3lYV8kEiWK4DV1uDuY/tkTtEwLT1gWcbn6GdAdsuC5yke0y3wlxWo2B KSoI1x0mv2iVD2Dus4AYD6AXOFJVJ0CUxPLp6nsuRMrQIQ/1m7rF8MSrpb0Uj+gbGOYG N12MayLJrmaMpI75SwXA5qo2EVEYdHdW3hc2hdYxkxf1WT41w+BOWD7nEwhz5++m1/MQ TePGIIwQH1yhxVCjrD3wi9doGqZyGsDTOgVfUvZ29mJR8tPJezPdDTY83+SaWI/A4F4k I+SVQp17C/SOG3OXEFWXPpH60KbCvPKtAJOTw/wkIwICXah/m5TqZzpTpZelmCaSolqW olGg== X-Gm-Message-State: AOAM530xmtEsSJGzyg7nBRMtXxmpTHqQc7sSYqjI6+R3vcLOJhMi+Mf/ A4MuCjXZMe8r0dVM6g579NxE8XoqTs+S66jJ+ts= X-Google-Smtp-Source: ABdhPJzXOzdwoeK6MTibEjKg4qq431h1Cj4D65DKtCoq8xJk8h+bJUhVY8Gg16LiKvItwb5IQFOG2Q== X-Received: by 2002:a65:6296:: with SMTP id f22mr3028777pgv.320.1644434314901; Wed, 09 Feb 2022 11:18:34 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id u16sm14378401pgh.54.2022.02.09.11.18.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 11:18:34 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , David Hunt , Jerin Jacob , Kiran Kumar K , Nithin Dabilpuram , Konstantin Ananyev , Bernard Iremonger , Vladimir Medvedkin , Cristian Dumitrescu , Reshma Pattan Subject: [PATCH v3 36/36] other: remove unnecessary NULL checks Date: Wed, 9 Feb 2022 11:17:48 -0800 Message-Id: <20220209191748.377729-37-stephen@networkplumber.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220209191748.377729-1-stephen@networkplumber.org> References: <20220124000518.319850-1-stephen@networkplumber.org> <20220209191748.377729-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Remove redundant NULL pointer checks before free functions found by nullfree.cocci Signed-off-by: Stephen Hemminger Acked-by: David Hunt --- lib/graph/graph_stats.c | 3 +-- lib/ipsec/ipsec_sad.c | 3 +-- lib/port/rte_port_source_sink.c | 21 +++++++-------------- lib/power/rte_power_empty_poll.c | 3 +-- lib/reorder/rte_reorder.c | 6 ++---- 5 files changed, 12 insertions(+), 24 deletions(-) diff --git a/lib/graph/graph_stats.c b/lib/graph/graph_stats.c index aa70929dc32e..65e12d46a313 100644 --- a/lib/graph/graph_stats.c +++ b/lib/graph/graph_stats.c @@ -233,8 +233,7 @@ cluster_add(struct cluster *cluster, struct graph *graph) static void cluster_fini(struct cluster *cluster) { - if (cluster->graphs) - free(cluster->graphs); + free(cluster->graphs); } static int diff --git a/lib/ipsec/ipsec_sad.c b/lib/ipsec/ipsec_sad.c index 531e1e323cdc..af4b1ce757d2 100644 --- a/lib/ipsec/ipsec_sad.c +++ b/lib/ipsec/ipsec_sad.c @@ -440,8 +440,7 @@ rte_ipsec_sad_destroy(struct rte_ipsec_sad *sad) rte_hash_free(sad->hash[RTE_IPSEC_SAD_SPI_DIP]); rte_hash_free(sad->hash[RTE_IPSEC_SAD_SPI_DIP_SIP]); rte_free(sad); - if (te != NULL) - rte_free(te); + rte_free(te); } /* diff --git a/lib/port/rte_port_source_sink.c b/lib/port/rte_port_source_sink.c index 68575c98338d..79042d13ff66 100644 --- a/lib/port/rte_port_source_sink.c +++ b/lib/port/rte_port_source_sink.c @@ -163,14 +163,10 @@ pcap_source_load(struct rte_port_source *port, return 0; error_exit: - if (pkt_len_aligns) - rte_free(pkt_len_aligns); - if (port->pkt_len) - rte_free(port->pkt_len); - if (port->pkts) - rte_free(port->pkts); - if (port->pkt_buff) - rte_free(port->pkt_buff); + rte_free(pkt_len_aligns); + rte_free(port->pkt_len); + rte_free(port->pkts); + rte_free(port->pkt_buff); return -1; } @@ -242,12 +238,9 @@ rte_port_source_free(void *port) if (p == NULL) return 0; - if (p->pkt_len) - rte_free(p->pkt_len); - if (p->pkts) - rte_free(p->pkts); - if (p->pkt_buff) - rte_free(p->pkt_buff); + rte_free(p->pkt_len); + rte_free(p->pkts); + rte_free(p->pkt_buff); rte_free(p); diff --git a/lib/power/rte_power_empty_poll.c b/lib/power/rte_power_empty_poll.c index c4b5de9601cf..2261ce7820f6 100644 --- a/lib/power/rte_power_empty_poll.c +++ b/lib/power/rte_power_empty_poll.c @@ -457,8 +457,7 @@ rte_power_empty_poll_stat_free(void) RTE_LOG(INFO, POWER, "Close the Empty Poll\n"); - if (ep_params != NULL) - rte_free(ep_params); + rte_free(ep_params); } int diff --git a/lib/reorder/rte_reorder.c b/lib/reorder/rte_reorder.c index 9445853b79cc..bc0241bfb3fd 100644 --- a/lib/reorder/rte_reorder.c +++ b/lib/reorder/rte_reorder.c @@ -192,10 +192,8 @@ rte_reorder_free_mbufs(struct rte_reorder_buffer *b) /* Free up the mbufs of order buffer & ready buffer */ for (i = 0; i < b->order_buf.size; i++) { - if (b->order_buf.entries[i]) - rte_pktmbuf_free(b->order_buf.entries[i]); - if (b->ready_buf.entries[i]) - rte_pktmbuf_free(b->ready_buf.entries[i]); + rte_pktmbuf_free(b->order_buf.entries[i]); + rte_pktmbuf_free(b->ready_buf.entries[i]); } } -- 2.34.1