From owner-dev-commits-src-all@freebsd.org Tue Jan 19 21:38:22 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BCB604E0894; Tue, 19 Jan 2021 21:38:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DL28G3DfBz4lY6; Tue, 19 Jan 2021 21:38:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 84FE45E09; Tue, 19 Jan 2021 21:38:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 10JLcL2d078514; Tue, 19 Jan 2021 21:38:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 10JLcLPW078513; Tue, 19 Jan 2021 21:38:21 GMT (envelope-from git) Date: Tue, 19 Jan 2021 21:38:21 GMT Message-Id: <202101192138.10JLcLPW078513@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alex Richardson Subject: git: 0348c8fcfaa2 - main - getopt: Fix conversion from string-literal to non-const char * MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0348c8fcfaa22d4f2bf548ad9c187c09ef90c533 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jan 2021 21:38:22 -0000 The branch main has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=0348c8fcfaa22d4f2bf548ad9c187c09ef90c533 commit 0348c8fcfaa22d4f2bf548ad9c187c09ef90c533 Author: Alex Richardson AuthorDate: 2021-01-19 11:35:04 +0000 Commit: Alex Richardson CommitDate: 2021-01-19 21:23:25 +0000 getopt: Fix conversion from string-literal to non-const char * Define a non-const static char EMSG[] = "" to avoid having to add __DECONST() to all uses of EMSG. Also make current_dash a const char * to fix this warning. --- lib/libc/stdlib/getopt.c | 3 +-- lib/libc/stdlib/getopt_long.c | 4 ++-- tools/build/mk/Makefile.boot | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/libc/stdlib/getopt.c b/lib/libc/stdlib/getopt.c index b6bdf8a1eeaf..b7f2229a2f54 100644 --- a/lib/libc/stdlib/getopt.c +++ b/lib/libc/stdlib/getopt.c @@ -54,8 +54,7 @@ char *optarg; /* argument associated with option */ #define BADCH (int)'?' #define BADARG (int)':' -#define EMSG "" - +static char EMSG[] = ""; /* * getopt -- * Parse argc/argv argument vector. diff --git a/lib/libc/stdlib/getopt_long.c b/lib/libc/stdlib/getopt_long.c index 4d92fd0cd45d..1f3548bef9ad 100644 --- a/lib/libc/stdlib/getopt_long.c +++ b/lib/libc/stdlib/getopt_long.c @@ -88,7 +88,7 @@ char *optarg; /* argument associated with option */ #define BADARG ((*options == ':') ? (int)':' : (int)'?') #define INORDER (int)1 -#define EMSG "" +static char EMSG[] = ""; #ifdef GNU_COMPATIBLE #define NO_PREFIX (-1) @@ -194,7 +194,7 @@ parse_long_options(char * const *nargv, const char *options, { char *current_argv, *has_equal; #ifdef GNU_COMPATIBLE - char *current_dash; + const char *current_dash; #endif size_t current_argv_len; int i, match, exact_match, second_partial_match; diff --git a/tools/build/mk/Makefile.boot b/tools/build/mk/Makefile.boot index 38df8135e53b..7ebbf726e7f2 100644 --- a/tools/build/mk/Makefile.boot +++ b/tools/build/mk/Makefile.boot @@ -41,6 +41,7 @@ CWARNFLAGS+= -Wno-typedef-redefinition # bsd.sys.mk explicitly turns on -Wsystem-headers, but that's extremely # noisy when building on Linux. CWARNFLAGS+= -Wno-system-headers +CWARNFLAGS.clang+=-Werror=incompatible-pointer-types-discards-qualifiers # b64_pton and b64_ntop is in libresolv on MacOS and Linux: # TODO: only needed for uuencode and uudecode