From nobody Tue Dec 16 16:42:55 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F21CC77B61 for ; Mon, 24 Apr 2023 09:24:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230432AbjDXJYP (ORCPT ); Mon, 24 Apr 2023 05:24:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230139AbjDXJYM (ORCPT ); Mon, 24 Apr 2023 05:24:12 -0400 Received: from hust.edu.cn (unknown [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 658E21FCC for ; Mon, 24 Apr 2023 02:23:50 -0700 (PDT) Received: from huangjintao.. ([10.12.190.56]) (user=u202017189@hust.edu.cn mech=LOGIN bits=0) by mx1.hust.edu.cn with ESMTP id 33O9Mveu031569-33O9Mvev031569 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 24 Apr 2023 17:23:03 +0800 From: Jintao Huang To: Sanjay R Mehta , Shyam Sundar S K , Jon Mason , Dave Jiang , Allen Hubbe Cc: hust-os-kernel-patches@googlegroups.com, Jintao Huang , Dongliang Mu , ntb@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH] NTB: remove all the checks of the return values. Date: Mon, 24 Apr 2023 09:22:55 +0000 Message-Id: <20230424092255.29338-1-u202017189@hust.edu.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FEAS-AUTH-USER: u202017189@hust.edu.cn Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The comments in debugfs_create_dir and debugfs_create_file point out that, generally, we do not need to check the return arguments of the functions. In this case, it will be useful to delete all the checks about the return arguments. Signed-off-by: Jintao Huang Reviewed-by: Dongliang Mu --- This issue is found by static analyzer. The patched code has passed Smatch checker, but remains untested on concrete running. --- drivers/ntb/hw/amd/ntb_hw_amd.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.c b/drivers/ntb/hw/amd/ntb_hw_am= d.c index 04550b1f984c..6b0f0c4bf278 100644 --- a/drivers/ntb/hw/amd/ntb_hw_amd.c +++ b/drivers/ntb/hw/amd/ntb_hw_amd.c @@ -934,21 +934,13 @@ static ssize_t ndev_debugfs_read(struct file *filp, c= har __user *ubuf, =20 static void ndev_init_debugfs(struct amd_ntb_dev *ndev) { - if (!debugfs_dir) { - ndev->debugfs_dir =3D NULL; - ndev->debugfs_info =3D NULL; - } else { - ndev->debugfs_dir =3D - debugfs_create_dir(pci_name(ndev->ntb.pdev), - debugfs_dir); - if (!ndev->debugfs_dir) - ndev->debugfs_info =3D NULL; - else - ndev->debugfs_info =3D - debugfs_create_file("info", S_IRUSR, - ndev->debugfs_dir, ndev, - &amd_ntb_debugfs_info); - } + ndev->debugfs_dir =3D + debugfs_create_dir(pci_name(ndev->ntb.pdev), + debugfs_dir); + ndev->debugfs_info =3D + debugfs_create_file("info", 0400, + ndev->debugfs_dir, ndev, + &amd_ntb_debugfs_info); } =20 static void ndev_deinit_debugfs(struct amd_ntb_dev *ndev) --=20 2.34.1