From 23703c75da502bf75ceca483040d7e298014334d Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Mon, 6 Jun 2016 18:15:47 +0200 Subject: [PATCH] tests/dir.c: Remove nested checker function Move nested check function is_startup_config() outside main(). Signed-off-by: Joachim Nilsson --- tests/dir.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/tests/dir.c b/tests/dir.c index d9bb8b5..38f16f2 100644 --- a/tests/dir.c +++ b/tests/dir.c @@ -39,28 +39,29 @@ static int cfg_dir_filter(const char *file) return ! !strcmp(file, STARTUP_CONFIG); } +static int is_startup_config(const char *entry) +{ + static int once = 1; + static char file[80]; + + if (once) { + int len = readlink(STARTUP_CONFIG, file, sizeof(file)); + + if (len == -1) + return 0; + + file[len] = 0; + once = 0; /* Only once per call to dir() */ + } + //printf ("Comparing link %s with entry %s\n", file, entry); + return !strcmp(file, entry); +} + int main(int argc, char *argv[]) { int i, num; char *type = DIR_TYPE_CONFIG; char **files; - int once = 1; - - int is_startup_config(const char *entry) { - static char file[80]; - - if (once) { - int len = readlink(STARTUP_CONFIG, file, sizeof(file)); - - if (len == -1) - return 0; - - file[len] = 0; - once = 0; /* Only once per call to dir() */ - } - //printf ("Comparing link %s with entry %s\n", file, entry); - return !strcmp(file, entry); - } simulate_files(1);