From: Wenchao Hao <haowenchao22@gmail.com>
To: Dan Carpenter <dan.carpenter@linaro.org>,
Wenchao Hao <haowenchao2@huawei.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
linux-scsi@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 2/2] scsi: scsi_debug: delete some bogus error checking
Date: Sat, 21 Oct 2023 01:28:50 +0800 [thread overview]
Message-ID: <d2cb55a9-6bc0-47a0-a812-418d187c2c00@gmail.com> (raw)
In-Reply-To: <f96d6366-9271-4020-ab66-f75737a1e8bd@moroto.mountain>
On 2023/10/20 22:15, Dan Carpenter wrote:
> Smatch complains that "dentry" is never initialized. These days everyone
> initializes all their stack variables to zero so this means that it will
> trigger a warning every time this function is run.
>
> Really debugfs functions are not supposed to be checked for errors so
> this checking can just be deleted.
>
> Fixes: f084fe52c640 ("scsi: scsi_debug: Add debugfs interface to fail target reset")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> See my blog for more information on the history of debugfs error
> checking:
>
> https://staticthinking.wordpress.com/2023/07/24/debugfs-functions-are-not-supposed-to-be-checked/
> ---
> drivers/scsi/scsi_debug.c | 7 -------
> 1 file changed, 7 deletions(-)
>
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index 0a4e41d84df8..c0be9a53ac79 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -1127,7 +1127,6 @@ static const struct file_operations sdebug_target_reset_fail_fops = {
> static int sdebug_target_alloc(struct scsi_target *starget)
> {
> struct sdebug_target_info *targetip;
> - struct dentry *dentry;
>
> targetip = kzalloc(sizeof(struct sdebug_target_info), GFP_KERNEL);
> if (!targetip)
> @@ -1135,15 +1134,9 @@ static int sdebug_target_alloc(struct scsi_target *starget)
>
> targetip->debugfs_entry = debugfs_create_dir(dev_name(&starget->dev),
> sdebug_debugfs_root);
> - if (IS_ERR_OR_NULL(targetip->debugfs_entry))
> - pr_info("%s: failed to create debugfs directory for target %s\n",
> - __func__, dev_name(&starget->dev));
>
> debugfs_create_file("fail_reset", 0600, targetip->debugfs_entry, starget,
> &sdebug_target_reset_fail_fops);
> - if (IS_ERR_OR_NULL(dentry))
> - pr_info("%s: failed to create fail_reset file for target %s\n",
> - __func__, dev_name(&starget->dev));
>
> starget->hostdata = targetip;
>
Thank you for the fix, the check for debugfs_create_file() is added because
scsi_debug driver is often used to test abnormal situations, here just check
and prompt a log, so maybe you should not remove it and fix the issue
following changes:
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 67922e2c4c19..d37437fa9eba 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -1144,8 +1144,8 @@ static int sdebug_target_alloc(struct scsi_target *starget)
pr_info("%s: failed to create debugfs directory for target %s\n",
__func__, dev_name(&starget->dev));
- debugfs_create_file("fail_reset", 0600, targetip->debugfs_entry, starget,
- &sdebug_target_reset_fail_fops);
+ dentry = debugfs_create_file("fail_reset", 0600, targetip->debugfs_entry,
+ starget, &sdebug_target_reset_fail_fops);
if (IS_ERR_OR_NULL(dentry))
pr_info("%s: failed to create fail_reset file for target %s\n",
__func__, dev_name(&starget->dev));
next prev parent reply other threads:[~2023-10-20 17:29 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-20 14:15 [PATCH 1/2] scsi: scsi_debug: fix some bugs in sdebug_error_write() Dan Carpenter
2023-10-20 14:15 ` [PATCH 2/2] scsi: scsi_debug: delete some bogus error checking Dan Carpenter
2023-10-20 17:28 ` Wenchao Hao [this message]
2023-10-23 5:06 ` Dan Carpenter
2023-10-24 16:49 ` Wenchao Hao
2023-10-25 4:07 ` Dan Carpenter
2023-10-21 10:10 ` [PATCH 1/2] scsi: scsi_debug: fix some bugs in sdebug_error_write() Wenchao Hao
2023-10-23 13:39 ` Dan Carpenter
2023-10-24 17:09 ` Wenchao Hao
2023-10-25 4:11 ` Dan Carpenter
2023-10-25 6:10 ` Wenchao Hao
2023-10-25 7:07 ` Dan Carpenter
2023-11-03 18:00 ` Wenchao Hao
2023-11-03 18:13 ` Wenchao Hao
2023-11-06 13:44 ` Dan Carpenter
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=d2cb55a9-6bc0-47a0-a812-418d187c2c00@gmail.com \
--to=haowenchao22@gmail.com \
--cc=dan.carpenter@linaro.org \
--cc=haowenchao2@huawei.com \
--cc=jejb@linux.ibm.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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