]> granicus.if.org Git - graphviz/commitdiff
fix: return -2 on error in seg_cmp and remove now unused longjmp path
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 24 Apr 2021 03:10:42 +0000 (20:10 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 14 May 2021 00:03:36 +0000 (17:03 -0700)
Related to #1801. This removes two (accurate) warnings about possible clobbered
variables in orthoEdges.

lib/ortho/ortho.c

index 7926b5929a540d1d9ed73734c0bdb7532e487fbf..463b7b776c07617f43d6ef0b1a397d0af000f88c 100644 (file)
@@ -25,7 +25,6 @@
 #include <assert.h>
 #include <stdbool.h>
 #include <stddef.h>
-#include <setjmp.h>
 #include <ortho/maze.h>
 #include <ortho/fPQ.h>
 #include <ortho/ortho.h>
@@ -39,8 +38,6 @@ typedef struct {
     Agedge_t* e;
 } epair_t;
 
-static jmp_buf jbuf;
-
 #ifdef DEBUG
 static void emitSearchGraph (FILE* fp, sgraph* sg);
 static void emitGraph (FILE* fp, maze* mp, size_t n_edges, route* route_list, epair_t[]);
@@ -723,6 +720,7 @@ segCmp (segment* S1, segment* S2, bend T1, bend T2)
  *   0 if a crossing is unavoidable or there is no crossing at all or 
  *     the segments are parallel,
  *   1 if S1 HAS TO BE to the left/above S2 to avoid a crossing
+ *  -2 if S1 and S2 are incomparable
  *
  * Note: This definition means horizontal segments have track numbers
  * increasing as y decreases, while vertical segments have track numbers
@@ -737,7 +735,7 @@ seg_cmp(segment* S1, segment* S2)
 {
     if(S1->isVert!=S2->isVert||S1->comm_coord!=S2->comm_coord) {
        agerr (AGERR, "incomparable segments !! -- Aborting\n");
-       longjmp(jbuf, 1);
+       return -2;
     }
     if(S1->isVert)
        return segCmp (S1, S2, B_RIGHT, B_LEFT);
@@ -1365,8 +1363,6 @@ orthoEdges (Agraph_t* g, int doLbls)
     mp->hchans = extractHChans (mp);
     mp->vchans = extractVChans (mp);
     assignSegs (n_edges, route_list, mp);
-    if (setjmp(jbuf))
-       goto orthofinish;
     if (assignTracks(mp) != 0)
        goto orthofinish;
 #ifdef DEBUG