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 7D806A00C2; Sun, 20 Feb 2022 19:22:35 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2BEB741170; Sun, 20 Feb 2022 19:22:04 +0100 (CET) Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by mails.dpdk.org (Postfix) with ESMTP id B2F3441168 for ; Sun, 20 Feb 2022 19:22:01 +0100 (CET) Received: by mail-pg1-f177.google.com with SMTP id 27so7150691pgk.10 for ; Sun, 20 Feb 2022 10:22:01 -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=wiCeMYv7+h2jiWHP785UN56RTEtMBsuqnMSE63mZVu0=; b=czZGQhT/bODICAekyjudC2x8zYsQxA8D+Lk7GrFeELKCqlAy37yqGgMtpagki+wJRG jx6KEjBpllPDFwRpX5naDXuf/paA6uofTbBlGD0W+bUP3KJ2m3Gqcy645Ay0zSUV3LtH y1m5fYtNsaF7qg5ik19UAs9DATIk/GIeZT/qhIErE+94zhNgTmsKZhVLF5Xp7QdQ213Q NFJhetnxVuS6K+RgTG6GDWeonJs0rI2EWw2dmXgCd11SSu7wOLMb6Wa+Gdc4I2TDLWw2 J/6p05vmRopHyiSwE6RUzRSlzyZQEftXPBvQYcBxQgxBXDO0j2bGkJkKK3MOIaiPRMWL QHBg== 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=wiCeMYv7+h2jiWHP785UN56RTEtMBsuqnMSE63mZVu0=; b=oGlTLGJ0psMslvcapRGn6vfIbF7G505XqoLe1+V2CKQi1bO6Plm8RvyAqzH65/alU6 QClT0TARPh1RIB9ytiQfKv5ItKNnzf+fz5JupXhZPHB4vmAVqZBXuS/FlixrXzMA1LM9 qdmZbwO/2lhVBOc0t5HrgQDDzJiWj9oWO65aa46tkxmF72DZZGGfIygI1tkAIY5R72Tj 6KTEzKZUc8Ez9Q22DGl1IrnrJFAe0ZOpiFYX4aXed5k1xSOX5pdk+VLnJsFeL2jM2RtD M+FmGUT8blqSjn7Q+FGFvY+kv1f1YYMp11Tc2AqU4ZdB8kbEsPIr0v35ixHuHarL1HTY EBsA== X-Gm-Message-State: AOAM532527BsNAkoydnCK/7w/J+IpRRURpHyciJNesMn16zh3WFaQvs2 RjwYl2dXOuT0BzDmIZHLw0ZQN3eDuQlgAvnr X-Google-Smtp-Source: ABdhPJwzfe8iyW20ajo/JXDhiVB6X0zBy/snJLXiRNKKx+KlHQ/AMYV/uO2BebfyzttLCrHXgveTPg== X-Received: by 2002:a63:445f:0:b0:373:d43f:2b42 with SMTP id t31-20020a63445f000000b00373d43f2b42mr9841614pgk.125.1645381320610; Sun, 20 Feb 2022 10:22:00 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id u8sm13528107pgf.83.2022.02.20.10.21.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 10:21:59 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Cristian Dumitrescu Subject: [PATCH v3 8/8] pipeline: remove unnecessary checks for NULL pointer before free Date: Sun, 20 Feb 2022 10:21:47 -0800 Message-Id: <20220220182147.9750-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220220182147.9750-1-stephen@networkplumber.org> References: <20220219234322.61309-1-stephen@networkplumber.org> <20220220182147.9750-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 This library (mostly) uses convention that allows caller to pass NULL. Signed-off-by: Stephen Hemminger --- lib/pipeline/rte_port_in_action.h | 6 ++++-- lib/pipeline/rte_swx_ctl.c | 3 +-- lib/pipeline/rte_swx_ctl.h | 1 + lib/pipeline/rte_swx_pipeline.c | 6 ++---- lib/pipeline/rte_swx_pipeline.h | 1 + 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/pipeline/rte_port_in_action.h b/lib/pipeline/rte_port_in_action.h index d6b063cf58a7..9debb9269297 100644 --- a/lib/pipeline/rte_port_in_action.h +++ b/lib/pipeline/rte_port_in_action.h @@ -181,8 +181,9 @@ rte_port_in_action_profile_create(uint32_t socket_id); * * @param[in] profile * Input port action profile handle (needs to be valid). + * If NULL then, the function does nothing. * @return - * Zero on success, non-zero error code otherwise. + * always zero. */ __rte_experimental int @@ -259,8 +260,9 @@ rte_port_in_action_create(struct rte_port_in_action_profile *profile, * * @param[in] action * Handle to input port action object (needs to be valid). + * If NULL then, the function does nothing. * @return - * Zero on success, non-zero error code otherwise. + * Always zero. */ __rte_experimental int diff --git a/lib/pipeline/rte_swx_ctl.c b/lib/pipeline/rte_swx_ctl.c index f52ccffd75a4..710e89a46a26 100644 --- a/lib/pipeline/rte_swx_ctl.c +++ b/lib/pipeline/rte_swx_ctl.c @@ -1046,8 +1046,7 @@ table_state_free(struct rte_swx_ctl_pipeline *ctl) struct rte_swx_table_state *ts = &ctl->ts_next[selector_base_index + i]; /* Table object. */ - if (ts->obj) - rte_swx_table_selector_free(ts->obj); + rte_swx_table_selector_free(ts->obj); } /* For each learner table, free its table state. */ diff --git a/lib/pipeline/rte_swx_ctl.h b/lib/pipeline/rte_swx_ctl.h index 82e62e70a7c3..501731d54724 100644 --- a/lib/pipeline/rte_swx_ctl.h +++ b/lib/pipeline/rte_swx_ctl.h @@ -1285,6 +1285,7 @@ rte_swx_ctl_meter_stats_read(struct rte_swx_pipeline *p, * * @param[in] ctl * Pipeline control handle. + * If NULL then, the function does nothing. */ __rte_experimental void diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c index 868010303c73..0177a45c4486 100644 --- a/lib/pipeline/rte_swx_pipeline.c +++ b/lib/pipeline/rte_swx_pipeline.c @@ -8672,16 +8672,14 @@ table_state_build_free(struct rte_swx_pipeline *p) struct rte_swx_table_state *ts = &p->table_state[p->n_tables + i]; /* ts->obj. */ - if (ts->obj) - rte_swx_table_selector_free(ts->obj); + rte_swx_table_selector_free(ts->obj); } for (i = 0; i < p->n_learners; i++) { struct rte_swx_table_state *ts = &p->table_state[p->n_tables + p->n_selectors + i]; /* ts->obj. */ - if (ts->obj) - rte_swx_table_learner_free(ts->obj); + rte_swx_table_learner_free(ts->obj); /* ts->default_action_data. */ free(ts->default_action_data); diff --git a/lib/pipeline/rte_swx_pipeline.h b/lib/pipeline/rte_swx_pipeline.h index 77141bd3415b..51817159b154 100644 --- a/lib/pipeline/rte_swx_pipeline.h +++ b/lib/pipeline/rte_swx_pipeline.h @@ -912,6 +912,7 @@ rte_swx_pipeline_flush(struct rte_swx_pipeline *p); * * @param[in] p * Pipeline handle. + * If NULL then, the function does nothing. */ __rte_experimental void -- 2.34.1