2023-04-23 12:39:32

by Yuchen Yang

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

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 <[email protected]>
Reviewed-by: Dongliang Mu <[email protected]>
---
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


2023-04-24 11:56:49

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] drivers: regulator: core: remove return value check of `regulator_init`

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 :(


Attachments:
(No filename) (555.00 B)
signature.asc (499.00 B)
Download all attachments