From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 04A17A034E;
	Wed,  9 Feb 2022 20:17:54 +0100 (CET)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id B9E5E41101;
	Wed,  9 Feb 2022 20:17:53 +0100 (CET)
Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com
 [209.85.210.182])
 by mails.dpdk.org (Postfix) with ESMTP id 373B540140
 for <dev@dpdk.org>; Wed,  9 Feb 2022 20:17:52 +0100 (CET)
Received: by mail-pf1-f182.google.com with SMTP id d187so5942378pfa.10
 for <dev@dpdk.org>; Wed, 09 Feb 2022 11:17:52 -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=fISF3QKhYfqePbKXqVQSo0pwz/Aje2bb+BbXpARC7Vs=;
 b=5iMv94q76iwSgzB2BRWesVSWIdZg/152vnTa/JX21xOIt3Q5RnOeXCBdF4Pkv+pBjU
 /Jp0S91rRlN3MC9QAA5+KYcnSdnjtnVeLSOxXE6KoPd/8B/BbEdA0cKywQtfBtAZhLPI
 7unagqPdQEZi8aMfiFPXo9MLVCbf2Mz0itpCB3HFKohDmnGGcNxAX/oWhaoQ7yZR0JSn
 cF4D7P3GbaKr3zLRy7rhNU/3Hr2mfVHUr2FzcBf0e04awwaGKYkJv6XaMvcRkyRxzLTG
 0K3S8ZFNVh3PMkgdS8ym2Xq19BYr+zLu36WMvxpzKdnSw/fp8zS+8NuZ4KP1acpwwCpv
 QYnA==
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=fISF3QKhYfqePbKXqVQSo0pwz/Aje2bb+BbXpARC7Vs=;
 b=bSEmrff/2fUddhShP3fM138BJqg8Suru/yo8J14aj5ZosgykCVBMr/lCXYeL1OQ3iB
 4pAyT02M7fMN/Ij6cbT2qkZtxzyfk+dyUBS3UgsKVBrzf/BTeB4j9yFtgh15Y2tiAgaI
 Lv4gGsfyp0eYrDzPbiEh4egd/7wNcReDJGvYOJzA5jSX5x5Eh+hCjSDMytMQFh+VNJ5L
 XT96Iq3UiTck2YKmitYqaK1IWfrWoXCOrx9+BKdzNAXEWhqYNedqIaAVW5FonyZHdry1
 ETEBhQIFPBUUuNPaBTksmFaDaufpXDu+RsyMXwGXnoMJ5OVd9AAGHXfxrKm67qqXEDwk
 SfjA==
X-Gm-Message-State: AOAM533/AbEjxnMCmnPPh3K1bEpE+8dzP17znDIBAiU7fyWapP5Kzk9A
 0OzoYCUZtjCrSM1XePM8zctFOGsW7RNl61vJ
X-Google-Smtp-Source: ABdhPJxjsgtgnQDh4p698bpwEZBMB0OdPAk9qQDy/JQkSGjsENTHRq6vVedAo72CpawucYABTGv16g==
X-Received: by 2002:a63:2048:: with SMTP id r8mr3086250pgm.211.1644434270996; 
 Wed, 09 Feb 2022 11:17:50 -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.17.49
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 09 Feb 2022 11:17:50 -0800 (PST)
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH v3 00/36] remove unnecessary null checks
Date: Wed,  9 Feb 2022 11:17:12 -0800
Message-Id: <20220209191748.377729-1-stephen@networkplumber.org>
X-Mailer: git-send-email 2.34.1
In-Reply-To: <20220124000518.319850-1-stephen@networkplumber.org>
References: <20220124000518.319850-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 <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

While working on a new driver, noticed that some drivers always call
free routines (correct) and others conditionally call free routines
if not null (redundant check).  The extra if(e != NULL) type check
is unneeded and adds extra code.  Better to have all the code
consistent.

The Linux kernel has automated this kind of fixup using coccinelle,
and this patchset creates a coccinelle script to do the transformation;
then has individual patches for each sub component.

