]> granicus.if.org Git - graphviz/commitdiff
dotgen: squash -Wsign-conversion warning in 'doDot'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 8 May 2022 20:02:31 +0000 (13:02 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 25 May 2022 14:27:22 +0000 (07:27 -0700)
The compiler says:

  dotinit.c: In function 'doDot':
  dotinit.c:454:24: warning: conversion to 'unsigned int' from 'int' may change
    the sign of the result [-Wsign-conversion]
  454 |         pinfo.margin = Pack;
      |                        ^~~~

But from the surrounding code and the implementation of `getPack`, we can
statically determine that `Pack` is non-negative at this point.

lib/dotgen/dotinit.c

index e4d086368ee90b27b7e600d20d190dde76ed1594..f9b24f121e49dca1fb4b34e1823e401fb2d1534d 100644 (file)
@@ -8,7 +8,7 @@
  * Contributors: Details at https://graphviz.org
  *************************************************************************/
 
-
+#include <assert.h>
 #include <time.h>
 #include <dotgen/dot.h>
 #include <pack/pack.h>
@@ -451,7 +451,8 @@ static void doDot (Agraph_t* g)
            pinfo.mode = l_graph;
        else if (Pack < 0)
            Pack = CL_OFFSET;
-       pinfo.margin = Pack;
+       assert(Pack >= 0);
+       pinfo.margin = (unsigned)Pack;
        pinfo.fixed = NULL;
 
           /* components using clusters */