From 61ef9fdc4f826ce435bdfd0d0acdc3d81c3dcfb3 Mon Sep 17 00:00:00 2001 From: Lukas Dullinger <129603980+itislu@users.noreply.github.com> Date: Wed, 24 Jul 2024 14:25:55 +0200 Subject: [PATCH] style: Add macro for max input retries --- include/defines.h | 3 +++ source/utils/user_input_utils.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/defines.h b/include/defines.h index e1dce484..10692dc3 100644 --- a/include/defines.h +++ b/include/defines.h @@ -115,6 +115,9 @@ # define PT_ROW_NUM 192 # define UNDEFINED_STATE -1 +/* User Input */ +# define MAX_INPUT_RETRIES 5 + /* Export */ # define EXPORT_PREFIX "export " diff --git a/source/utils/user_input_utils.c b/source/utils/user_input_utils.c index 0bc892ce..7d0c191d 100644 --- a/source/utils/user_input_utils.c +++ b/source/utils/user_input_utils.c @@ -55,7 +55,7 @@ static bool limit_retries(t_sh *shell, bool success) retries = 0; return (true); } - else if (++retries > 5) + else if (++retries > MAX_INPUT_RETRIES) clean_and_exit_shell(shell, GENERAL_ERROR, "read input failed"); print_error("%s: read input failed, trying again...\n", PROGRAM_NAME); return (false);