* [PATCH] kunit: update NULL vs IS_ERR() tests
@ 2022-10-14 9:37 Dan Carpenter
2022-10-14 15:17 ` Daniel Latypov
2022-10-15 3:56 ` David Gow
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2022-10-14 9:37 UTC (permalink / raw)
To: Brendan Higgins, David Gow
Cc: Daniel Latypov, Shuah Khan, linux-kselftest, kunit-dev,
kernel-janitors
The alloc_string_stream() functions were changed from returning NULL on
error to returning error pointers so these caller needs to be updated
as well.
Fixes: 78b1c6584fce ("kunit: string-stream: Simplify resource use")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
lib/kunit/string-stream.c | 4 ++--
lib/kunit/test.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/kunit/string-stream.c b/lib/kunit/string-stream.c
index f5ae79c37400..a608746020a9 100644
--- a/lib/kunit/string-stream.c
+++ b/lib/kunit/string-stream.c
@@ -56,8 +56,8 @@ int string_stream_vadd(struct string_stream *stream,
frag_container = alloc_string_stream_fragment(stream->test,
len,
stream->gfp);
- if (!frag_container)
- return -ENOMEM;
+ if (IS_ERR(frag_container))
+ return PTR_ERR(frag_container);
len = vsnprintf(frag_container->fragment, len, fmt, args);
spin_lock(&stream->lock);
diff --git a/lib/kunit/test.c b/lib/kunit/test.c
index 90640a43cf62..2a6992fe7c3e 100644
--- a/lib/kunit/test.c
+++ b/lib/kunit/test.c
@@ -265,7 +265,7 @@ static void kunit_fail(struct kunit *test, const struct kunit_loc *loc,
kunit_set_failure(test);
stream = alloc_string_stream(test, GFP_KERNEL);
- if (!stream) {
+ if (IS_ERR(stream)) {
WARN(true,
"Could not allocate stream to print failed assertion in %s:%d\n",
loc->file,
--
2.35.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] kunit: update NULL vs IS_ERR() tests
2022-10-14 9:37 [PATCH] kunit: update NULL vs IS_ERR() tests Dan Carpenter
@ 2022-10-14 15:17 ` Daniel Latypov
2022-10-15 3:56 ` David Gow
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Latypov @ 2022-10-14 15:17 UTC (permalink / raw)
To: Dan Carpenter
Cc: Brendan Higgins, David Gow, Shuah Khan, linux-kselftest,
kunit-dev, kernel-janitors
On Fri, Oct 14, 2022 at 2:37 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> The alloc_string_stream() functions were changed from returning NULL on
> error to returning error pointers so these caller needs to be updated
> as well.
>
> Fixes: 78b1c6584fce ("kunit: string-stream: Simplify resource use")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Daniel Latypov <dlatypov@google.com>
Thanks for catching this.
This patch seems like it updates the only (direct) callsite for each
of the funcs, so I think we're good once it goes in.
I also tested alloc_string_stream() failing, and the output looks good:
Could not allocate stream to print failed assertion in
lib/kunit/kunit-example-test.c:29
...
---[ end trace 0000000000000000 ]---
not ok 1 - example_simple_test
# example_skip_test: initializing
# example_skip_test: You should not see a line below.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] kunit: update NULL vs IS_ERR() tests
2022-10-14 9:37 [PATCH] kunit: update NULL vs IS_ERR() tests Dan Carpenter
2022-10-14 15:17 ` Daniel Latypov
@ 2022-10-15 3:56 ` David Gow
1 sibling, 0 replies; 3+ messages in thread
From: David Gow @ 2022-10-15 3:56 UTC (permalink / raw)
To: Dan Carpenter
Cc: Brendan Higgins, Daniel Latypov, Shuah Khan, linux-kselftest,
kunit-dev, kernel-janitors
On Fri, Oct 14, 2022 at 5:37 PM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> The alloc_string_stream() functions were changed from returning NULL on
> error to returning error pointers so these caller needs to be updated
> as well.
>
> Fixes: 78b1c6584fce ("kunit: string-stream: Simplify resource use")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
Thanks for catching this!
Reviewed-by: David Gow <davidgow@google.com>
Cheers,
-- David
> lib/kunit/string-stream.c | 4 ++--
> lib/kunit/test.c | 2 +-
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/lib/kunit/string-stream.c b/lib/kunit/string-stream.c
> index f5ae79c37400..a608746020a9 100644
> --- a/lib/kunit/string-stream.c
> +++ b/lib/kunit/string-stream.c
> @@ -56,8 +56,8 @@ int string_stream_vadd(struct string_stream *stream,
> frag_container = alloc_string_stream_fragment(stream->test,
> len,
> stream->gfp);
> - if (!frag_container)
> - return -ENOMEM;
> + if (IS_ERR(frag_container))
> + return PTR_ERR(frag_container);
>
> len = vsnprintf(frag_container->fragment, len, fmt, args);
> spin_lock(&stream->lock);
> diff --git a/lib/kunit/test.c b/lib/kunit/test.c
> index 90640a43cf62..2a6992fe7c3e 100644
> --- a/lib/kunit/test.c
> +++ b/lib/kunit/test.c
> @@ -265,7 +265,7 @@ static void kunit_fail(struct kunit *test, const struct kunit_loc *loc,
> kunit_set_failure(test);
>
> stream = alloc_string_stream(test, GFP_KERNEL);
> - if (!stream) {
> + if (IS_ERR(stream)) {
> WARN(true,
> "Could not allocate stream to print failed assertion in %s:%d\n",
> loc->file,
> --
> 2.35.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-15 3:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-14 9:37 [PATCH] kunit: update NULL vs IS_ERR() tests Dan Carpenter
2022-10-14 15:17 ` Daniel Latypov
2022-10-15 3:56 ` David Gow
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox