Skip to contentSkip to conversation

Use memset() to fill buffers in diotest

PATCH In review Sergey Ulanov via ltp 2 participants 2 messages Feb 27, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Use memset() to fill buffers in diotest

Previously fillbuf() was calling strncpy() for every byte in the buffer, which is rather inefficient and was slowing down the tests.

---
 testcases/kernel/io/direct_io/diotest_routines.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
testcases/kernel/io/direct_io/diotest_routines.c +1 -5
index fe03630ef..793572c37 100644
@@ -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)
Signature · 5 lines
2.44.0.rc1.240.g4c46232300-goog


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp