ntb.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Jintao Huang <u202017189@hust.edu.cn>
To: Sanjay R Mehta <sanju.mehta@amd.com>,
	Shyam Sundar S K <Shyam-sundar.S-k@amd.com>,
	Jon Mason <jdmason@kudzu.us>, Dave Jiang <dave.jiang@intel.com>,
	Allen Hubbe <allenbh@gmail.com>
Cc: hust-os-kernel-patches@googlegroups.com,
	Jintao Huang <u202017189@hust.edu.cn>,
	Dongliang Mu <dzm91@hust.edu.cn>,
	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	[thread overview]
Message-ID: <20230424092255.29338-1-u202017189@hust.edu.cn> (raw)

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 <u202017189@hust.edu.cn>
Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
---
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_amd.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, char __user *ubuf,
 
 static void ndev_init_debugfs(struct amd_ntb_dev *ndev)
 {
-	if (!debugfs_dir) {
-		ndev->debugfs_dir = NULL;
-		ndev->debugfs_info = NULL;
-	} else {
-		ndev->debugfs_dir =
-			debugfs_create_dir(pci_name(ndev->ntb.pdev),
-					   debugfs_dir);
-		if (!ndev->debugfs_dir)
-			ndev->debugfs_info = NULL;
-		else
-			ndev->debugfs_info =
-				debugfs_create_file("info", S_IRUSR,
-						    ndev->debugfs_dir, ndev,
-						    &amd_ntb_debugfs_info);
-	}
+	ndev->debugfs_dir =
+		debugfs_create_dir(pci_name(ndev->ntb.pdev),
+				   debugfs_dir);
+	ndev->debugfs_info =
+		debugfs_create_file("info", 0400,
+				    ndev->debugfs_dir, ndev,
+				    &amd_ntb_debugfs_info);
 }
 
 static void ndev_deinit_debugfs(struct amd_ntb_dev *ndev)
-- 
2.34.1


                 reply	other threads:[~2023-04-24  9:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230424092255.29338-1-u202017189@hust.edu.cn \
    --to=u202017189@hust.edu.cn \
    --cc=Shyam-sundar.S-k@amd.com \
    --cc=allenbh@gmail.com \
    --cc=dave.jiang@intel.com \
    --cc=dzm91@hust.edu.cn \
    --cc=hust-os-kernel-patches@googlegroups.com \
    --cc=jdmason@kudzu.us \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntb@lists.linux.dev \
    --cc=sanju.mehta@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).