[PATCH 5/5] commandhelper: printCwd: Print result directly instead of copying it

Peter Krempa pkrempa at redhat.com
Wed Mar 3 10:45:37 UTC 2021


Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 tests/commandhelper.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tests/commandhelper.c b/tests/commandhelper.c
index ee06339392..9b56feb120 100644
--- a/tests/commandhelper.c
+++ b/tests/commandhelper.c
@@ -221,9 +221,10 @@ static int printCwd(FILE *log)
     if (!(cwd = getcwd(NULL, 0)))
         return -1;

-    if ((strlen(cwd) > strlen(".../commanddata")) &&
-        (STREQ(cwd + strlen(cwd) - strlen("/commanddata"), "/commanddata"))) {
-        strcpy(cwd, ".../commanddata");
+    if ((display = strstr(cwd, "/commanddata")) &&
+        STREQ(display, "/commanddata")) {
+        fprintf(log, "CWD:.../commanddata\n");
+        return 0;
     }

     display = cwd;
-- 
2.29.2




More information about the libvir-list mailing list