summaryrefslogtreecommitdiff
path: root/lib/kunit/string-stream.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-08-17 19:44:06 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2026-08-17 19:44:06 -0700
commitfd89b0be5503dbbbdbd53c8158ea6ba0e57357fc (patch)
tree07f204cfef318924a07eeca0959abb70fe1d2970 /lib/kunit/string-stream.c
parentfc8c78bce3335860ff4ae9fcfd3b2eb1f674efbb (diff)
parentdea754ded9518b51740c417d2c1e02ff540784c6 (diff)
downloadlinux-fd89b0be5503dbbbdbd53c8158ea6ba0e57357fc.tar.gz
linux-fd89b0be5503dbbbdbd53c8158ea6ba0e57357fc.zip
Merge tag 'linux_kselftest-kunit-7.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
Pull kunit updates from Shuah Khan: "Fixes and new kunit and tools, enable new configs: - configs: enable GPIO kunit test cases in all_tests.config - string-stream: Replace strlcat() with strscpy() and seq_buf - configs: enable GPIO kunit test cases in all_tests.config Documentation: - Test config entries shouldn't select other configs - Fix outdated FAQ entries Add the ability to skip entire test suites and an example test suite that can be skipped at runtime: - Add ability to skip entire test suites - Add example of test suite that can be skipped at runtime" * tag 'linux_kselftest-kunit-7.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: kunit: tool: fix _list_tests filtering wrong variable when list has TAP prefix kunit: configs: enable GPIO kunit test cases in all_tests.config kunit: string-stream: Replace strlcat() with strscpy() and seq_buf Documentation: kunit: Fix outdated FAQ entries Documentation: kunit: Test Kconfig entries shouldn't select other configs kunit: Add example of test suite that can be skipped at runtime kunit,rust: Add ability to skip entire test suites
Diffstat (limited to 'lib/kunit/string-stream.c')
-rw-r--r--lib/kunit/string-stream.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/kunit/string-stream.c b/lib/kunit/string-stream.c
index 0d8f1b30559b..51ba40ebf19f 100644
--- a/lib/kunit/string-stream.c
+++ b/lib/kunit/string-stream.c
@@ -9,6 +9,7 @@
#include <kunit/static_stub.h>
#include <kunit/test.h>
#include <linux/list.h>
+#include <linux/seq_buf.h>
#include <linux/slab.h>
#include "string-stream.h"
@@ -74,7 +75,8 @@ int string_stream_vadd(struct string_stream *stream,
/* Append newline if necessary. */
if (frag_container->fragment[result_len - 1] != '\n')
- result_len = strlcat(frag_container->fragment, "\n", buf_len);
+ result_len += strscpy(frag_container->fragment + result_len,
+ "\n", buf_len - result_len);
} else {
result_len = vsnprintf(frag_container->fragment, buf_len, fmt, args);
}
@@ -118,15 +120,18 @@ char *string_stream_get_string(struct string_stream *stream)
{
struct string_stream_fragment *frag_container;
size_t buf_len = stream->length + 1; /* +1 for null byte. */
+ struct seq_buf sb;
char *buf;
buf = kzalloc(buf_len, stream->gfp);
if (!buf)
return NULL;
+ seq_buf_init(&sb, buf, buf_len);
+
spin_lock(&stream->lock);
list_for_each_entry(frag_container, &stream->fragments, node)
- strlcat(buf, frag_container->fragment, buf_len);
+ seq_buf_puts(&sb, frag_container->fragment);
spin_unlock(&stream->lock);
return buf;