kunit: update NULL vs IS_ERR() tests
Subsystems (3)
PATCH 1/1 kunit: update NULL vs IS_ERR() tests
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.
--- lib/kunit/string-stream.c | 4 ++-- lib/kunit/test.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
lib/kunit/string-stream.c +2 -2
@@ -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);
lib/kunit/test.c +1 -1
@@ -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,
Signature · 1 line
2.35.1
Quoted 7 lines · Dan Carpenter
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 <[email protected]>
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.Quoted 8 lines · Dan Carpenter
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 <[email protected]>---
Thanks for catching this!
Cheers,
-- David
Quoted 35 lines
lib/kunit/string-stream.c | 4 ++-- lib/kunit/test.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)lib/kunit/string-stream.c +2
-2@@ -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);lib/kunit/test.c +1
-2@@ -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