]> granicus.if.org Git - graphviz/commitdiff
common: squash spurious -Wconversion warnings in 'new_virtual_edge'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 8 May 2022 19:55:35 +0000 (12:55 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 4 Jun 2022 18:39:44 +0000 (11:39 -0700)
By doing these assignments all in a single line, the compiler was fooled into
believing there was some unintentional narrowing happening:

  fastgr.c: In function 'new_virtual_edge':
  ../../lib/common/types.h:592:22: warning: conversion from 'int' to 'short int'
    may change value [-Wconversion]
    592 | #define ED_weight(e) (((Agedgeinfo_t*)AGDATA(e))->weight)
        |                      ^
  fastgr.c:192:55: note: in expansion of macro 'ED_weight'
    192 |         ED_minlen(e) = ED_count(e) = ED_xpenalty(e) = ED_weight(e) = 1
        |                                                       ^~~~~~~~~
  ../../lib/common/types.h:569:21: warning: conversion to 'short unsigned int'
    from 'short int' may change the sign of the result [-Wsign-conversion]
    569 | #define ED_count(e) (((Agedgeinfo_t*)AGDATA(e))->count)
        |                     ^
  fastgr.c:192:24: note: in expansion of macro 'ED_count'
    192 |         ED_minlen(e) = ED_count(e) = ED_xpenalty(e) = ED_weight(e) = 1
        |                        ^~~~~~~~

We can make it clearer and avoid these warnings by separating the assignments.

lib/dotgen/fastgr.c

index 5608b5957a00acd90dff131059c0819665918515..c641d9de69e9d0713e26cb817f27cd1406e16b07 100644 (file)
@@ -188,8 +188,12 @@ edge_t *new_virtual_edge(node_t * u, node_t * v, edge_t * orig)
        if (ED_to_virt(orig) == NULL)
            ED_to_virt(orig) = e;
        ED_to_orig(e) = orig;
-    } else
-       ED_minlen(e) = ED_count(e) = ED_xpenalty(e) = ED_weight(e) = 1;
+    } else {
+       ED_weight(e) = 1;
+       ED_xpenalty(e) = 1;
+       ED_count(e) = 1;
+       ED_minlen(e) = 1;
+    }
     return e;
 }