[pve-devel] [PATCH mini-journalreader v2 5/5] use memcpy/cmp instead of strncpy/cmp

Dominik Csapak d.csapak at proxmox.com
Thu May 16 12:22:19 CEST 2019


faster since it does not have to look for '\0'

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/mini-journalreader.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mini-journalreader.c b/src/mini-journalreader.c
index 3be348e..d5c55fd 100644
--- a/src/mini-journalreader.c
+++ b/src/mini-journalreader.c
@@ -91,12 +91,12 @@ static void print_reboot(sd_journal *j) {
 
     static char bootid[32];
     if (bootid[0] != '\0') { // we have some bootid
-        if (strncmp(bootid, d, l)) { // a new bootid found
-            strncpy(bootid, d, l);
+        if (memcmp(bootid, d, l)) { // a new bootid found
+            memcpy(bootid, d, l);
             print_to_buf("-- Reboot --\n", 13);
         }
     } else {
-        strncpy(bootid, d, l);
+        memcpy(bootid, d, l);
     }
 }
 
-- 
2.11.0





More information about the pve-devel mailing list