From: Shlomi Fish Date: Mon, 4 Apr 2022 12:42:28 +0000 (+0300) Subject: Silence compiler/linter warnings of declared but unused variables. X-Git-Tag: fortune-mod-3.14.0~11 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f77085ad1c9137f84682fb3108d4e9847c0c3c62;p=fortune-mod Silence compiler/linter warnings of declared but unused variables. They are a distraction. --- diff --git a/fortune-mod/fortune/fortune.c b/fortune-mod/fortune/fortune.c index f2096ef..2e36724 100644 --- a/fortune-mod/fortune/fortune.c +++ b/fortune-mod/fortune/fortune.c @@ -143,7 +143,6 @@ typedef struct fd static const char *env_lang = NULL; -static bool Found_one = false; /* did we find a match? */ static bool Find_files = false; /* just find a list of proper fortune files */ static bool Wait = false; /* wait desired after fortune */ static bool Short_only = false; /* short fortune desired */ @@ -1714,7 +1713,7 @@ static int maxlen_in_list(FILEDESC *list) * matches_in_list * Print out the matches from the files in the list. */ -static void matches_in_list(FILEDESC *list) +static void matches_in_list(FILEDESC *list, bool *const Found_one_ptr) { unsigned char *sp; unsigned char *p; /* -allover */ @@ -1727,7 +1726,7 @@ static void matches_in_list(FILEDESC *list) { if (fp->child) { - matches_in_list(fp->child); + matches_in_list(fp->child, Found_one_ptr); continue; } DPRINTF(1, (stderr, "searching in %s\n", fp->path)); @@ -1778,7 +1777,7 @@ static void matches_in_list(FILEDESC *list) { fprintf( stderr, "(%s)\n%c\n", fp->name, fp->tbl.str_delim); - Found_one = true; + (*Found_one_ptr) = true; in_file = true; } fputs(output, stdout); @@ -1802,15 +1801,15 @@ static void matches_in_list(FILEDESC *list) * Find all the fortunes which match the pattern we've been * given. */ -static int find_matches(void) +static bool find_matches(void) { Fort_len = maxlen_in_list(File_list); DPRINTF(2, (stderr, "Maximum length is %d\n", Fort_len)); /* extra length, "%\n" is appended */ Fortbuf = do_malloc((unsigned int)Fort_len + 10); - Found_one = false; - matches_in_list(File_list); + bool Found_one = false; + matches_in_list(File_list, &Found_one); return Found_one; /* NOTREACHED */ } @@ -1966,7 +1965,7 @@ int main(int argc, char *argv[]) #ifdef WITH_REGEX if (Match) { - exit_code = (find_matches() != 0); + exit_code = (find_matches() != false); regfree(&Re_pat); goto cleanup; }