Skip to content

Commit 6188877

Browse files
Dan Carpentershuahkh
authored andcommitted
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. 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]>
1 parent 9abf231 commit 6188877

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/kunit/string-stream.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ int string_stream_vadd(struct string_stream *stream,
5656
frag_container = alloc_string_stream_fragment(stream->test,
5757
len,
5858
stream->gfp);
59-
if (!frag_container)
60-
return -ENOMEM;
59+
if (IS_ERR(frag_container))
60+
return PTR_ERR(frag_container);
6161

6262
len = vsnprintf(frag_container->fragment, len, fmt, args);
6363
spin_lock(&stream->lock);

lib/kunit/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ static void kunit_fail(struct kunit *test, const struct kunit_loc *loc,
265265
kunit_set_failure(test);
266266

267267
stream = alloc_string_stream(test, GFP_KERNEL);
268-
if (!stream) {
268+
if (IS_ERR(stream)) {
269269
WARN(true,
270270
"Could not allocate stream to print failed assertion in %s:%d\n",
271271
loc->file,

0 commit comments

Comments
 (0)