]> granicus.if.org Git - graphviz/commitdiff
Resolve three Wsign-conversion in agxbuf.c
authorErwin Janssen <erwinjanssen@outlook.com>
Thu, 1 Sep 2016 12:55:19 +0000 (14:55 +0200)
committerErwin Janssen <erwinjanssen@outlook.com>
Thu, 1 Sep 2016 12:55:19 +0000 (14:55 +0200)
These three warnings could be resolved without making functional changes in the code. Also initialized the three local variables in this function to zero.

lib/cgraph/agxbuf.c

index 3b2bd3a7cfee923ce242a65b67a5cc7b26f9b0a9..a2a71df0109909cfe65579718a1ad19b0fa481eb 100644 (file)
@@ -43,16 +43,16 @@ void agxbinit(agxbuf * xb, unsigned int hint, unsigned char *init)
  */
 int agxbmore(agxbuf * xb, size_t ssz)
 {
-    size_t cnt;                        /* current no. of characters in buffer */
-    size_t size;               /* current buffer size */
-    size_t nsize;              /* new buffer size */
-    unsigned char *nbuf;       /* new buffer */
+    size_t cnt = 0;         /* current no. of characters in buffer */
+    size_t size = 0;        /* current buffer size */
+    size_t nsize = 0;       /* new buffer size */
+    unsigned char *nbuf;    /* new buffer */
 
-    size = xb->eptr - xb->buf;
+    size = (size_t) (xb->eptr - xb->buf);
     nsize = 2 * size;
-    if (size + (int)ssz > nsize)
+    if (size + ssz > nsize)
        nsize = size + ssz;
-    cnt = xb->ptr - xb->buf;
+    cnt = (size_t) (xb->ptr - xb->buf);
     if (xb->dyna) {
        nbuf = realloc(xb->buf, nsize);
     } else {