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

Log:
  MFC 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/12/usr.sbin/lpr/common_source/printcap.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.sbin/lpr/common_source/printcap.c
==============================================================================
--- stable/12/usr.sbin/lpr/common_source/printcap.c     Wed May 15 07:51:30 
2019        (r347610)
+++ stable/12/usr.sbin/lpr/common_source/printcap.c     Wed May 15 07:51:35 
2019        (r347611)
@@ -62,7 +62,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,
@@ -99,15 +99,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);
@@ -380,10 +374,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) {
@@ -404,10 +398,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;
@@ -421,9 +415,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;
 }
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to