svn commit: r347610 - in stable/11/usr.sbin/lpr: common_source lpc

Enji Cooper ngie at FreeBSD.org
Wed May 15 07:51:31 UTC 2019


Author: ngie
Date: Wed May 15 07:51:30 2019
New Revision: 347610
URL: https://svnweb.freebsd.org/changeset/base/347610

Log:
  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)

Modified:
  stable/11/usr.sbin/lpr/common_source/printcap.c
  stable/11/usr.sbin/lpr/lpc/lpc.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.sbin/lpr/common_source/printcap.c
==============================================================================
--- stable/11/usr.sbin/lpr/common_source/printcap.c	Wed May 15 07:46:17 2019	(r347609)
+++ stable/11/usr.sbin/lpr/common_source/printcap.c	Wed May 15 07:51:30 2019	(r347610)
@@ -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
 {
 	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
 {
 	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
 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;
 }

Modified: stable/11/usr.sbin/lpr/lpc/lpc.c
==============================================================================
--- stable/11/usr.sbin/lpr/lpc/lpc.c	Wed May 15 07:46:17 2019	(r347609)
+++ stable/11/usr.sbin/lpr/lpc/lpc.c	Wed May 15 07:51:30 2019	(r347610)
@@ -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]);


More information about the svn-src-all mailing list