From 7eedf31af1197dea0f3a4ff4aa15c2d7581925bf Mon Sep 17 00:00:00 2001 From: ngie Date: Wed, 15 May 2019 07:51:30 +0000 Subject: [PATCH] MFC r320009,r347075: r320009 (by sbruno): Quiesce clang warning while building lpc. usr.sbin/lpr/lpc/lpc.c Warning passing 'char *[20]' to parameter of type 'const char **' discards qualifiers in nested pointer types [-Wincompatible-pointer-types-discards-qualifiers] Fix: Explicitly cast the variable "margv" to const char ** only for it's use as a parameter to suppress the error r347075: Fix `clang -Wcast-qual` issues Remove unnecessary `char*` casting for arguments passed to `cget*(3)`, and deconst `_PATH_PRINTCAP` before passing it to `cget*` via the `printcapdb` variable. This unblocks ^/projects/runtime-coverage-v2 from building cleanly on universe13a.freebsd.org. I suspect the issue was introduced through some changes to `bsd.*.mk` inclusion on the branch, which I will continue to investigate/isolate. Tested with: clang 8 (arm64) --- usr.sbin/lpr/common_source/printcap.c | 22 ++++++++-------------- usr.sbin/lpr/lpc/lpc.c | 2 +- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/usr.sbin/lpr/common_source/printcap.c b/usr.sbin/lpr/common_source/printcap.c index 707b7b824d9..15d044c688f 100644 --- a/usr.sbin/lpr/common_source/printcap.c +++ b/usr.sbin/lpr/common_source/printcap.c @@ -60,7 +60,7 @@ __FBSDID("$FreeBSD$"); /* * Routines and data used in processing the printcap file. */ -static char *printcapdb[2] = { _PATH_PRINTCAP, 0 }; /* list for cget* */ +static char *printcapdb[] = { __DECONST(char *, _PATH_PRINTCAP), NULL }; static char *capdb_canonical_name(const char *_bp); static int capdb_getaltlog(char *_bp, const char *_shrt, @@ -97,15 +97,9 @@ int getprintcap(const char *printer, struct printer *pp) { int status; - char *XXX; char *bp; - /* - * A bug in the declaration of cgetent(3) means that we have - * to hide the constness of its third argument. - */ - XXX = (char *)printer; - if ((status = cgetent(&bp, printcapdb, XXX)) < 0) + if ((status = cgetent(&bp, printcapdb, printer)) < 0) return status; status = getprintcap_int(bp, pp); free(bp); @@ -378,10 +372,10 @@ capdb_getaltstr(char *bp, const char *shrt, const char *lng, { int status; - status = cgetstr(bp, (char *)/*XXX*/lng, result); + status = cgetstr(bp, lng, result); if (status >= 0 || status == PCAPERR_OSERR) return status; - status = cgetstr(bp, (char *)/*XXX*/shrt, result); + status = cgetstr(bp, shrt, result); if (status >= 0 || status == PCAPERR_OSERR) return status; if (dflt) { @@ -402,10 +396,10 @@ capdb_getaltnum(char *bp, const char *shrt, const char *lng, long dflt, { int status; - status = cgetnum(bp, (char *)/*XXX*/lng, result); + status = cgetnum(bp, lng, result); if (status >= 0) return status; - status = cgetnum(bp, (char *)/*XXX*/shrt, result); + status = cgetnum(bp, shrt, result); if (status >= 0) return status; *result = dflt; @@ -419,9 +413,9 @@ capdb_getaltnum(char *bp, const char *shrt, const char *lng, long dflt, static int capdb_getaltlog(char *bp, const char *shrt, const char *lng) { - if (cgetcap(bp, (char *)/*XXX*/lng, ':')) + if (cgetcap(bp, lng, ':')) return 1; - if (cgetcap(bp, (char *)/*XXX*/shrt, ':')) + if (cgetcap(bp, shrt, ':')) return 1; return 0; } diff --git a/usr.sbin/lpr/lpc/lpc.c b/usr.sbin/lpr/lpc/lpc.c index 2be4c84d619..33fd0c54e63 100644 --- a/usr.sbin/lpr/lpc/lpc.c +++ b/usr.sbin/lpr/lpc/lpc.c @@ -197,7 +197,7 @@ cmdscanner(void) makeargv(); if (margc == 0) continue; - if (el != NULL && el_parse(el, margc, margv) != -1) + if (el != NULL && el_parse(el, margc, (const char **)margv) != -1) continue; c = getcmd(margv[0]); -- 2.45.0