]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
commandhelper: printCwd: Print result directly instead of copying it
authorPeter Krempa <pkrempa@redhat.com>
Wed, 3 Mar 2021 10:36:22 +0000 (11:36 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 5 Mar 2021 14:33:34 +0000 (15:33 +0100)
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tests/commandhelper.c

index ee06339392f4c3cd1a8a0a7c51efe14e1fef52a8..9b56feb1202870d11be7df6be0c6e4a841609709 100644 (file)
@@ -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;