* [PATCH v2 -next] platform/x86: intel-ips: fix 'passing zero to PTR_ERR()' warning
@ 2018-11-26 13:19 YueHaibing
2018-11-26 13:37 ` Andy Shevchenko
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: YueHaibing @ 2018-11-26 13:19 UTC (permalink / raw)
To: dvhart, andy, jkosina
Cc: linux-kernel, platform-driver-x86, andriy.shevchenko, YueHaibing
Fix a static code checker warning:
drivers/platform/x86/intel_ips.c:1314
ips_debugfs_init() warn: passing zero to 'PTR_ERR'
drivers/platform/x86/intel_ips.c:1328
ips_debugfs_init() warn: passing zero to 'PTR_ERR'
If error occurs,debugfs_create_dir/debugfs_create_file
return NULL while debugfs is enabled, which should not
passing to PTR_ERR.
Fixes: aa7ffc01d254 ("x86 platform driver: intelligent power sharing driver")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
v2:Fix typo in patch log and title
---
drivers/platform/x86/intel_ips.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/platform/x86/intel_ips.c b/drivers/platform/x86/intel_ips.c
index 225638a..a5d1a68 100644
--- a/drivers/platform/x86/intel_ips.c
+++ b/drivers/platform/x86/intel_ips.c
@@ -1311,8 +1311,7 @@ static void ips_debugfs_init(struct ips_driver *ips)
ips->debug_root = debugfs_create_dir("ips", NULL);
if (!ips->debug_root) {
- dev_err(ips->dev, "failed to create debugfs entries: %ld\n",
- PTR_ERR(ips->debug_root));
+ dev_err(ips->dev, "failed to create debugfs entries\n")
return;
}
@@ -1325,8 +1324,7 @@ static void ips_debugfs_init(struct ips_driver *ips)
ips->debug_root, node,
&ips_debugfs_ops);
if (!ent) {
- dev_err(ips->dev, "failed to create debug file: %ld\n",
- PTR_ERR(ent));
+ dev_err(ips->dev, "failed to create debug file\n");
goto err_cleanup;
}
}
--
2.7.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 -next] platform/x86: intel-ips: fix 'passing zero to PTR_ERR()' warning
2018-11-26 13:19 [PATCH v2 -next] platform/x86: intel-ips: fix 'passing zero to PTR_ERR()' warning YueHaibing
@ 2018-11-26 13:37 ` Andy Shevchenko
2018-11-26 22:04 ` kbuild test robot
2018-12-02 5:01 ` kbuild test robot
2 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2018-11-26 13:37 UTC (permalink / raw)
To: YueHaibing; +Cc: dvhart, andy, jkosina, linux-kernel, platform-driver-x86
On Mon, Nov 26, 2018 at 09:19:48PM +0800, YueHaibing wrote:
> Fix a static code checker warning:
> drivers/platform/x86/intel_ips.c:1314
> ips_debugfs_init() warn: passing zero to 'PTR_ERR'
> drivers/platform/x86/intel_ips.c:1328
> ips_debugfs_init() warn: passing zero to 'PTR_ERR'
>
> If error occurs,debugfs_create_dir/debugfs_create_file
> return NULL while debugfs is enabled, which should not
> passing to PTR_ERR.
>
Thanks for a patch.
Though the better approach as Greg KH explained [1] is to get rid of unnecessary checks.
[1]: https://lkml.org/lkml/2015/8/15/114
> Fixes: aa7ffc01d254 ("x86 platform driver: intelligent power sharing driver")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
> v2:Fix typo in patch log and title
> ---
> drivers/platform/x86/intel_ips.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/platform/x86/intel_ips.c b/drivers/platform/x86/intel_ips.c
> index 225638a..a5d1a68 100644
> --- a/drivers/platform/x86/intel_ips.c
> +++ b/drivers/platform/x86/intel_ips.c
> @@ -1311,8 +1311,7 @@ static void ips_debugfs_init(struct ips_driver *ips)
>
> ips->debug_root = debugfs_create_dir("ips", NULL);
> if (!ips->debug_root) {
> - dev_err(ips->dev, "failed to create debugfs entries: %ld\n",
> - PTR_ERR(ips->debug_root));
> + dev_err(ips->dev, "failed to create debugfs entries\n")
> return;
> }
>
> @@ -1325,8 +1324,7 @@ static void ips_debugfs_init(struct ips_driver *ips)
> ips->debug_root, node,
> &ips_debugfs_ops);
> if (!ent) {
> - dev_err(ips->dev, "failed to create debug file: %ld\n",
> - PTR_ERR(ent));
> + dev_err(ips->dev, "failed to create debug file\n");
> goto err_cleanup;
> }
> }
> --
> 2.7.0
>
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 -next] platform/x86: intel-ips: fix 'passing zero to PTR_ERR()' warning
2018-11-26 13:19 [PATCH v2 -next] platform/x86: intel-ips: fix 'passing zero to PTR_ERR()' warning YueHaibing
2018-11-26 13:37 ` Andy Shevchenko
@ 2018-11-26 22:04 ` kbuild test robot
2018-12-02 5:01 ` kbuild test robot
2 siblings, 0 replies; 4+ messages in thread
From: kbuild test robot @ 2018-11-26 22:04 UTC (permalink / raw)
To: YueHaibing
Cc: kbuild-all, dvhart, andy, jkosina, linux-kernel,
platform-driver-x86, andriy.shevchenko, YueHaibing
[-- Attachment #1: Type: text/plain, Size: 3066 bytes --]
Hi YueHaibing,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on next-20181126]
url: https://github.com/0day-ci/linux/commits/YueHaibing/platform-x86-intel-ips-fix-passing-zero-to-PTR_ERR-warning/20181126-213205
config: x86_64-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All errors (new ones prefixed by >>):
>> drivers/platform/x86/intel_ips.c:1315:17: error: Expected ; at end of statement
>> drivers/platform/x86/intel_ips.c:1315:17: error: got return
vim +1315 drivers/platform/x86/intel_ips.c
aa7ffc01 Jesse Barnes 2010-05-14 1307
aa7ffc01 Jesse Barnes 2010-05-14 1308 static void ips_debugfs_init(struct ips_driver *ips)
aa7ffc01 Jesse Barnes 2010-05-14 1309 {
aa7ffc01 Jesse Barnes 2010-05-14 1310 int i;
aa7ffc01 Jesse Barnes 2010-05-14 1311
aa7ffc01 Jesse Barnes 2010-05-14 1312 ips->debug_root = debugfs_create_dir("ips", NULL);
aa7ffc01 Jesse Barnes 2010-05-14 1313 if (!ips->debug_root) {
895c026e YueHaibing 2018-11-26 1314 dev_err(ips->dev, "failed to create debugfs entries\n")
aa7ffc01 Jesse Barnes 2010-05-14 @1315 return;
aa7ffc01 Jesse Barnes 2010-05-14 1316 }
aa7ffc01 Jesse Barnes 2010-05-14 1317
aa7ffc01 Jesse Barnes 2010-05-14 1318 for (i = 0; i < ARRAY_SIZE(ips_debug_files); i++) {
aa7ffc01 Jesse Barnes 2010-05-14 1319 struct dentry *ent;
aa7ffc01 Jesse Barnes 2010-05-14 1320 struct ips_debugfs_node *node = &ips_debug_files[i];
aa7ffc01 Jesse Barnes 2010-05-14 1321
aa7ffc01 Jesse Barnes 2010-05-14 1322 node->ips = ips;
aa7ffc01 Jesse Barnes 2010-05-14 1323 ent = debugfs_create_file(node->name, S_IFREG | S_IRUGO,
aa7ffc01 Jesse Barnes 2010-05-14 1324 ips->debug_root, node,
aa7ffc01 Jesse Barnes 2010-05-14 1325 &ips_debugfs_ops);
aa7ffc01 Jesse Barnes 2010-05-14 1326 if (!ent) {
895c026e YueHaibing 2018-11-26 1327 dev_err(ips->dev, "failed to create debug file\n");
aa7ffc01 Jesse Barnes 2010-05-14 1328 goto err_cleanup;
aa7ffc01 Jesse Barnes 2010-05-14 1329 }
aa7ffc01 Jesse Barnes 2010-05-14 1330 }
aa7ffc01 Jesse Barnes 2010-05-14 1331
aa7ffc01 Jesse Barnes 2010-05-14 1332 return;
aa7ffc01 Jesse Barnes 2010-05-14 1333
aa7ffc01 Jesse Barnes 2010-05-14 1334 err_cleanup:
aa7ffc01 Jesse Barnes 2010-05-14 1335 ips_debugfs_cleanup(ips);
aa7ffc01 Jesse Barnes 2010-05-14 1336 return;
aa7ffc01 Jesse Barnes 2010-05-14 1337 }
aa7ffc01 Jesse Barnes 2010-05-14 1338 #endif /* CONFIG_DEBUG_FS */
aa7ffc01 Jesse Barnes 2010-05-14 1339
:::::: The code at line 1315 was first introduced by commit
:::::: aa7ffc01d254c91a36bf854d57a14049c6134c72 x86 platform driver: intelligent power sharing driver
:::::: TO: Jesse Barnes <jbarnes@virtuousgeek.org>
:::::: CC: Matthew Garrett <mjg@redhat.com>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 66875 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 -next] platform/x86: intel-ips: fix 'passing zero to PTR_ERR()' warning
2018-11-26 13:19 [PATCH v2 -next] platform/x86: intel-ips: fix 'passing zero to PTR_ERR()' warning YueHaibing
2018-11-26 13:37 ` Andy Shevchenko
2018-11-26 22:04 ` kbuild test robot
@ 2018-12-02 5:01 ` kbuild test robot
2 siblings, 0 replies; 4+ messages in thread
From: kbuild test robot @ 2018-12-02 5:01 UTC (permalink / raw)
To: YueHaibing
Cc: kbuild-all, dvhart, andy, jkosina, linux-kernel,
platform-driver-x86, andriy.shevchenko, YueHaibing
[-- Attachment #1: Type: text/plain, Size: 3098 bytes --]
Hi YueHaibing,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on next-20181126]
url: https://github.com/0day-ci/linux/commits/YueHaibing/platform-x86-intel-ips-fix-passing-zero-to-PTR_ERR-warning/20181126-213205
config: x86_64-rhel-7.2-clear (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All errors (new ones prefixed by >>):
drivers/platform/x86/intel_ips.c: In function 'ips_debugfs_init':
>> drivers/platform/x86/intel_ips.c:1315:3: error: expected ';' before 'return'
return;
^~~~~~
vim +1315 drivers/platform/x86/intel_ips.c
aa7ffc01 Jesse Barnes 2010-05-14 1307
aa7ffc01 Jesse Barnes 2010-05-14 1308 static void ips_debugfs_init(struct ips_driver *ips)
aa7ffc01 Jesse Barnes 2010-05-14 1309 {
aa7ffc01 Jesse Barnes 2010-05-14 1310 int i;
aa7ffc01 Jesse Barnes 2010-05-14 1311
aa7ffc01 Jesse Barnes 2010-05-14 1312 ips->debug_root = debugfs_create_dir("ips", NULL);
aa7ffc01 Jesse Barnes 2010-05-14 1313 if (!ips->debug_root) {
895c026e YueHaibing 2018-11-26 1314 dev_err(ips->dev, "failed to create debugfs entries\n")
aa7ffc01 Jesse Barnes 2010-05-14 @1315 return;
aa7ffc01 Jesse Barnes 2010-05-14 1316 }
aa7ffc01 Jesse Barnes 2010-05-14 1317
aa7ffc01 Jesse Barnes 2010-05-14 1318 for (i = 0; i < ARRAY_SIZE(ips_debug_files); i++) {
aa7ffc01 Jesse Barnes 2010-05-14 1319 struct dentry *ent;
aa7ffc01 Jesse Barnes 2010-05-14 1320 struct ips_debugfs_node *node = &ips_debug_files[i];
aa7ffc01 Jesse Barnes 2010-05-14 1321
aa7ffc01 Jesse Barnes 2010-05-14 1322 node->ips = ips;
aa7ffc01 Jesse Barnes 2010-05-14 1323 ent = debugfs_create_file(node->name, S_IFREG | S_IRUGO,
aa7ffc01 Jesse Barnes 2010-05-14 1324 ips->debug_root, node,
aa7ffc01 Jesse Barnes 2010-05-14 1325 &ips_debugfs_ops);
aa7ffc01 Jesse Barnes 2010-05-14 1326 if (!ent) {
895c026e YueHaibing 2018-11-26 1327 dev_err(ips->dev, "failed to create debug file\n");
aa7ffc01 Jesse Barnes 2010-05-14 1328 goto err_cleanup;
aa7ffc01 Jesse Barnes 2010-05-14 1329 }
aa7ffc01 Jesse Barnes 2010-05-14 1330 }
aa7ffc01 Jesse Barnes 2010-05-14 1331
aa7ffc01 Jesse Barnes 2010-05-14 1332 return;
aa7ffc01 Jesse Barnes 2010-05-14 1333
aa7ffc01 Jesse Barnes 2010-05-14 1334 err_cleanup:
aa7ffc01 Jesse Barnes 2010-05-14 1335 ips_debugfs_cleanup(ips);
aa7ffc01 Jesse Barnes 2010-05-14 1336 return;
aa7ffc01 Jesse Barnes 2010-05-14 1337 }
aa7ffc01 Jesse Barnes 2010-05-14 1338 #endif /* CONFIG_DEBUG_FS */
aa7ffc01 Jesse Barnes 2010-05-14 1339
:::::: The code at line 1315 was first introduced by commit
:::::: aa7ffc01d254c91a36bf854d57a14049c6134c72 x86 platform driver: intelligent power sharing driver
:::::: TO: Jesse Barnes <jbarnes@virtuousgeek.org>
:::::: CC: Matthew Garrett <mjg@redhat.com>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 41448 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-12-02 5:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-26 13:19 [PATCH v2 -next] platform/x86: intel-ips: fix 'passing zero to PTR_ERR()' warning YueHaibing
2018-11-26 13:37 ` Andy Shevchenko
2018-11-26 22:04 ` kbuild test robot
2018-12-02 5:01 ` kbuild test robot
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 NNTP newsgroup(s).