From owner-svn-src-stable-11@freebsd.org Tue Jul 18 08:35:24 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 57825CFC24B; Tue, 18 Jul 2017 08:35:24 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 341EE65458; Tue, 18 Jul 2017 08:35:24 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v6I8ZN6j036857; Tue, 18 Jul 2017 08:35:23 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v6I8ZNJZ036854; Tue, 18 Jul 2017 08:35:23 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201707180835.v6I8ZNJZ036854@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Tue, 18 Jul 2017 08:35:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r321121 - stable/11/usr.bin/localedef X-SVN-Group: stable-11 X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: stable/11/usr.bin/localedef X-SVN-Commit-Revision: 321121 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Jul 2017 08:35:24 -0000 Author: ngie Date: Tue Jul 18 08:35:22 2017 New Revision: 321121 URL: https://svnweb.freebsd.org/changeset/base/321121 Log: MFC r318257,r318278: r318257: style(9): sort headers r318278: Mark errf _Noreturn, and mark errf and warn __printflike The _Noreturn attribute was added to placate Coverity and other static analysis tools. The __printflike attribute was added to catch issues with the calls related to printf(3) abuse. - Modify the code to facilitate the __printflike attribute addition. - Convert errf calls in to_mb(..) and to_mb_string(..) to warn(..) so the calls will return instead of exiting, as the code suggests it should. Modified: stable/11/usr.bin/localedef/localedef.c stable/11/usr.bin/localedef/localedef.h stable/11/usr.bin/localedef/wide.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/localedef/localedef.c ============================================================================== --- stable/11/usr.bin/localedef/localedef.c Tue Jul 18 08:33:29 2017 (r321120) +++ stable/11/usr.bin/localedef/localedef.c Tue Jul 18 08:35:22 2017 (r321121) @@ -119,7 +119,7 @@ open_category(void) */ file = fopen(category_file(), "w"); if (file == NULL) { - errf(strerror(errno)); + errf("%s", strerror(errno)); return (NULL); } return (file); @@ -131,11 +131,11 @@ close_category(FILE *f) if (fchmod(fileno(f), 0644) < 0) { (void) fclose(f); (void) unlink(category_file()); - errf(strerror(errno)); + errf("%s", strerror(errno)); } if (fclose(f) < 0) { (void) unlink(category_file()); - errf(strerror(errno)); + errf("%s", strerror(errno)); } if (verbose) { (void) fprintf(stdout, "done.\n"); @@ -195,13 +195,13 @@ putl_category(const char *s, FILE *f) if (s && fputs(s, f) == EOF) { (void) fclose(f); (void) unlink(category_file()); - errf(strerror(errno)); + errf("%s", strerror(errno)); return (EOF); } if (fputc('\n', f) == EOF) { (void) fclose(f); (void) unlink(category_file()); - errf(strerror(errno)); + errf("%s", strerror(errno)); return (EOF); } return (0); @@ -216,7 +216,7 @@ wr_category(void *buf, size_t sz, FILE *f) if (fwrite(buf, sz, 1, f) < 1) { (void) fclose(f); (void) unlink(category_file()); - errf(strerror(errno)); + errf("%s", strerror(errno)); return (EOF); } return (0); @@ -331,7 +331,7 @@ main(int argc, char **argv) while ((dir = opendir(locname)) == NULL) { if ((errno != ENOENT) || (mkdir(locname, 0755) < 0)) { - errf(strerror(errno)); + errf("%s", strerror(errno)); } } (void) closedir(dir); Modified: stable/11/usr.bin/localedef/localedef.h ============================================================================== --- stable/11/usr.bin/localedef/localedef.h Tue Jul 18 08:33:29 2017 (r321120) +++ stable/11/usr.bin/localedef/localedef.h Tue Jul 18 08:35:22 2017 (r321121) @@ -35,10 +35,11 @@ */ /* Common header files. */ +#include +#include +#include #include #include -#include -#include extern int com_char; extern int esc_char; @@ -54,8 +55,8 @@ extern int warnings; int yylex(void); void yyerror(const char *); -void errf(const char *, ...); -void warn(const char *, ...); +_Noreturn void errf(const char *, ...) __printflike(1, 2); +void warn(const char *, ...) __printflike(1, 2); int putl_category(const char *, FILE *); int wr_category(void *, size_t, FILE *); Modified: stable/11/usr.bin/localedef/wide.c ============================================================================== --- stable/11/usr.bin/localedef/wide.c Tue Jul 18 08:33:29 2017 (r321120) +++ stable/11/usr.bin/localedef/wide.c Tue Jul 18 08:35:22 2017 (r321121) @@ -598,7 +598,7 @@ to_mb(char *mb, wchar_t wc) int rv; if ((rv = _tomb(mb, wc)) < 0) { - errf(widemsg); + warn("%s", widemsg); free(widemsg); widemsg = NULL; } @@ -614,7 +614,7 @@ to_mb_string(const wchar_t *wcs) mbs = malloc((wcslen(wcs) * mb_cur_max) + 1); if (mbs == NULL) { - errf("out of memory"); + warn("out of memory"); return (NULL); } ptr = mbs;