From 047fc182d84a60befbbc8215c5369ecfe665c34a Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Mon, 5 Sep 2022 10:22:42 -0700 Subject: [PATCH] GTK plugin: squash -Wsign-compare, -Wsign-conversion warnings for width/height Graphviz deals with these values as unsigned, but the GTK APIs deal with them as signed. Nevertheless we expect both sides to only ever deal in non-negative values. --- plugin/gtk/callbacks.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/plugin/gtk/callbacks.c b/plugin/gtk/callbacks.c index 9e0cfe00b..d601e7977 100644 --- a/plugin/gtk/callbacks.c +++ b/plugin/gtk/callbacks.c @@ -9,7 +9,7 @@ *************************************************************************/ #include "config.h" - +#include #include #include @@ -227,8 +227,10 @@ on_drawingarea1_expose_event (GtkWidget *widget, job->context = cr; job->external_context = true; - job->width = widget->allocation.width; - job->height = widget->allocation.height; + assert(widget->allocation.width >= 0); + job->width = (unsigned)widget->allocation.width; + assert(widget->allocation.height >= 0); + job->height = (unsigned)widget->allocation.height; if (job->has_been_rendered) { (job->callbacks->refresh)(job); } @@ -297,8 +299,10 @@ on_drawingarea2_expose_event (GtkWidget *widget, job->context = cr; job->external_context = true; - job->width = widget->allocation.width; - job->height = widget->allocation.height; + assert(widget->allocation.width >= 0); + job->width = (unsigned)widget->allocation.width; + assert(widget->allocation.height >= 0); + job->height = (unsigned)widget->allocation.height; tmp = job->zoom; job->zoom = MIN(job->width * POINTS_PER_INCH / (job->bb.UR.x * job->dpi.x), @@ -352,10 +356,13 @@ on_drawingarea1_configure_event (GtkWidget *widget, (double) event->height / (double) job->height); job->zoom *= zoom_to_fit; } - if (event->width > job->width || event->height > job->height) + if ((event->width >= 0 && (unsigned)event->width > job->width) || + (event->height >= 0 && (unsigned)event->height > job->height)) job->has_grown = true; - job->width = event->width; - job->height = event->height; + assert(event->width >= 0); + job->width = (unsigned)event->width; + assert(event->height >= 0); + job->height = (unsigned)event->height; job->needs_refresh = true; return FALSE; -- 2.40.0