From 64416806c9c036623b0629984fc909ef33aecc11 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 13 Aug 2022 08:44:44 -0700 Subject: [PATCH] core plugin: replace 'assert(0)' with 'UNREACHABLE()' The latter is more robust and clearer in intent. --- plugin/core/gvrender_core_fig.c | 3 ++- plugin/core/gvrender_core_map.c | 10 ++++------ plugin/core/gvrender_core_mp.c | 3 ++- plugin/core/gvrender_core_svg.c | 7 ++++--- plugin/core/gvrender_core_tk.c | 6 +++--- plugin/core/gvrender_core_vml.c | 5 +++-- 6 files changed, 18 insertions(+), 16 deletions(-) diff --git a/plugin/core/gvrender_core_fig.c b/plugin/core/gvrender_core_fig.c index 661f91b45..58454f355 100644 --- a/plugin/core/gvrender_core_fig.c +++ b/plugin/core/gvrender_core_fig.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -119,7 +120,7 @@ static void fig_resolve_color(GVJ_t *job, gvcolor_t * color) color->u.index = i; break; default: - assert(0); /* internal error */ + UNREACHABLE(); // internal error } color->type = COLOR_INDEX; diff --git a/plugin/core/gvrender_core_map.c b/plugin/core/gvrender_core_map.c index 11e7b486f..3f62d4a37 100644 --- a/plugin/core/gvrender_core_map.c +++ b/plugin/core/gvrender_core_map.c @@ -12,6 +12,7 @@ #include +#include #include #include #include @@ -61,8 +62,7 @@ static void map_output_shape (GVJ_t *job, map_shape_t map_shape, pointf * AF, in gvputs(job, "\n"); break; default: - assert(0); - break; + UNREACHABLE(); } } else if (job->render.id == FORMAT_ISMAP && url && url[0]) { @@ -77,8 +77,7 @@ static void map_output_shape (GVJ_t *job, map_shape_t map_shape, pointf * AF, in break; } default: - assert(0); - break; + UNREACHABLE(); } } else if (job->render.id == FORMAT_CMAP || job->render.id == FORMAT_CMAPX) { @@ -93,8 +92,7 @@ static void map_output_shape (GVJ_t *job, map_shape_t map_shape, pointf * AF, in gvputs(job, " #endif +#include #include #include @@ -123,7 +124,7 @@ static void mp_resolve_color(GVJ_t *job, gvcolor_t * color) color->u.index = 0; break; default: - assert(0); /* internal error */ + UNREACHABLE(); // internal error } color->type = COLOR_INDEX; diff --git a/plugin/core/gvrender_core_svg.c b/plugin/core/gvrender_core_svg.c index f86da09eb..d77532c80 100644 --- a/plugin/core/gvrender_core_svg.c +++ b/plugin/core/gvrender_core_svg.c @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -127,7 +128,7 @@ static void svg_print_paint(GVJ_t * job, gvcolor_t color) color.u.rgba[0], color.u.rgba[1], color.u.rgba[2]); break; default: - assert(0); /* internal error */ + UNREACHABLE(); // internal error } } @@ -152,7 +153,7 @@ static void svg_print_gradient_color(GVJ_t * job, gvcolor_t color) color.u.rgba[0], color.u.rgba[1], color.u.rgba[2]); break; default: - assert(0); /* internal error */ + UNREACHABLE(); // internal error } } @@ -502,7 +503,7 @@ static void svg_textspan(GVJ_t * job, pointf p, textspan_t * span) gvprintf(job, " fill-opacity=\"%f\"", ((float) obj->pencolor.u.rgba[3] / 255.0)); break; default: - assert(0); /* internal error */ + UNREACHABLE(); // internal error } gvputc(job, '>'); if (obj->labeledgealigned) { diff --git a/plugin/core/gvrender_core_tk.c b/plugin/core/gvrender_core_tk.c index f197b2f63..17bba9a6f 100644 --- a/plugin/core/gvrender_core_tk.c +++ b/plugin/core/gvrender_core_tk.c @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -45,7 +46,7 @@ static void tkgen_print_color(GVJ_t * job, gvcolor_t color) color.u.rgba[0], color.u.rgba[1], color.u.rgba[2]); break; default: - assert(0); /* internal error */ + UNREACHABLE(); // internal error } } @@ -102,8 +103,7 @@ static void tkgen_print_tags(GVJ_t *job) ObjId = AGID(obj->u.sg); break; default: - assert (0); - break; + UNREACHABLE(); } gvprintf(job, " -tags {%d%s0x%" PRIx64 "}", ObjFlag, ObjType, ObjId); } diff --git a/plugin/core/gvrender_core_vml.c b/plugin/core/gvrender_core_vml.c index e6314a529..81e2cde44 100644 --- a/plugin/core/gvrender_core_vml.c +++ b/plugin/core/gvrender_core_vml.c @@ -25,6 +25,7 @@ #include #include #include +#include typedef enum { FORMAT_VML, FORMAT_VMLZ, } format_type; @@ -61,7 +62,7 @@ static void vml_print_color(GVJ_t * job, gvcolor_t color) color.u.rgba[0], color.u.rgba[1], color.u.rgba[2]); break; default: - assert(0); /* internal error */ + UNREACHABLE(); // internal error } } @@ -316,7 +317,7 @@ static void vml_textspan(GVJ_t * job, pointf p, textspan_t * span) obj->pencolor.u.rgba[0], obj->pencolor.u.rgba[1], obj->pencolor.u.rgba[2]); break; default: - assert(0); /* internal error */ + UNREACHABLE(); // internal error } gvputs(job, "\">
"); html_puts(job, span->str); -- 2.40.0