Skip to content

Commit

Permalink
kunit: update NULL vs IS_ERR() tests
Browse files Browse the repository at this point in the history
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: 78b1c65 ("kunit: string-stream: Simplify resource use")
Signed-off-by: Dan Carpenter <[email protected]>
Reviewed-by: Daniel Latypov <[email protected]>
Reviewed-by: David Gow <[email protected]>
Signed-off-by: Shuah Khan <[email protected]>
  • Loading branch information
Dan Carpenter authored and shuahkh committed Oct 18, 2022
1 parent 9abf231 commit 6188877
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/kunit/string-stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/kunit/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 6188877

Please sign in to comment.