From: Peter Krempa Date: Wed, 3 Mar 2021 10:36:22 +0000 (+0100) Subject: commandhelper: printCwd: Print result directly instead of copying it X-Git-Tag: v7.2.0-rc1~212 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=479f92ae16246076bfad623954706b15daabd7df;p=thirdparty%2Flibvirt.git commandhelper: printCwd: Print result directly instead of copying it Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- 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;