In one driver dpaaxx, the change suggested a further change
to the compat macros to make them even simpler.

v3
  - consolidate patches into logical groups

v2
  - add documentation change patch
  - spelling fix to coccinelle script patch
  - suggested whitespace fix to igc and ixgbe patch


Stephen Hemminger (36):
  lib: update documentation of XXX_free() functions
  devtools/cocci: add script to fix unnecessary null checks
  eal: remove unnecessary NULL checks
  ethdev: remove unnecessary NULL checks
  examples: remove unnecessary NULL checks
  vhost: remove unnecessary NULL checks
  app: remove unnecessary NULL checks
  baseband/*: remove unnecessary NULL checks
  bus/*: remove unnecessary NULL checks
  common/*: remove unnecessary NULL checks
  compress/*: remove unnecessary NULL checks
  crypto: remove unnecessary NULL checks
  event/sw: remove unnecessary NULL checks
  net/axgbe: remove unnecessary NULL checks
  net/bnx*: remove unnecessary NULL checks
  net/cnxk: remove unnecessary NULL checks
  net/cxgbe: remove unnecessary NULL checks
  net/dpaa*: remove unnecessary NULL checks
  net/ena: remove unnecessary NULL checks
  net/hinic: remove unnecessary NULL checks
  net/hns3: remove unnecessary NULL checks
  net/i*: remove unnecessary NULL checks
  net/mlx*: remove unnecessary NULL checks
  net/mvpp2: remove unnecessary NULL checks
  net/netvsc: remove unnecessary NULL checks
  net/octeontx: remove unnecessary NULL checks
  net/qede: remove unnecessary NULL checks
  net/txgbe: remove unnecessary NULL checks
  net/vdev_netvsc: remove unnecessary NULL checks
  net/virtio: remove unnecessary NULL checks
  net/other: remove unnecessary NULL checks
  raw/*: remove unnecessary NULL checks
  regex/*: remove unnecessary NULL checks
  vdpa/*: remove unnecessary NULL checks
  compressdev: remove unnecessary NULL checks
  other: remove unnecessary NULL checks

 app/pdump/main.c                              |  9 ++--
 app/test-crypto-perf/cperf_test_latency.c     |  3 +-
 .../cperf_test_pmd_cyclecount.c               |  9 ++--
 app/test-crypto-perf/cperf_test_throughput.c  |  3 +-
 .../cperf_test_vector_parsing.c               |  6 +--
 app/test-crypto-perf/cperf_test_verify.c      |  3 +-
 app/test-pmd/cmd_flex_item.c                  |  3 +-
 app/test-pmd/cmdline.c                        |  3 +-
 app/test-pmd/testpmd.c                        |  3 +-
 app/test-regex/main.c                         | 12 ++---
 app/test/test_cksum.c                         |  3 +-
 app/test/test_compressdev.c                   |  3 +-
 app/test/test_cryptodev.h                     |  3 +-
 app/test/test_cryptodev_asym.c                |  3 +-
 app/test/test_cryptodev_blockcipher.c         | 12 ++---
 app/test/test_func_reentrancy.c               | 15 +++----
 app/test/test_hash.c                          | 15 +++----
 app/test/test_hash_perf.c                     |  7 +--
 app/test/test_link_bonding.c                  |  9 ++--
 app/test/test_link_bonding_mode4.c            |  3 +-
 app/test/test_malloc.c                        |  5 +--
 app/test/test_mbuf.c                          | 45 +++++++------------
 app/test/test_pcapng.c                        |  3 +-
 app/test/test_reorder.c                       | 15 +++----
 app/test/virtual_pmd.c                        |  3 +-
 devtools/cocci/nullfree.cocci                 | 33 ++++++++++++++
 drivers/baseband/acc100/rte_acc100_pmd.c      |  3 +-
 drivers/baseband/la12xx/bbdev_la12xx.c        |  3 +-
 drivers/baseband/null/bbdev_null.c            |  3 +-
 .../baseband/turbo_sw/bbdev_turbo_software.c  |  3 +-
 drivers/bus/fslmc/fslmc_bus.c                 |  6 +--
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c      |  6 +--
 drivers/bus/ifpga/ifpga_bus.c                 | 12 ++---
 drivers/bus/pci/pci_params.c                  |  3 +-
 drivers/bus/pci/windows/pci.c                 |  3 +-
 drivers/bus/pci/windows/pci_netuio.c          |  3 +-
 drivers/common/cpt/cpt_ucode_asym.h           |  6 +--
 drivers/common/dpaax/compat.h                 | 11 +----
 drivers/common/mlx5/mlx5_common_mr.c          |  3 +-
 drivers/common/mlx5/mlx5_common_pci.c         |  3 +-
 drivers/common/qat/qat_qp.c                   |  9 ++--
 drivers/compress/mlx5/mlx5_compress.c         |  3 +-
 drivers/compress/octeontx/otx_zip_pmd.c       |  9 ++--
 drivers/crypto/armv8/rte_armv8_pmd_ops.c      |  3 +-
 drivers/crypto/ccp/ccp_dev.c                  |  3 +-
 drivers/crypto/ccp/ccp_pmd_ops.c              |  3 +-
 drivers/crypto/cnxk/cnxk_ae.h                 |  6 +--
 drivers/crypto/ipsec_mb/ipsec_mb_ops.c        |  3 +-
 drivers/crypto/mvsam/rte_mrvl_pmd_ops.c       |  6 +--
 drivers/crypto/null/null_crypto_pmd_ops.c     |  6 +--
 drivers/crypto/octeontx/otx_cryptodev_ops.c   |  3 +-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c  |  6 +--
 drivers/crypto/scheduler/scheduler_pmd_ops.c  |  6 +--
 drivers/crypto/virtio/virtqueue.c             |  6 +--
 drivers/event/sw/sw_evdev.c                   |  3 +-
 drivers/net/axgbe/axgbe_rxtx.c                |  6 +--
 drivers/net/bnx2x/bnx2x_rxtx.c                |  6 +--
 drivers/net/bnxt/bnxt_ethdev.c                |  3 +-
 drivers/net/bonding/rte_eth_bond_pmd.c        |  3 +-
 drivers/net/cnxk/cnxk_ethdev.c                |  6 +--
 drivers/net/cxgbe/cxgbe_main.c                |  3 +-
 drivers/net/dpaa/dpaa_ethdev.c                |  3 +-
 drivers/net/dpaa/fmlib/fm_lib.c               |  3 +-
 drivers/net/dpaa2/dpaa2_ethdev.c              |  3 +-
 drivers/net/dpaa2/dpaa2_mux.c                 |  3 +-
 drivers/net/dpaa2/dpaa2_ptp.c                 |  3 +-
 drivers/net/ena/ena_ethdev.c                  | 18 +++-----
 drivers/net/hinic/hinic_pmd_ethdev.c          |  3 +-
 drivers/net/hns3/hns3_rxtx.c                  |  9 ++--
 drivers/net/i40e/i40e_ethdev.c                | 27 ++++-------
 drivers/net/i40e/i40e_rxtx.c                  |  3 +-
 drivers/net/iavf/iavf_rxtx.c                  |  3 +-
 drivers/net/ice/ice_fdir_filter.c             |  6 +--
 drivers/net/igc/igc_flow.c                    |  5 +--
 drivers/net/ixgbe/ixgbe_ethdev.c              | 12 ++---
 drivers/net/ixgbe/ixgbe_rxtx.c                |  3 +-
 drivers/net/memif/rte_eth_memif.c             |  6 +--
 drivers/net/mlx4/mlx4_mr.c                    |  3 +-
 drivers/net/mlx5/mlx5_flow.c                  |  3 +-
 drivers/net/mvpp2/mrvl_qos.c                  |  3 +-
 drivers/net/netvsc/hn_rxtx.c                  |  6 +--
 drivers/net/null/rte_eth_null.c               |  3 +-
 drivers/net/octeontx/octeontx_ethdev.c        |  3 +-
 drivers/net/octeontx/octeontx_ethdev_ops.c    |  3 +-
 drivers/net/qede/qede_main.c                  |  3 +-
 drivers/net/qede/qede_rxtx.c                  |  6 +--
 drivers/net/softnic/rte_eth_softnic_cli.c     | 12 ++---
 .../net/softnic/rte_eth_softnic_cryptodev.c   |  6 +--
 drivers/net/softnic/rte_eth_softnic_thread.c  |  6 +--
 drivers/net/tap/tap_flow.c                    |  9 ++--
 drivers/net/txgbe/txgbe_ethdev.c              | 12 ++---
 drivers/net/vdev_netvsc/vdev_netvsc.c         |  3 +-
 drivers/net/virtio/virtio_user_ethdev.c       | 12 ++---
 drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c         |  3 +-
 drivers/raw/dpaa2_qdma/dpaa2_qdma.c           | 15 +++----
 drivers/raw/ifpga/ifpga_rawdev.c              |  9 ++--
 drivers/raw/skeleton/skeleton_rawdev_test.c   |  6 +--
 drivers/regex/cn9k/cn9k_regexdev.c            |  6 +--
 drivers/regex/cn9k/cn9k_regexdev_compiler.c   |  3 +-
 drivers/regex/mlx5/mlx5_regex.c               |  3 +-
 drivers/regex/mlx5/mlx5_rxp.c                 |  3 +-
 drivers/vdpa/ifc/ifcvf_vdpa.c                 |  9 ++--
 drivers/vdpa/mlx5/mlx5_vdpa_mem.c             |  3 +-
 drivers/vdpa/mlx5/mlx5_vdpa_virtq.c           |  3 +-
 examples/fips_validation/fips_dev_self_test.c | 18 +++-----
 examples/fips_validation/fips_validation.c    |  3 +-
 examples/fips_validation/main.c               | 36 +++++----------
 examples/ip_pipeline/cli.c                    | 12 ++---
 examples/ip_pipeline/cryptodev.c              |  6 +--
 examples/ip_pipeline/thread.c                 |  6 +--
 examples/l2fwd-cat/cat.c                      |  3 +-
 examples/pipeline/thread.c                    |  6 +--
 examples/vhost_blk/vhost_blk.c                |  3 +-
 lib/compressdev/rte_compressdev.c             |  3 +-
 lib/eal/common/eal_common_devargs.c           |  6 +--
 lib/eal/common/eal_common_memzone.c           |  3 +-
 lib/eal/common/eal_common_options.c           |  9 ++--
 lib/eal/common/eal_common_trace_ctf.c         |  6 +--
 lib/eal/freebsd/eal.c                         |  4 +-
 lib/eal/linux/eal.c                           | 10 ++---
 lib/eal/windows/eal_alarm.c                   |  3 +-
 lib/eal/windows/eal_memory.c                  |  3 +-
 lib/ethdev/rte_ethdev.c                       |  3 +-
 lib/graph/graph_stats.c                       |  3 +-
 lib/hash/rte_hash.h                           |  4 +-
 lib/ipsec/ipsec_sad.c                         |  3 +-
 lib/mempool/rte_mempool.h                     |  1 +
 lib/port/rte_port_source_sink.c               | 21 +++------
 lib/power/rte_power_empty_poll.c              |  3 +-
 lib/reorder/rte_reorder.c                     |  6 +--
 lib/ring/rte_ring.h                           |  3 +-
 lib/vhost/iotlb.c                             |  3 +-
 lib/vhost/vhost_crypto.c                      |  6 +--
 lib/vhost/vhost_user.c                        |  9 ++--
 134 files changed, 312 insertions(+), 560 deletions(-)
 create mode 100644 devtools/cocci/nullfree.cocci

-- 
2.34.1