kunit: string-stream: Simplify resource use

Currently, KUnit's string streams are themselves "KUnit resources".
This is redundant since the stream itself is already allocated with
kunit_kzalloc() and will thus be freed automatically at the end of the
test.

string-stream is only used internally within KUnit, and isn't using the
extra features that resources provide like reference counting, being
able to locate them dynamically as "test-local variables", etc.

Indeed, the resource's refcount is never incremented when the
pointer is returned. The fact that it's always manually destroyed is
more evidence that the reference counting is unused.

Signed-off-by: David Gow <davidgow@google.com>
Signed-off-by: Daniel Latypov <dlatypov@google.com>
Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
This commit is contained in:
David Gow
2022-07-22 17:15:30 +00:00
committed by Shuah Khan
parent 4e37057387
commit 78b1c6584f
3 changed files with 24 additions and 82 deletions
+1 -1
View File
@@ -46,6 +46,6 @@ int string_stream_append(struct string_stream *stream,
bool string_stream_is_empty(struct string_stream *stream);
int string_stream_destroy(struct string_stream *stream);
void string_stream_destroy(struct string_stream *stream);
#endif /* _KUNIT_STRING_STREAM_H */