diff mbox series

Use memset() to fill buffers in diotest

Message ID 20240227013727.1979300-1-sergeyu@google.com
State Accepted
Headers show
Series Use memset() to fill buffers in diotest | expand

Commit Message

Sergey Ulanov Feb. 27, 2024, 1:37 a.m. UTC
Previously fillbuf() was calling strncpy() for every byte in the buffer,
which is rather inefficient and was slowing down the tests.

Signed-off-by: Sergey Ulanov <sergeyu@google.com>
---
 testcases/kernel/io/direct_io/diotest_routines.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Comments

Cyril Hrubis Feb. 27, 2024, 10:35 a.m. UTC | #1
Hi!
Good catch, applied, thanks.
diff mbox series

Patch

diff --git a/testcases/kernel/io/direct_io/diotest_routines.c b/testcases/kernel/io/direct_io/diotest_routines.c
index fe03630ef..793572c37 100644
--- a/testcases/kernel/io/direct_io/diotest_routines.c
+++ b/testcases/kernel/io/direct_io/diotest_routines.c
@@ -55,11 +55,7 @@ 
 */
 void fillbuf(char *buf, int count, char value)
 {
-	while (count > 0) {
-		strncpy(buf, &value, 1);
-		buf++;
-		count = count - 1;
-	}
+	memset(buf, value, count);
 }
 
 void vfillbuf(struct iovec *iv, int vcnt, char value)