]> granicus.if.org Git - graphviz/commitdiff
swap assertion in setattr for a call to UNREACHABLE
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 20 Jun 2021 21:11:33 +0000 (14:11 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 26 Jun 2021 16:42:17 +0000 (09:42 -0700)
This removes some -Wstring-conversion warnings when building with Clang, due to
the expression `!"unreachable"`. It also teaches the compiler it can more
aggressively optimize this switch.

lib/cgraph/attr.c

index 7a8ce5aea883d7f063bd87bf16b5d7c1c9b76234..2e09f873bbffc12b11c1144d3c0e149deed29cb7 100644 (file)
@@ -9,6 +9,7 @@
  *************************************************************************/
 
 #include       <cgraph/cghdr.h>
+#include       <cgraph/unreachable.h>
 #include       <stddef.h>
 
 /*
@@ -292,8 +293,7 @@ static Agsym_t *setattr(Agraph_t * g, int kind, char *name, char *value)
                        addattr(g, (Agobj_t *) e, rsym);
                break;
            default:
-               assert(!"unreachable");
-               break;
+               UNREACHABLE();
            }
            rv = rsym;
        }