Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kunit: drop test pointer in string_stream_fragment

We already store the `struct kunit *test` in the string_stream object
itself, so we need don't need to store a copy of this pointer in every
fragment in the stream.

Drop it, getting string_stream_fragment down the bare minimum: a
list_head and the `char *` with the actual fragment.

Signed-off-by: Daniel Latypov <dlatypov@google.com>
Reviewed-by: David Gow <davidgow@google.com>
Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Daniel Latypov and committed by
Shuah Khan
4db4598b 78b1c658

+5 -6
+5 -5
lib/kunit/string-stream.c
··· 22 22 if (!frag) 23 23 return ERR_PTR(-ENOMEM); 24 24 25 - frag->test = test; 26 25 frag->fragment = kunit_kmalloc(test, len, gfp); 27 26 if (!frag->fragment) 28 27 return ERR_PTR(-ENOMEM); ··· 29 30 return frag; 30 31 } 31 32 32 - static void string_stream_fragment_destroy(struct string_stream_fragment *frag) 33 + static void string_stream_fragment_destroy(struct kunit *test, 34 + struct string_stream_fragment *frag) 33 35 { 34 36 list_del(&frag->node); 35 - kunit_kfree(frag->test, frag->fragment); 36 - kunit_kfree(frag->test, frag); 37 + kunit_kfree(test, frag->fragment); 38 + kunit_kfree(test, frag); 37 39 } 38 40 39 41 int string_stream_vadd(struct string_stream *stream, ··· 89 89 frag_container_safe, 90 90 &stream->fragments, 91 91 node) { 92 - string_stream_fragment_destroy(frag_container); 92 + string_stream_fragment_destroy(stream->test, frag_container); 93 93 } 94 94 stream->length = 0; 95 95 spin_unlock(&stream->lock);
-1
lib/kunit/string-stream.h
··· 14 14 #include <linux/stdarg.h> 15 15 16 16 struct string_stream_fragment { 17 - struct kunit *test; 18 17 struct list_head node; 19 18 char *fragment; 20 19 };