]> granicus.if.org Git - graphviz/commitdiff
gxl2gv characterDataHandler: squash -Wsign-conversion warnings
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 17 Sep 2021 04:22:08 +0000 (21:22 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 19 Sep 2021 23:21:06 +0000 (16:21 -0700)
cmd/tools/gxl2gv.c

index 4a5dcb6c14013cb1e4e179cbc6c9484df55955d7..758cd660fc152b061e39e142062edad31050856a 100644 (file)
@@ -8,7 +8,7 @@
  * Contributors: Details at https://graphviz.org
  *************************************************************************/
 
-
+#include    <assert.h>
 #include    "convert.h"
 #include    <cgraph/agxbuf.h>
 #ifdef HAVE_EXPAT
@@ -689,15 +689,18 @@ static void characterDataHandler(void *userData, const char *s, int length)
 {
     userdata_t *ud = userData;
 
+    assert(length >= 0 && "Expat returned negative length data");
+    size_t len = (size_t)length;
+
     if (!ud->listen)
        return;
 
     if (ud->compositeReadState) {
-       agxbput_n(&ud->composite_buffer, s, length);
+       agxbput_n(&ud->composite_buffer, s, len);
        return;
     }
 
-    agxbput_n(&ud->xml_attr_value, s, length);
+    agxbput_n(&ud->xml_attr_value, s, len);
 }
 
 Agraph_t *gxl_to_gv(FILE * gxlFile)