public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Sergey Ulanov via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Cc: Sergey Ulanov <sergeyu@google.com>
Subject: [LTP] [PATCH] Use memset() to fill buffers in diotest
Date: Tue, 27 Feb 2024 01:37:27 +0000	[thread overview]
Message-ID: <20240227013727.1979300-1-sergeyu@google.com> (raw)

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(-)

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)
-- 
2.44.0.rc1.240.g4c46232300-goog


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

             reply	other threads:[~2024-02-27 10:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-27  1:37 Sergey Ulanov via ltp [this message]
2024-02-27 10:35 ` [LTP] [PATCH] Use memset() to fill buffers in diotest Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240227013727.1979300-1-sergeyu@google.com \
    --to=ltp@lists.linux.it \
    --cc=sergeyu@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox