]> granicus.if.org Git - graphviz/commitdiff
smyrna mTestgvpr: use a 'size_t' for 'argc'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 7 Sep 2022 03:56:37 +0000 (20:56 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 10 Sep 2022 00:11:28 +0000 (17:11 -0700)
This squashes a -Wsign-conversion warning. We need to cast back to `int` for
calling `gvpr`, but this is acceptable as the number of arguments cannot
practically exceed `INT_MAX`.

ci/clang_format.py
cmd/smyrna/gui/menucallbacks.c
cmd/smyrna/gvprpipe.c
cmd/smyrna/gvprpipe.h

index 69ff688003e534ade77729f72700115da8c9b5df..301f9a47e8d60bcd08be4045467c64dc7ae600b0 100644 (file)
@@ -69,7 +69,6 @@ EXCLUDE = (
   "cmd/smyrna/gui/topviewsettings.c",
   "cmd/smyrna/gui/topviewsettings.h",
   "cmd/smyrna/gvprpipe.c",
-  "cmd/smyrna/gvprpipe.h",
   "cmd/smyrna/hier.c",
   "cmd/smyrna/hier.h",
   "cmd/smyrna/hotkeymap.c",
index dcaa644738f260c3bacdb313692d36a011659eac..cc6f22d657aedd4728875236b74a402d12c6146e 100644 (file)
@@ -275,7 +275,7 @@ void mTestgvpr(GtkWidget * widget, gpointer user_data)
     GtkTextIter startit;
     GtkTextIter endit;
     const char *args;
-    int j, argc, cloneGraph;
+    int cloneGraph;
     char **argv;
 
     args =
@@ -294,7 +294,7 @@ void mTestgvpr(GtkWidget * widget, gpointer user_data)
        return;
     }
 
-    argc = 1;
+    size_t argc = 1;
     if (*args != '\0')
        argc += 2;
     if (*bf2 != '\0')
@@ -306,7 +306,7 @@ void mTestgvpr(GtkWidget * widget, gpointer user_data)
     } else
        cloneGraph = 0;
     argv = gv_calloc(argc + 1, sizeof(char*));
-    j = 0;
+    size_t j = 0;
     argv[j++] = "smyrna";
     if (cloneGraph)
        argv[j++] = "-C";
index 053c8f506902cdb91bdd456320aba0ba02ba8fa9..ea4a0a4be31506b34688a376fcf64d7e7668b5e8 100644 (file)
@@ -11,6 +11,7 @@
 #include "smyrnadefs.h"
 #include "gvprpipe.h"
 #include <common/const.h>
+#include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <assert.h>
@@ -36,8 +37,7 @@ static ssize_t outfn(void *sp, const char *buf, size_t nbyte, void *dp)
     return (ssize_t)nbyte;
 }
 
-int run_gvpr(Agraph_t * srcGraph, int argc, char *argv[])
-{
+int run_gvpr(Agraph_t * srcGraph, size_t argc, char *argv[]) {
     int i, rv = 1;
     gvpropts opts;
     Agraph_t *gs[2];
@@ -52,7 +52,8 @@ int run_gvpr(Agraph_t * srcGraph, int argc, char *argv[])
     opts.err = outfn;
     opts.flags = GV_USE_OUTGRAPH;
 
-    rv = gvpr(argc, argv, &opts);
+    assert(argc <= INT_MAX);
+    rv = gvpr((int)argc, argv, &opts);
 
     if (rv) {                  /* error */
        fprintf(stderr, "Error in gvpr\n");
index 2eca35ccdd7d866468a8918b18674f54f1a0bf6b..31cb140a1e0fa2837dfaecafa2048465dbac1f37 100644 (file)
@@ -1,5 +1,5 @@
 /*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
+ * Copyright (c) 2011 AT&T Intellectual Property
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -12,4 +12,4 @@
 
 #include <cgraph/cgraph.h>
 
-    extern int run_gvpr(Agraph_t * srcGraph, int argc, char *argv[]);
+extern int run_gvpr(Agraph_t *srcGraph, size_t argc, char *argv[]);