diff options
author | Richard Fitzgerald <rf@opensource.cirrus.com> | 2023-08-28 12:41:07 +0200 |
---|---|---|
committer | Shuah Khan <skhan@linuxfoundation.org> | 2023-09-18 18:45:35 +0200 |
commit | 20631e154c78f4140fffe111f5c79464fae3c38c (patch) | |
tree | fc8e4ffead49f1e3585cb102682c86fe86aee0ee /lib/kunit/string-stream.c | |
parent | kunit: Don't use a managed alloc in is_literal() (diff) | |
download | linux-20631e154c78f4140fffe111f5c79464fae3c38c.tar.xz linux-20631e154c78f4140fffe111f5c79464fae3c38c.zip |
kunit: string-stream: Add kunit_alloc_string_stream()
Add function kunit_alloc_string_stream() to do a resource-managed
allocation of a string stream, and corresponding
kunit_free_string_stream() to free the resource-managed stream.
This is preparing for decoupling the string_stream
implementation from struct kunit, to reduce the amount of code
churn when that happens. Currently:
- kunit_alloc_string_stream() only calls alloc_string_stream().
- kunit_free_string_stream() takes a struct kunit* which
isn't used yet.
Callers of the old alloc_string_stream() and
string_stream_destroy() are all requesting a managed allocation
so have been changed to use the new functions.
alloc_string_stream() has been temporarily made static because
its current behavior has been replaced with
kunit_alloc_string_stream().
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'lib/kunit/string-stream.c')
-rw-r--r-- | lib/kunit/string-stream.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/kunit/string-stream.c b/lib/kunit/string-stream.c index 1dcf6513b692..12ecf15e1f6b 100644 --- a/lib/kunit/string-stream.c +++ b/lib/kunit/string-stream.c @@ -153,7 +153,7 @@ bool string_stream_is_empty(struct string_stream *stream) return list_empty(&stream->fragments); } -struct string_stream *alloc_string_stream(struct kunit *test, gfp_t gfp) +static struct string_stream *alloc_string_stream(struct kunit *test, gfp_t gfp) { struct string_stream *stream; @@ -173,3 +173,13 @@ void string_stream_destroy(struct string_stream *stream) { string_stream_clear(stream); } + +struct string_stream *kunit_alloc_string_stream(struct kunit *test, gfp_t gfp) +{ + return alloc_string_stream(test, gfp); +} + +void kunit_free_string_stream(struct kunit *test, struct string_stream *stream) +{ + string_stream_destroy(stream); +} |