From: Tobias Stoeckmann Date: Thu, 19 Sep 2024 20:10:17 +0000 (+0200) Subject: lib: Eliminate dead code X-Git-Tag: 4.17.0-rc1~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e6a5484cedb674b09a46aafe3b1f8901fde62349;p=thirdparty%2Fshadow.git lib: Eliminate dead code The tz function is only called if ENV_TZ starts with a slash. If the specified file cannot be read, the code implies that ENV_TZ would be returned if it does not start with a slash. Since we know that it DOES start with a slash, the code can be simplified to state that "TZ=CST6CDT" is returned as a default if the specified file cannot be read. Benefit of this change is that strcpy's use case here can be easier verified. Signed-off-by: Tobias Stoeckmann --- diff --git a/lib/tz.c b/lib/tz.c index 9506a8b16..b854a593b 100644 --- a/lib/tz.c +++ b/lib/tz.c @@ -32,27 +32,23 @@ /*@observer@*/const char *tz (const char *fname) { FILE *fp = NULL; + const char *result; static char tzbuf[BUFSIZ]; - const char *def_tz = "TZ=CST6CDT"; fp = fopen (fname, "r"); if ( (NULL == fp) || (fgets (tzbuf, sizeof (tzbuf), fp) == NULL)) { - def_tz = getdef_str ("ENV_TZ"); - if ((NULL == def_tz) || ('/' == def_tz[0])) { - def_tz = "TZ=CST6CDT"; - } - - strcpy (tzbuf, def_tz); + result = "TZ=CST6CDT"; } else { stpsep(tzbuf, "\n"); + result = tzbuf; } if (NULL != fp) { (void) fclose (fp); } - return tzbuf; + return result; } #else /* !USE_PAM */ extern int ISO_C_forbids_an_empty_translation_unit;