git: 2aad7570f4e1 - main - tzcode: Silence warnings.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 14 Jan 2023 17:20:08 UTC
The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=2aad7570f4e11ac94bb06c44cdc83ad1962fb97e commit 2aad7570f4e11ac94bb06c44cdc83ad1962fb97e Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2023-01-13 15:05:36 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> CommitDate: 2023-01-14 17:17:06 +0000 tzcode: Silence warnings. * Ignore failure to remove our temp file. * Avoid a minor memory leak in the -D case. Reported by: Coverity (CID 1502534, 1502535, 1502538) MFC after: 1 week Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D38038 --- contrib/tzcode/zic.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/contrib/tzcode/zic.c b/contrib/tzcode/zic.c index 812814b70cfa..c65282d46d27 100644 --- a/contrib/tzcode/zic.c +++ b/contrib/tzcode/zic.c @@ -661,7 +661,7 @@ close_file(FILE *stream, char const *dir, char const *name, name ? name : "", name ? ": " : "", e); if (tempname) - remove(tempname); + (void)remove(tempname); exit(EXIT_FAILURE); } } @@ -1418,7 +1418,7 @@ rename_dest(char *tempname, char const *name) if (tempname) { if (rename(tempname, name) != 0) { int rename_errno = errno; - remove(tempname); + (void)remove(tempname); fprintf(stderr, _("%s: rename to %s/%s: %s\n"), progname, directory, name, strerror(rename_errno)); exit(EXIT_FAILURE); @@ -3933,6 +3933,14 @@ mp = _("time zone abbreviation differs from POSIX standard"); static void mkdirs(char const *argname, bool ancestors) { + /* + * If -D was specified, do not create directories. A subsequent + * file operation will fail and produce an appropriate error + * message. + */ + if (Dflag) + return; + char *name = estrdup(argname); char *cp = name; @@ -3943,13 +3951,6 @@ mkdirs(char const *argname, bool ancestors) it can use slashes to separate the already-existing ancestor prefix from the to-be-created subdirectories. */ - /* - * If -D was specified, do not create directories. A subsequent - * file operation will fail and produce an appropriate error - * message. - */ - if (Dflag) - return; /* Do not mkdir a root directory, as it must exist. */ while (*cp == '/') cp++;