From 479f92ae16246076bfad623954706b15daabd7df Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 3 Mar 2021 11:36:22 +0100 Subject: [PATCH] commandhelper: printCwd: Print result directly instead of copying it Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- 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;