* [PATCH] kunit: debugfs: Use IS_ERR() for alloc_string_stream() error check
@ 2024-11-14 16:55 Kuan-Wei Chiu
2024-11-15 21:26 ` David Gow
0 siblings, 1 reply; 2+ messages in thread
From: Kuan-Wei Chiu @ 2024-11-14 16:55 UTC (permalink / raw)
To: brendanhiggins, davidgow
Cc: rmoar, ruanjinjie, jserv, linux-kselftest, kunit-dev,
linux-kernel, Kuan-Wei Chiu
The alloc_string_stream() function only returns ERR_PTR(-ENOMEM) on
failure and never returns NULL. Therefore, switching the error check in
the caller from IS_ERR_OR_NULL to IS_ERR improves clarity, indicating
that this function will return an error pointer (not NULL) when an
error occurs. This change avoids any ambiguity regarding the function's
return behavior.
Link: https://lore.kernel.org/lkml/Zy9deU5VK3YR+r9N@visitorckw-System-Product-Name
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
---
lib/kunit/debugfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/kunit/debugfs.c b/lib/kunit/debugfs.c
index d548750a325a..6273fa9652df 100644
--- a/lib/kunit/debugfs.c
+++ b/lib/kunit/debugfs.c
@@ -181,7 +181,7 @@ void kunit_debugfs_create_suite(struct kunit_suite *suite)
* successfully.
*/
stream = alloc_string_stream(GFP_KERNEL);
- if (IS_ERR_OR_NULL(stream))
+ if (IS_ERR(stream))
return;
string_stream_set_append_newlines(stream, true);
@@ -189,7 +189,7 @@ void kunit_debugfs_create_suite(struct kunit_suite *suite)
kunit_suite_for_each_test_case(suite, test_case) {
stream = alloc_string_stream(GFP_KERNEL);
- if (IS_ERR_OR_NULL(stream))
+ if (IS_ERR(stream))
goto err;
string_stream_set_append_newlines(stream, true);
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] kunit: debugfs: Use IS_ERR() for alloc_string_stream() error check
2024-11-14 16:55 [PATCH] kunit: debugfs: Use IS_ERR() for alloc_string_stream() error check Kuan-Wei Chiu
@ 2024-11-15 21:26 ` David Gow
0 siblings, 0 replies; 2+ messages in thread
From: David Gow @ 2024-11-15 21:26 UTC (permalink / raw)
To: Kuan-Wei Chiu
Cc: brendanhiggins, rmoar, ruanjinjie, jserv, linux-kselftest,
kunit-dev, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1671 bytes --]
On Fri, 15 Nov 2024 at 00:56, Kuan-Wei Chiu <visitorckw@gmail.com> wrote:
>
> The alloc_string_stream() function only returns ERR_PTR(-ENOMEM) on
> failure and never returns NULL. Therefore, switching the error check in
> the caller from IS_ERR_OR_NULL to IS_ERR improves clarity, indicating
> that this function will return an error pointer (not NULL) when an
> error occurs. This change avoids any ambiguity regarding the function's
> return behavior.
>
> Link: https://lore.kernel.org/lkml/Zy9deU5VK3YR+r9N@visitorckw-System-Product-Name
> Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
> --
Makes sense to me, thanks.
Reviewed-by: David Gow <davidgow@google.com>
Cheers,
-- David
> lib/kunit/debugfs.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/kunit/debugfs.c b/lib/kunit/debugfs.c
> index d548750a325a..6273fa9652df 100644
> --- a/lib/kunit/debugfs.c
> +++ b/lib/kunit/debugfs.c
> @@ -181,7 +181,7 @@ void kunit_debugfs_create_suite(struct kunit_suite *suite)
> * successfully.
> */
> stream = alloc_string_stream(GFP_KERNEL);
> - if (IS_ERR_OR_NULL(stream))
> + if (IS_ERR(stream))
> return;
>
> string_stream_set_append_newlines(stream, true);
> @@ -189,7 +189,7 @@ void kunit_debugfs_create_suite(struct kunit_suite *suite)
>
> kunit_suite_for_each_test_case(suite, test_case) {
> stream = alloc_string_stream(GFP_KERNEL);
> - if (IS_ERR_OR_NULL(stream))
> + if (IS_ERR(stream))
> goto err;
>
> string_stream_set_append_newlines(stream, true);
> --
> 2.34.1
>
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5294 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-11-15 21:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-14 16:55 [PATCH] kunit: debugfs: Use IS_ERR() for alloc_string_stream() error check Kuan-Wei Chiu
2024-11-15 21:26 ` David Gow
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox