From 453fc14702f09299dd9745d31afff4007d0f76ae Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 1 Feb 2021 17:43:16 +0100 Subject: Eliminiate unncessary code if RETRY_SLEEP is nonpositive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- asroot.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/asroot.c b/asroot.c index 7db8eac..65bc16f 100644 --- a/asroot.c +++ b/asroot.c @@ -229,7 +229,10 @@ check_password(void) #ifndef WITH_LIBPASSPHRASE struct termios stty_original; #endif - struct termios stty_enter, stty_sleep; + struct termios stty_enter; +#if RETRY_SLEEP > 0 + struct termios stty_sleep; +#endif int fd; errno = 0; @@ -307,8 +310,10 @@ check_password(void) tcsetattr(fd, TCSAFLUSH, &stty_enter); #endif +#if RETRY_SLEEP > 0 memcpy(&stty_sleep, &stty_enter, sizeof(stty_enter)); stty_sleep.c_lflag = 0; +#endif again: fprintf(stderr, PROMPT); @@ -341,11 +346,11 @@ again: if (strcmp(got, expected)) { fprintf(stderr, "%s: incorrect password, please try again\n", argv0); - tcsetattr(fd, TCSAFLUSH, &stty_sleep); #if RETRY_SLEEP > 0 + tcsetattr(fd, TCSAFLUSH, &stty_sleep); sleep(RETRY_SLEEP); -#endif tcsetattr(fd, TCSAFLUSH, &stty_enter); +#endif goto again; } -- cgit v1.2.3-70-g09d2