]> granicus.if.org Git - graphviz/commitdiff
remove some -Wcast-qual compiler warnings
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 27 Jun 2020 21:24:58 +0000 (14:24 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 27 Jun 2020 21:24:58 +0000 (14:24 -0700)
30 files changed:
cmd/lefty/ws/x11/libfilereq/Dir.c
cmd/lefty/ws/x11/libfilereq/Path.c
cmd/smyrna/gui/frmobjectui.c
cmd/smyrna/viewport.c
cmd/tools/colxlate.c
cmd/tools/graphml2gv.c
lib/ast/chrtoi.c
lib/ast/error.c
lib/ast/fmtesc.c
lib/ast/pathfind.c
lib/common/colxlate.c
lib/common/textspan.c
lib/common/utils.c
lib/dotgen/aspect.c
lib/fdpgen/layout.c
lib/gvc/gvdevice.c
lib/gvc/gvplugin.c
lib/gvc/gvrender.c
lib/gvpr/actions.c
lib/gvpr/gprstate.c
lib/neatogen/adjust.c
lib/neatogen/overlap.c
lib/neatogen/quad_prog_solve.c
lib/pack/pack.c
lib/sfdpgen/Multilevel.c
lib/sfdpgen/spring_electrical.c
lib/sfio/sfopen.c
lib/sfio/sfscanf.c
lib/sfio/sfwrite.c
lib/sparse/general.c

index 1159c4eff8771ce7ed343dcc608af6fc400bf46a..bef83ae0dd9842863712a660c899a0bb2cbcdf5d 100644 (file)
@@ -94,7 +94,7 @@ int SFcompareEntries (const void *vp, const void *vq) {
 }
 #else /* def SEL_FILE_IGNORE_CASE */
 int SFcompareEntries (const void *vp, const void *vq) {
-    SFEntry *p = (SFEntry *) vp, *q = (SFEntry *) vq;
+    const SFEntry *p = (const SFEntry *) vp, *q = (const SFEntry *) vq;
 
     return strcmp (p->real, q->real);
 }
index e8cd8ee51b2989d7dcdaab8e9cfaa9ba9d0eb0d3..b55823ee19c5903339cf88dfe99a191b3d3416ea 100644 (file)
@@ -342,7 +342,7 @@ static void SFunselect (void) {
 }
 
 static int SFcompareLogins (const void *vp, const void *vq) {
-    SFLogin *p = (SFLogin *) vp, *q = (SFLogin *) vq;
+    const SFLogin *p = (const SFLogin *) vp, *q = (const SFLogin *) vq;
 
     return strcmp (p->name, q->name);
 }
index b64543a1586f51cd55d3711c9d37173a7b4707d6..1d90ddcfc96c3776ce9f0aca2c50de46d3650606 100644 (file)
@@ -210,8 +210,8 @@ void print_attr_list(attr_list * l)
 
 int attr_compare(const void *a, const void *b)
 {
-    attr_t *a1 = *(attr_t **) a;
-    attr_t *a2 = *(attr_t **) b;
+    const attr_t *a1 = *(attr_t *const *) a;
+    const attr_t *a2 = *(attr_t *const *) b;
     return STRCASECMP(a1->name, a2->name);
 }
 
index 09929b72652a595dbc9cbc4d238abb0df3a95bd3..371ebfc3f8670167417e69d85a945ecece2bbbd9 100644 (file)
@@ -763,7 +763,7 @@ static md5_state_t pms;
 
 static int append_to_md5(void *chan, const char *str)
 {
-    md5_append(&pms, (unsigned char *) str, (int) strlen(str));
+    md5_append(&pms, (const unsigned char *) str, (int) strlen(str));
     return 1;
 
 }
index fc4f2625979711991c7b6aea9b1e0d85783b9443..5b650e21625745a62cdc3411e0ff0d58e6976834 100644 (file)
@@ -62,8 +62,8 @@ static unsigned char *canoncolor(char *orig, unsigned char *out)
 
 static int colorcmpf(const void *a0, const void *a1)
 {
-    hsbcolor_t *p0 = (hsbcolor_t *) a0;
-    hsbcolor_t *p1 = (hsbcolor_t *) a1;
+    const hsbcolor_t *p0 = (const hsbcolor_t *) a0;
+    const hsbcolor_t *p1 = (const hsbcolor_t *) a1;
     int i = (p0->name[0] - p1->name[0]);
     return (i ? i : strcmp(p0->name, p1->name));
 }
index ea7df59ad6cbbfb18598e24d3b36870de8ce4b3f..b82aeac51ae6278c46704afa104554204d2cf746 100644 (file)
@@ -498,7 +498,7 @@ startElementHandler(void *userData, const char *name, const char **atts)
            head = tname;
 
         if (G == 0)
-            fprintf(stderr,"edge source %s target %s outside graph, ignored\n",(char*)tail,(char*)head);
+            fprintf(stderr,"edge source %s target %s outside graph, ignored\n",tail,head);
         else {
             bind_edge(tail, head);
 
index e479c4d3e271f867b57d06ca91259c625695e83f..80cbc670410e0b745bf7ddc812673a9022e4470c 100644 (file)
@@ -29,7 +29,7 @@ int chrtoi(register const char *s)
 
     c = 0;
     for (n = 0; n < sizeof(int) * CHAR_BIT; n += CHAR_BIT) {
-       switch (x = *((unsigned char *) s++)) {
+       switch (x = *((const unsigned char *) s++)) {
        case '\\':
            x = chresc(s - 1, &p);
            s = (const char *) p;
index e8522ef8418d7203698f37dfcf17b49552259d3a..85bc2d206a089bbdfa49bb07761312182bcabd96 100644 (file)
@@ -42,7 +42,7 @@ void setTraceLevel (int i) { error_info.trace = i; }
 
 void errorv(const char *id, int level, va_list ap)
 {
-    char *s;
+    const char *s;
     int flags;
 
     if (level < error_info.trace) return;
@@ -52,7 +52,7 @@ void errorv(const char *id, int level, va_list ap)
        flags = level & ~ERROR_LEVEL;
        level &= ERROR_LEVEL;
     }
-    if (level && ((s = error_info.id) || (s = (char *) id))) {
+    if (level && ((s = error_info.id) || (s = id))) {
        if (flags & ERROR_USAGE)
            sfprintf(sfstderr, "Usage: %s ", s);
        else
index c4490603db7c796ea53cbbeffc285cbf1519d74c..655727286d73d05aca05dd3c8e4f6cd1a0340a5b 100644 (file)
@@ -35,8 +35,8 @@
 char *fmtquote(const char *as, const char *qb, const char *qe, size_t n,
               int flags)
 {
-    register unsigned char *s = (unsigned char *) as;
-    register unsigned char *e = s + n;
+    register const unsigned char *s = (const unsigned char *) as;
+    register const unsigned char *e = s + n;
     register char *b;
     register int c;
     register int escaped;
@@ -47,9 +47,9 @@ char *fmtquote(const char *as, const char *qb, const char *qe, size_t n,
 
     c = 4 * (n + 1);
     if (qb)
-       c += strlen((char *) qb);
+       c += strlen(qb);
     if (qe)
-       c += strlen((char *) qe);
+       c += strlen(qe);
     b = buf = fmtbuf(c);
     shell = 0;
     if (qb) {
@@ -152,7 +152,7 @@ char *fmtquote(const char *as, const char *qb, const char *qe, size_t n,
 
 char *fmtesq(const char *as, const char *qs)
 {
-    return fmtquote(as, NiL, qs, strlen((char *) as), 0);
+    return fmtquote(as, NiL, qs, strlen(as), 0);
 }
 
 /*
@@ -161,5 +161,5 @@ char *fmtesq(const char *as, const char *qs)
 
 char *fmtesc(const char *as)
 {
-    return fmtquote(as, NiL, NiL, strlen((char *) as), 0);
+    return fmtquote(as, NiL, NiL, strlen(as), 0);
 }
index 67af018ee1acd3f61014fdd7bcd878a1f336880c..85e7e665b5fd03dd2d0b8a20a64e270f809146ef 100644 (file)
@@ -77,7 +77,7 @@ char *pathfind(const char *name, const char *lib, const char *type,
            }
        }
        if (lib) {
-           if ((s = strrchr((char *) lib, ':')))
+           if ((s = strrchr(lib, ':')))
                lib = (const char *) s + 1;
            sfsprintf(tmp, sizeof(tmp), "lib/%s/%s", lib, name);
            if (pathpath(buf, tmp, "", PATH_REGULAR))
index a0dbc7dbd57c9612a042de44cc723e9279ffe131..4cf3af144c2807ee9611444923930f11fa4a652f 100644 (file)
@@ -139,7 +139,7 @@ static void rgb2cmyk(double r, double g, double b, double *c, double *m,
 
 static int colorcmpf(const void *p0, const void *p1)
 {
-    return strcasecmp(((hsvrgbacolor_t *) p0)->name, ((hsvrgbacolor_t *) p1)->name);
+    return strcasecmp(((const hsvrgbacolor_t *) p0)->name, ((const hsvrgbacolor_t *) p1)->name);
 }
 
 char *canontoken(char *str)
index 5799a26c4e4cbcda7a19a4604addcf7017b75648..3f3f446052d9543d7559b8af59c52f126d6d97af 100644 (file)
@@ -175,7 +175,7 @@ static PostscriptAlias postscript_alias[] = {
 
 static int fontcmpf(const void *a, const void *b)
 {
-    return (strcasecmp(((PostscriptAlias*)a)->name, ((PostscriptAlias*)b)->name));
+    return (strcasecmp(((const PostscriptAlias*)a)->name, ((const PostscriptAlias*)b)->name));
 }
 
 static PostscriptAlias* translate_postscript_fontname(char* fontname)
index c574ddc0e0044a6dc2e11729349bd28bd7810b88..75b4763724054e563ef450e538cabb792d38b347 100644 (file)
@@ -1342,7 +1342,7 @@ safe_dcl(graph_t * g, int obj_kind, char *name, char *def)
 }
 
 static int comp_entities(const void *e1, const void *e2) {
-  return strcmp(((struct entities_s *)e1)->name, ((struct entities_s *)e2)->name);
+  return strcmp(((const struct entities_s *)e1)->name, ((const struct entities_s *)e2)->name);
 }
 
 #define MAXENTLEN 8
index 39678a0a0399ee3abd0cd5ffa1e767001066316a..de6fb368dfa449cd58dee5111be067bb61d2c631 100644 (file)
@@ -276,8 +276,8 @@ static void computeLayerWidths(graph_t * g)
  */
 static int compFunction(const void *a, const void *b)
 {
-    int *ind1 = (int *) a;
-    int *ind2 = (int *) b;
+    const int *ind1 = (const int *) a;
+    const int *ind2 = (const int *) b;
 
     return (layerWidthInfo[*ind2].width >
            layerWidthInfo[*ind1].width) - (layerWidthInfo[*ind2].width <
@@ -357,7 +357,8 @@ static int compFunction2(const void *a, const void *b)
  */
 static int compFunction3(const void *a, const void *b)
 {
-    nodeGroup_t **ind1 = (nodeGroup_t **) a, **ind2 = (nodeGroup_t **) b;
+    const nodeGroup_t **ind1 = (const nodeGroup_t **) a,
+                      **ind2 = (const nodeGroup_t **) b;
     if ((*ind2)->height == (*ind1)->height)
        return ((*ind2)->width < (*ind1)->width) - ((*ind2)->width >
                                                    (*ind1)->width);
index 68bddba079d8b322854788ff6cb449585b50158f..24d9a0e71464e64f373297085ed19c6e607e0cf6 100644 (file)
@@ -588,8 +588,8 @@ static graph_t *deriveGraph(graph_t * g, layout_info * infop)
  */
 static int ecmp(const void *v1, const void *v2)
 {
-    erec *e1 = (erec *) v1;
-    erec *e2 = (erec *) v2;
+    const erec *e1 = (const erec *) v1;
+    const erec *e2 = (const erec *) v2;
     if (e1->alpha > e2->alpha)
        return 1;
     else if (e1->alpha < e2->alpha)
index bc5e5fd06d683063d6b14161270beb32538c4818..1375207d08e60dc98d8d68b8ec87ea0f3f46308f 100644 (file)
@@ -214,7 +214,7 @@ size_t gvwrite (GVJ_t * job, const char *s, size_t len)
            }
        }
 
-       crc = crc32(crc, (unsigned char*)s, len);
+       crc = crc32(crc, (const unsigned char*)s, len);
 
        z->next_in = (unsigned char*)s;
        z->avail_in = len;
index 083dbf74cd0f83b2d39bb8d4bbfdbce8367d7b65..e2bb1dd8194dade35e49414690e79be9b5c4409e 100644 (file)
@@ -207,7 +207,7 @@ gvplugin_library_t *gvplugin_library_load(GVC_t * gvc, char *path)
             agerr(AGWARN, "Could not load \"%s\" - %s\n", p, "It was found, so perhaps one of its dependents was not.  Try ldd.");
         }
         else {
-            agerr(AGWARN, "Could not load \"%s\" - %s\n", p, (char *) lt_dlerror());
+            agerr(AGWARN, "Could not load \"%s\" - %s\n", p, lt_dlerror());
         }
         return NULL;
     }
index 4b18aea0569d86c555a16086a0a5212aa49e2703..38d6b09980bda421bef3c43ee303d35b40c65c74 100644 (file)
@@ -185,7 +185,7 @@ pointf *gvrender_ptf_A(GVJ_t * job, pointf * af, pointf * AF, int n)
 
 static int gvrender_comparestr(const void *s1, const void *s2)
 {
-    return strcmp(*(char **) s1, *(char **) s2);
+    return strcmp(*(char *const *) s1, *(char *const *) s2);
 }
 
 /* gvrender_resolve_color:
index 2d45f9bf724b0ae08dc6dde97a89bf3d39b6346c..28829f062f92a006e2f951ba6889bd7420d9f684 100644 (file)
@@ -932,7 +932,7 @@ static void rgb2cmyk(double r, double g, double b, double *c, double *m,
 
 static int colorcmpf(const void *p0, const void *p1)
 {
-    return strcasecmp(((hsvrgbacolor_t *) p0)->name, ((hsvrgbacolor_t *) p1)->name);
+    return strcasecmp(((const hsvrgbacolor_t *) p0)->name, ((const hsvrgbacolor_t *) p1)->name);
 }
 
 static char *canontoken(char *str)
index 0a02819813c4bdda2c9d001211ea1b0f6a6293e7..d380c3758113725af71deaf831ae65fa8ce3b105 100644 (file)
@@ -71,7 +71,7 @@ Gpr_t *openGPRState(gpr_info* info)
 static int
 bindingcmpf (const void *key, const void *ip)
 {
-    return strcmp (((gvprbinding*)key)->name, ((gvprbinding*)ip)->name);
+    return strcmp (((const gvprbinding*)key)->name, ((const gvprbinding*)ip)->name);
 }
 
 /* findBinding:
index b1ce739b80653a7aa402e7b89adf315b58f9d755..a83a26c7b8b23d4258494a54215c8f2c927a91cc 100644 (file)
@@ -197,10 +197,10 @@ static int makeInfo(Agraph_t * graph)
 /* sort sites on y, then x, coord */
 static int scomp(const void *S1, const void *S2)
 {
-    Site *s1, *s2;
+    const Site *s1, *s2;
 
-    s1 = *(Site **) S1;
-    s2 = *(Site **) S2;
+    s1 = *(Site *const *) S1;
+    s2 = *(Site *const *) S2;
     if (s1->coord.y < s2->coord.y)
        return (-1);
     if (s1->coord.y > s2->coord.y)
index 62044cec04b62513fa68dc66bc5473b1b9082d73..e5133df0bcdc7b07d934c7b8166f9f9f721831d5 100644 (file)
@@ -89,8 +89,8 @@ typedef struct scan_point_struct scan_point;
 
 
 static int comp_scan_points(const void *p, const void *q){
-  scan_point *pp = (scan_point *) p;
-  scan_point *qq = (scan_point *) q;
+  const scan_point *pp = (const scan_point *) p;
+  const scan_point *qq = (const scan_point *) q;
   if (pp->x > qq->x){
     return 1;
   } else if (pp->x < qq->x){
@@ -119,9 +119,9 @@ static int NodeComp(const void* a,const void* b) {
 }
 
 static void NodePrint(const void* a) {
-  scan_point *aa;
+  const scan_point *aa;
 
-  aa = (scan_point *) a;
+  aa = (const scan_point *) a;
   fprintf(stderr, "node {%d, %f, %d}\n", aa->node, aa->x, aa->status);
 
 }
index 969eeb9680454d880feb61feb78c31a55bc87bda..f8748a92196ee68911dc166805e9d86ff68eff48 100644 (file)
@@ -407,9 +407,9 @@ constrained_majorization_new(CMajEnv * e, float *b, float **coords,
 static float *place;
 static int compare_incr(const void *a, const void *b)
 {
-    if (place[*(int *) a] > place[*(int *) b]) {
+    if (place[*(const int *) a] > place[*(const int *) b]) {
        return 1;
-    } else if (place[*(int *) a] < place[*(int *) b]) {
+    } else if (place[*(const int *) a] < place[*(const int *) b]) {
        return -1;
     }
     return 0;
index 63f66ff17f6f3d08928c12342783b2798ef73585..396df0e660aff7349ee9e5ca17c6578ef5ba8023 100644 (file)
@@ -98,8 +98,8 @@ static int computeStep(int ng, boxf* bbs, unsigned int margin)
  */
 static int cmpf(const void *X, const void *Y)
 {
-    ginfo *x = *(ginfo **) X;
-    ginfo *y = *(ginfo **) Y;
+    const ginfo *x = *(ginfo *const *) X;
+    const ginfo *y = *(ginfo *const *) Y;
     /* flip order to get descending array */
     return (y->perim - x->perim);
 }
@@ -569,8 +569,8 @@ static packval_t* userVals;
  */
 static int ucmpf(const void *X, const void *Y)
 {
-    ainfo* x = *(ainfo **) X;
-    ainfo* y = *(ainfo **) Y;
+    const ainfo* x = *(ainfo *const *) X;
+    const ainfo* y = *(ainfo *const *) Y;
 
     int dX = userVals[x->index];
     int dY = userVals[y->index];
@@ -584,8 +584,8 @@ static int ucmpf(const void *X, const void *Y)
  */
 static int acmpf(const void *X, const void *Y)
 {
-    ainfo* x = *(ainfo **) X;
-    ainfo* y = *(ainfo **) Y;
+    const ainfo* x = *(ainfo *const *) X;
+    const ainfo* y = *(ainfo *const *) Y;
 #if 0
     if (x->height < y->height) return 1;
     else if (x->height > y->height) return -1;
index 2e3e4ee213ac5bad9864711d3e4cb297464ecf79..16597b46f27f6aeb59f375ec344255f1402290a5 100644 (file)
@@ -629,9 +629,9 @@ static void maximal_independent_edge_set_heavest_edge_pernode_supernodes_first(S
 }
 
 static int scomp(const void *s1, const void *s2){
-  real *ss1, *ss2;
-  ss1 = (real*) s1;
-  ss2 = (real*) s2;
+  const real *ss1, *ss2;
+  ss1 = (const real*) s1;
+  ss2 = (const real*) s2;
 
   if ((ss1)[1] > (ss2)[1]){
     return -1;
index 608bc62ff2e1e26906407d3957c85b5317957f10..d0c4d48942a3f9d74ced48372db9062aae29aa94 100644 (file)
@@ -353,8 +353,8 @@ static real get_angle(real *x, int dim, int i, int j){
 }
 
 static int comp_real(const void *x, const void *y){
-  real *xx = (real*) x;
-  real *yy = (real*) y;
+  const real *xx = (const real*) x;
+  const real *yy = (const real*) y;
 
   if (*xx > *yy){
     return 1;
index 17605c1c0c77027541d33ecb1316c185e5e477aa..aa791d4008f15dc757c6772de68ad3afc4d4e4c7 100644 (file)
@@ -74,14 +74,14 @@ Sfio_t *sfopen(reg Sfio_t * f, const char *file, const char *mode)
 #endif
     if (sflags & SF_STRING) {
        f = sfnew(f, (char *) file,
-                 file ? (size_t) strlen((char *) file) : (size_t)
+                 file ? (size_t) strlen(file) : (size_t)
                  SF_UNBOUND, -1, sflags);
     } else {
        if (!file)
            return NIL(Sfio_t *);
 
 #if _has_oflags                        /* open the file */
-       while ((fd = open((char *) file, oflags, SF_CREATMODE)) < 0
+       while ((fd = open(file, oflags, SF_CREATMODE)) < 0
               && errno == EINTR)
            errno = 0;
 #else
index 089838d0ed98555d3ebea7ec0c5b832f4d4d0d3c..f4bfc41cb7093a86a7c1ea2fed7d3985efd2b64e 100644 (file)
@@ -40,7 +40,7 @@ int sfvsscanf(const char *s, const char *form, va_list args)
     f.flags = SF_STRING | SF_READ;
     f.bits = SF_PRIVATE;
     f.mode = SF_READ;
-    f.size = strlen((char *) s);
+    f.size = strlen(s);
     f.data = f.next = f.endw = (uchar *) s;
     f.endb = f.endr = f.data + f.size;
 
index d6d0527dfa20c28f6b805c0f16e4e6117db5e84d..f7f115d727fc2d9bc87f6e220e83fa045784e3db 100644 (file)
@@ -41,8 +41,8 @@ ssize_t sfwrite(reg Sfio_t * f, const void * buf, reg size_t n)
        if (!(f->mode & SF_WRITE) && (f->flags & SF_RDWR) != SF_RDWR)
            SFMTXRETURN(f, (ssize_t) (-1));
 
-       if ((uchar *) buf != f->next &&
-           (!f->rsrv || f->rsrv->data != (uchar *) buf))
+       if ((const uchar *) buf != f->next &&
+           (!f->rsrv || f->rsrv->data != (const uchar *) buf))
            SFMTXRETURN(f, (ssize_t) (-1));
 
        f->mode &= ~SF_PEEK;
index 9204d29ce2ea3d62e6594a7560a1fcd410126c6e..cadfba37ab291df7aa32960004e18cbc9d068b03 100644 (file)
@@ -156,9 +156,9 @@ void vector_float_take(int n, float *v, int m, int *p, float **u){
 }
 
 static int comp_ascend(const void *s1, const void *s2){
-  real *ss1, *ss2;
-  ss1 = (real*) s1;
-  ss2 = (real*) s2;
+  const real *ss1, *ss2;
+  ss1 = (const real*) s1;
+  ss2 = (const real*) s2;
 
   if ((ss1)[0] > (ss2)[0]){
     return 1;
@@ -169,9 +169,9 @@ static int comp_ascend(const void *s1, const void *s2){
 }
 
 static int comp_descend(const void *s1, const void *s2){
-  real *ss1, *ss2;
-  ss1 = (real*) s1;
-  ss2 = (real*) s2;
+  const real *ss1, *ss2;
+  ss1 = (const real*) s1;
+  ss2 = (const real*) s2;
 
   if ((ss1)[0] > (ss2)[0]){
     return -1;
@@ -181,9 +181,9 @@ static int comp_descend(const void *s1, const void *s2){
   return 0;
 }
 static int comp_descend_int(const void *s1, const void *s2){
-  int *ss1, *ss2;
-  ss1 = (int*) s1;
-  ss2 = (int*) s2;
+  const int *ss1, *ss2;
+  ss1 = (const int*) s1;
+  ss2 = (const int*) s2;
 
   if ((ss1)[0] > (ss2)[0]){
     return -1;
@@ -194,9 +194,9 @@ static int comp_descend_int(const void *s1, const void *s2){
 }
 
 static int comp_ascend_int(const void *s1, const void *s2){
-  int *ss1, *ss2;
-  ss1 = (int*) s1;
-  ss2 = (int*) s2;
+  const int *ss1, *ss2;
+  ss1 = (const int*) s1;
+  ss2 = (const int*) s2;
 
   if ((ss1)[0] > (ss2)[0]){
     return 1;