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 49DE4A04A6; Mon, 24 Jan 2022 01:05:25 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BABC74068B; Mon, 24 Jan 2022 01:05:24 +0100 (CET) Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by mails.dpdk.org (Postfix) with ESMTP id A601840040 for ; Mon, 24 Jan 2022 01:05:22 +0100 (CET) Received: by mail-pg1-f169.google.com with SMTP id i8so13592667pgt.13 for ; Sun, 23 Jan 2022 16:05:22 -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:mime-version :content-transfer-encoding; bh=BTOSIdbYIBQPuUlGWzWzZaqzzYhMMpdXC5+1GzV9/tw=; b=GqBZdJZkoQYI7+c+oPOAmLloBoa0fnlbrK/wSjXj6R8LRehg5Rd92Y4H/YAcgWMett Nqju0xsiHoS8sJBKC81r/bURTKRM38s579fS5uX1J/LxqE/3IN/jT6HplsylJRFS5Am2 z3UTxsk14E2NRsUF+hZu0IHpcl0yQDlCf3FVHt8KKWxVSbXo2GN9T17UhQgA1CjYm+O9 n6ZfGZfNnL5302h7KX3pYSlIFsKsqmbri20aQyi4MfCCEZY56Cg0c/4ynaqIYjcx93mY fWclbaDqQllcYxLqV35BT+5VwZZ/2bWY2lY5bPPa0Y3ZNNByswXCZo1zwINgpQ4tZYqr 4GVw== 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:mime-version :content-transfer-encoding; bh=BTOSIdbYIBQPuUlGWzWzZaqzzYhMMpdXC5+1GzV9/tw=; b=kPBgbJznHabRadV+A5aU/uTyhVuNG0fqBVnqXAparDyyQohHj+MenUWmnApo8oX/S9 Y2bp09Tty0ZMj2xiUIndKRbnIRuuTX4oDpO3Pv0V0w3CjrLttEb4twVtIt8+uBCzZmoW PUzJ/gXRYY6nU9Ne+sah3idRDpitV8Gt6ibc9byFov+SsEF+UzFIHhfRV3vWWXbCjN0J JsVCmeHmG753kXOPK4R2J0AMk3UcV1Ff2nn2VOsR1S6MBgXR19N95J/MH9a+gzL3H4l9 R0y5n2/MG2gpXOlaj08upshnZg/aImLp31cXn0w+BS+n0W3FVoJw8VASgcSu3WIT2eZU GyZw== X-Gm-Message-State: AOAM533Z2faOfWF7nf7jH1mkQzqtFO8mFz/g4eaH2znozeaKdkHenbge EAbtC7LNocf0HqA0IrIA19X8lyqhrz0+Ew== X-Google-Smtp-Source: ABdhPJwy/PfYp3j71qMmWFlvEDFj14VAs8WGQceinJlFX/23A2+IlU1NU8Vt8KRnZP4nZFEO1hUX9w== X-Received: by 2002:a05:6a00:1896:b0:4c9:6027:e847 with SMTP id x22-20020a056a00189600b004c96027e847mr2083089pfh.15.1642982721407; Sun, 23 Jan 2022 16:05:21 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id ck21sm10935350pjb.51.2022.01.23.16.05.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 16:05:20 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH 00/82] remove unnecessary null checks Date: Sun, 23 Jan 2022 16:03:56 -0800 Message-Id: <20220124000518.319850-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.30.2 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 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. Stephen Hemminger (82): devtools/cocci: add script to fix unnecessary null checks eal: remove unnecessary NULL checks eal/windows: remove unnecessary NULL checks before free examples/fips_validation: remove unnecessary NULL checks examples/ip_pipeline: remove unnecessary NULL checks examples/pipeline/thread: remove unnecessary NULL checks examples/l2fwd-cat: remove unnecessary NULL checks lib/vhost: remove unnecessary NULL checks examples/vhost_blk: remove unnecessary NULL checks app/pdump: remove unnecessary NULL checks app/test-crypto-perf: remove unnecessary NULL checks app/test-pmd: remove unnecessary NULL checks app/test-regex: remove unnecessary NULL checks app/test: remove unnecessary NULL checks baseband/acc100 remove unnecessary NULL checks baseband/la12xx remove unnecessary NULL checks baseband/null remove unnecessary NULL checks baseband/turbo_sw remove unnecessary NULL checks bus/fslmc: remove unnecessary NULL checks bus/ifpga: remove unnecessary NULL checks bus/pci: remove unnecessary NULL checks common/cpt: remove unnecessary NULL checks common/dpaax: simplify kernel compat macros common/mlx5: remove unnecessary NULL checks common/qat: remove unnecessary NULL checks compress/mlx5: remove unnecessary NULL checks compress/octeontx: remove unnecessary NULL checks crypto/armv8: remove unnecessary NULL checks crypto/ccp: remove unnecessary NULL checks crypto/cnxk: remove unnecessary NULL checks crypto/ipsec_mb: remove unnecessary NULL checks crypto/mvsam: remove unnecessary NULL checks crypto/null: remove unnecessary NULL checks crypto/octeontx: remove unnecessary NULL checks crypto/openssl: remove unnecessary NULL checks crypto/scheduler: remove unnecessary NULL checks crypto/virtio: remove unnecessary NULL checks event/sw: remove unnecessary NULL checks net/axgbe: remove unnecessary NULL checks net/bnx2x: remove unnecessary NULL checks net/bnxt: remove unnecessary NULL checks net/bonding: remove unnecessary NULL checks net/cnxk: remove unnecessary NULL checks net/cxgbe: remove unnecessary NULL checks net/dpaa: remove unnecessary NULL checks net/dpaa2: remove unnecessary NULL checks net/ena: remove unnecessary NULL checks net/hinic: remove unnecessary NULL checks net/hns3: remove unnecessary NULL checks net/i40e: remove unnecessary NULL checks net/iavf: remove unnecessary NULL checks net/ice: remove unnecessary NULL checks net/igc: remove unnecessary NULL checks net/ixgbe: remove unnecessary NULL checks net/memif: remove unnecessary NULL checks net/mlx4: remove unnecessary NULL checks net/mlx5: remove unnecessary NULL checks net/mvpp2: remove unnecessary NULL checks net/netvsc: remove unnecessary NULL checks net/null: remove unnecessary NULL checks net/octeontx: remove unnecessary NULL checks net/qede: remove unnecessary NULL checks net/softnic: remove unnecessary NULL checks net/tap: remove unnecessary NULL checks net/txgbe: remove unnecessary NULL checks net/vdev_netvsc: remove unnecessary NULL checks net/virtio: remove unnecessary NULL checks raw/cnxk_bphy: remove unnecessary NULL checks raw/dpaa2_qdma: remove unnecessary NULL checks raw/ifpga: remove unnecessary NULL checks raw/skeleton: remove unnecessary NULL checks regex/cn9k: remove unnecessary NULL checks regex/mlx5: remove unnecessary NULL checks vdpa/ifc: remove unnecessary NULL checks vdpa/mlx5: remove unnecessary NULL checks compressdev: remove unnecessary NULL checks ethdev: remove unnecessary NULL checks graph: remove unnecessary NULL checks ipsec: remove unnecessary NULL checks port: remove unnecessary NULL checks power: remove unnecessary NULL checks reorder: 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 | 6 +-- 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 | 3 +- drivers/net/ixgbe/ixgbe_ethdev.c | 10 ++--- 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/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 +-- lib/vhost/iotlb.c | 3 +- lib/vhost/vhost_crypto.c | 6 +-- lib/vhost/vhost_user.c | 9 ++-- 131 files changed, 306 insertions(+), 557 deletions(-) create mode 100644 devtools/cocci/nullfree.cocci -- 2.30.2