From 39582e0f264bf7e69c647f126c418a878b56bfa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Wed, 19 Jul 2017 19:11:52 +0200 Subject: [PATCH] CLI: Use printf return to compute string size instead of hardcoded values --- cli/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cli/main.c b/cli/main.c index a2a4e20..98a6765 100644 --- a/cli/main.c +++ b/cli/main.c @@ -81,19 +81,19 @@ static void signal_handler(int signum) static void display_password(char* password, int time) { - int length; + int print_len = 0; for (; time && !s_stop_display; time--) { - printf("\r(%02d) Password found: %s", time, password); + print_len = printf("\r(%02d) Password found: %s", time, password); fflush(stdout); sleep(1); } // Clear line + print_len++; // For C or Z printf("\r"); - length = 4 + 17 + strlen(password) + 1 + 1 /* For Ctrl+Z/C */; - while (length--) + while (print_len--) printf(" "); printf("\n"); }