Skip to contentSkip to conversation

scsi: fnic: delete incorrect debugfs error handling

PATCH In review Dan Carpenter 2 participants 2 messages Jan 7, 2025 – Jan 8, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: fnic: delete incorrect debugfs error handling

Debugfs functions are not supposed to require error checking and, in fact, adding checks would normally lead to the driver refusing to load when CONFIG_DEBUGFS is disabled.

What saves us here is that this code checks for NULL instead of error pointers so the error checking is all dead code. Delete it.

---
 drivers/scsi/fnic/fnic_debugfs.c | 25 +------------------------
 1 file changed, 1 insertion(+), 24 deletions(-)
drivers/scsi/fnic/fnic_debugfs.c +1 -24
index caee32bc9190..5767862ae42f 100644
@@ -679,46 +679,23 @@ static const struct file_operations fnic_reset_debugfs_fops = {
  */
 int fnic_stats_debugfs_init(struct fnic *fnic)
 {
-	int rc = -1;
 	char name[16];
 
 	snprintf(name, sizeof(name), "host%d", fnic->host->host_no);
 
-	if (!fnic_stats_debugfs_root) {
-		pr_debug("fnic_stats root doesn't exist\n");
-		return rc;
-	}
-
 	fnic->fnic_stats_debugfs_host = debugfs_create_dir(name,
 						fnic_stats_debugfs_root);
-
-	if (!fnic->fnic_stats_debugfs_host) {
-		pr_debug("Cannot create host directory\n");
-		return rc;
-	}
-
 	fnic->fnic_stats_debugfs_file = debugfs_create_file("stats",
 						S_IFREG|S_IRUGO|S_IWUSR,
 						fnic->fnic_stats_debugfs_host,
 						fnic,
 						&fnic_stats_debugfs_fops);
-
-	if (!fnic->fnic_stats_debugfs_file) {
-		pr_debug("Cannot create host stats file\n");
-		return rc;
-	}
-
 	fnic->fnic_reset_debugfs_file = debugfs_create_file("reset_stats",
 						S_IFREG|S_IRUGO|S_IWUSR,
 						fnic->fnic_stats_debugfs_host,
 						fnic,
 						&fnic_reset_debugfs_fops);
-	if (!fnic->fnic_reset_debugfs_file) {
-		pr_debug("Cannot create host stats file\n");
-		return rc;
-	}
-	rc = 0;
-	return rc;
+	return 0;
 }
 
 /*
Signature · 1 line
2.45.2
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 66 lines · Dan Carpenter

Debugfs functions are not supposed to require error checking and, in fact, adding checks would normally lead to the driver refusing to load when CONFIG_DEBUGFS is disabled.

What saves us here is that this code checks for NULL instead of error pointers so the error checking is all dead code. Delete it.

---
drivers/scsi/fnic/fnic_debugfs.c | 25 +------------------------

1 file changed, 1 insertion(+), 24 deletions(-)
drivers/scsi/fnic/fnic_debugfs.c +1 -25
index caee32bc9190..5767862ae42f 100644
@@ -679,46 +679,23 @@ static const struct file_operations fnic_reset_debugfs_fops = {
 */
 int fnic_stats_debugfs_init(struct fnic *fnic)
 {
-     int rc = -1;
 char name[16];
 
 snprintf(name, sizeof(name), "host%d", fnic->host->host_no);
 
-     if (!fnic_stats_debugfs_root) {
-             pr_debug("fnic_stats root doesn't exist\n");
-             return rc;
-     }
-
 fnic->fnic_stats_debugfs_host = debugfs_create_dir(name,
 fnic_stats_debugfs_root);
-
-     if (!fnic->fnic_stats_debugfs_host) {
-             pr_debug("Cannot create host directory\n");
-             return rc;
-     }
-
 fnic->fnic_stats_debugfs_file = debugfs_create_file("stats",
 S_IFREG|S_IRUGO|S_IWUSR,
 fnic->fnic_stats_debugfs_host,
 fnic,
 &fnic_stats_debugfs_fops);
-
-     if (!fnic->fnic_stats_debugfs_file) {
-             pr_debug("Cannot create host stats file\n");
-             return rc;
-     }
-
 fnic->fnic_reset_debugfs_file = debugfs_create_file("reset_stats",
 S_IFREG|S_IRUGO|S_IWUSR,
 fnic->fnic_stats_debugfs_host,
 fnic,
 &fnic_reset_debugfs_fops);
-     if (!fnic->fnic_reset_debugfs_file) {
-             pr_debug("Cannot create host stats file\n");
-             return rc;
-     }
-     rc = 0;
-     return rc;
+     return 0;
 }
 
 /*
--
Quoted 3 lines

2.45.2

Changes look good. Thanks for these changes.

Regards,
Karan