[PATCH] drivers: regulator: core: remove return value check of `regulator_init`

Yuchen Yang posted 1 patch 2 years, 7 months ago
drivers/regulator/core.c | 2 --
1 file changed, 2 deletions(-)
[PATCH] drivers: regulator: core: remove return value check of `regulator_init`
Posted by Yuchen Yang 2 years, 7 months ago
Smatch complains that:
regulator_init() warn: 'debugfs_root' is an error pointer or valid

According to the documentation of the debugfs_create_dir() function,
there is no need to check the return value of this function.
Just delete the dead code.

Fixes: 247514344492 ("regulator: Remove ifdefs for debugfs code")
Signed-off-by: Yuchen Yang <u202114568@hust.edu.cn>
Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
---
 drivers/regulator/core.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 4fcd36055b02..b14f281b1a97 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -6109,8 +6109,6 @@ static int __init regulator_init(void)
 	ret = class_register(&regulator_class);
 
 	debugfs_root = debugfs_create_dir("regulator", NULL);
-	if (!debugfs_root)
-		pr_warn("regulator: Failed to create debugfs directory\n");
 
 #ifdef CONFIG_DEBUG_FS
 	debugfs_create_file("supply_map", 0444, debugfs_root, NULL,
-- 
2.25.1
Re: [PATCH] drivers: regulator: core: remove return value check of `regulator_init`
Posted by Mark Brown 2 years, 7 months ago
On Sun, Apr 23, 2023 at 08:27:31PM +0800, Yuchen Yang wrote:
> Smatch complains that:
> regulator_init() warn: 'debugfs_root' is an error pointer or valid
> 
> According to the documentation of the debugfs_create_dir() function,
> there is no need to check the return value of this function.
> Just delete the dead code.

This is very much a taste and use case question, you can't just delete
error checks without thought.

> Fixes: 247514344492 ("regulator: Remove ifdefs for debugfs code")

Don't just throw random Fixes tags on things :(