summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.clang-tidy2
-rw-r--r--ganv/Edge.hpp7
-rw-r--r--ganv/Item.hpp1
-rw-r--r--ganv/Node.hpp2
-rw-r--r--src/Canvas.cpp155
-rw-r--r--src/box.c24
-rw-r--r--src/circle.c9
-rw-r--r--src/edge.c10
-rw-r--r--src/group.c67
-rw-r--r--src/item.c22
-rw-r--r--src/module.c15
-rw-r--r--src/node.c19
-rw-r--r--src/port.c4
-rw-r--r--src/text.c16
-rw-r--r--src/widget.c15
15 files changed, 217 insertions, 151 deletions
diff --git a/.clang-tidy b/.clang-tidy
index a07aa88..36cfbc7 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -32,7 +32,6 @@ Checks: >
-clang-analyzer-cplusplus.NewDeleteLeaks,
-clang-analyzer-unix.Malloc,
-cppcoreguidelines-avoid-non-const-global-variables,
- -cppcoreguidelines-init-variables,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-owning-memory,
@@ -69,7 +68,6 @@ Checks: >
-readability-container-size-empty,
-readability-implicit-bool-conversion,
-readability-inconsistent-declaration-parameter-name,
- -readability-isolate-declaration,
-readability-make-member-function-const,
WarningsAsErrors: '*'
HeaderFilterRegex: '.*'
diff --git a/ganv/Edge.hpp b/ganv/Edge.hpp
index c7056a3..3dd08f3 100644
--- a/ganv/Edge.hpp
+++ b/ganv/Edge.hpp
@@ -59,6 +59,9 @@ public:
: Item(GANV_ITEM(gobj))
{}
+ Edge(const Edge& copy) = delete;
+ Edge& operator=(const Edge& other) = delete;
+
~Edge() override {
if (_gobj && ganv_item_get_parent(_gobj)) {
g_object_unref(_gobj);
@@ -81,10 +84,6 @@ public:
GanvEdge* gobj() { return reinterpret_cast<GanvEdge*>(_gobj); }
const GanvEdge* gobj() const { return reinterpret_cast<GanvEdge*>(_gobj); }
-
-private:
- Edge(const Edge& copy);
- Edge& operator=(const Edge& other);
};
} // namespace Ganv
diff --git a/ganv/Item.hpp b/ganv/Item.hpp
index 09e2f13..1dfe4eb 100644
--- a/ganv/Item.hpp
+++ b/ganv/Item.hpp
@@ -21,7 +21,6 @@
#include "ganv/wrap.hpp"
#include <gdk/gdk.h>
-#include <gdkmm/event.h>
#include <glib-object.h>
#include <glib.h>
#include <gobject/gclosure.h>
diff --git a/ganv/Node.hpp b/ganv/Node.hpp
index 95c66a4..e075e73 100644
--- a/ganv/Node.hpp
+++ b/ganv/Node.hpp
@@ -103,7 +103,7 @@ private:
static void on_notify_bool(GObject* gobj,
GParamSpec* pspec,
gpointer signal) {
- gboolean value;
+ gboolean value = FALSE;
g_object_get(gobj, g_param_spec_get_name(pspec), &value, nullptr);
static_cast<sigc::signal<bool, gboolean>*>(signal)->emit(value);
}
diff --git a/src/Canvas.cpp b/src/Canvas.cpp
index f3b2499..fdd7358 100644
--- a/src/Canvas.cpp
+++ b/src/Canvas.cpp
@@ -48,7 +48,6 @@
#include <cairo.h>
#include <gdk/gdk.h>
#include <gdk/gdkkeysyms-compat.h>
-#include <gdkmm/event.h>
#include <gdkmm/gc.h>
#include <gdkmm/screen.h>
#include <gdkmm/window.h>
@@ -78,6 +77,7 @@
#include <iostream>
#include <map>
#include <set>
+#include <sstream>
#include <string>
#include <utility>
#include <vector>
@@ -541,8 +541,8 @@ GanvCanvasImpl::first_edge_to(const GanvNode* head)
static void
select_if_tail_is_selected(GanvEdge* edge, void*)
{
- GanvNode* tail = edge->impl->tail;
- gboolean selected;
+ GanvNode* tail = edge->impl->tail;
+ gboolean selected = FALSE;
g_object_get(tail, "selected", &selected, NULL);
if (!selected && GANV_IS_PORT(tail)) {
g_object_get(ganv_port_get_module(GANV_PORT(tail)),
@@ -557,8 +557,8 @@ select_if_tail_is_selected(GanvEdge* edge, void*)
static void
select_if_head_is_selected(GanvEdge* edge, void*)
{
- GanvNode* head = edge->impl->head;
- gboolean selected;
+ GanvNode* head = edge->impl->head;
+ gboolean selected = FALSE;
g_object_get(head, "selected", &selected, NULL);
if (!selected && GANV_IS_PORT(head)) {
g_object_get(ganv_port_get_module(GANV_PORT(head)),
@@ -700,7 +700,7 @@ GanvCanvasImpl::layout_dot(const std::string& filename)
}
// Label row
- std::stringstream colspan;
+ std::ostringstream colspan;
colspan << (flow_right ? 1 : (n_cols + 1));
html += std::string("<TR><TD BORDER=\"0\" CELLPADDING=\"2\" COLSPAN=\"")
+ colspan.str()
@@ -826,7 +826,10 @@ get_region(GanvNode* node)
{
GanvItem* item = &node->item;
- double x1, y1, x2, y2;
+ double x1 = 0.0;
+ double y1 = 0.0;
+ double x2 = 0.0;
+ double y2 = 0.0;
ganv_item_get_bounds(item, &x1, &y1, &x2, &y2);
Region reg;
@@ -1040,7 +1043,7 @@ GanvCanvasImpl::select_port(GanvPort* p, bool unique)
void
GanvCanvasImpl::select_port_toggle(GanvPort* port, int mod_state)
{
- gboolean selected;
+ gboolean selected = FALSE;
g_object_get(G_OBJECT(port), "selected", &selected, NULL);
if ((mod_state & GDK_CONTROL_MASK)) {
if (selected)
@@ -1151,7 +1154,9 @@ bool
GanvCanvasImpl::on_event(GdkEvent* event)
{
static const int scroll_increment = 10;
- int scroll_x, scroll_y;
+
+ int scroll_x = 0;
+ int scroll_y = 0;
bool handled = false;
switch (event->type) {
@@ -1269,9 +1274,9 @@ static void
get_motion_coords(GdkEventMotion* motion, double* x, double* y)
{
if (motion->is_hint) {
- gint px;
- gint py;
- GdkModifierType state;
+ gint px = 0;
+ gint py = 0;
+ GdkModifierType state = (GdkModifierType)0;
gdk_window_get_pointer(motion->window, &px, &py, &state);
*x = px;
*y = py;
@@ -1309,7 +1314,8 @@ GanvCanvasImpl::select_drag_handler(GdkEvent* event)
return true;
} else if (event->type == GDK_MOTION_NOTIFY && _drag_state == SELECT) {
assert(_select_rect);
- double x, y;
+ double x = 0.0;
+ double y = 0.0;
get_motion_coords(&event->motion, &x, &y);
_select_rect->impl->coords.x1 = MIN(_select_start_x, x);
_select_rect->impl->coords.y1 = MIN(_select_start_y, y);
@@ -1331,7 +1337,7 @@ GanvCanvasImpl::select_drag_handler(GdkEvent* event)
ganv_box_get_y1(_select_rect),
ganv_box_get_x2(_select_rect),
ganv_box_get_y2(_select_rect))) {
- gboolean selected;
+ gboolean selected = FALSE;
g_object_get(G_OBJECT(node), "selected", &selected, NULL);
if (selected) {
ganv_canvas_unselect_node(_gcanvas, node);
@@ -1373,7 +1379,8 @@ GanvCanvasImpl::connect_drag_handler(GdkEvent* event)
}
if (event->type == GDK_MOTION_NOTIFY) {
- double x, y;
+ double x = 0.0;
+ double y = 0.0;
get_motion_coords(&event->motion, &x, &y);
if (!_drag_edge) {
@@ -1473,6 +1480,8 @@ GanvCanvasImpl::port_event(GdkEvent* event, GanvPort* port)
static double control_start_y = 0;
static float control_start_value = 0;
+ gboolean selected = FALSE;
+
switch (event->type) {
case GDK_BUTTON_PRESS:
if (event->button.button == 1) {
@@ -1589,7 +1598,6 @@ GanvCanvasImpl::port_event(GdkEvent* event, GanvPort* port)
return true;
case GDK_ENTER_NOTIFY:
- gboolean selected;
g_object_get(G_OBJECT(port), "selected", &selected, NULL);
if (!control_dragging && !selected) {
highlight_port(port, true);
@@ -1632,8 +1640,8 @@ GanvCanvasImpl::ports_joined(GanvPort* port1, GanvPort* port2)
highlight_port(port1, false);
highlight_port(port2, false);
- GanvNode* src_node;
- GanvNode* dst_node;
+ GanvNode* src_node = NULL;
+ GanvNode* dst_node = NULL;
if (port2->impl->is_input && !port1->impl->is_input) {
src_node = GANV_NODE(port1);
@@ -2122,7 +2130,8 @@ ganv_canvas_zoom_full(GanvCanvas* canvas)
if (canvas->impl->_items.empty())
return;
- int win_width, win_height;
+ int win_width = 0;
+ int win_height = 0;
GdkWindow* win = gtk_widget_get_window(
GTK_WIDGET(canvas->impl->_gcanvas));
gdk_window_get_size(win, &win_width, &win_height);
@@ -2159,7 +2168,8 @@ ganv_canvas_zoom_full(GanvCanvas* canvas)
ganv_canvas_set_zoom(canvas, new_zoom);
- int scroll_x, scroll_y;
+ int scroll_x = 0;
+ int scroll_y = 0;
ganv_canvas_w2c(canvas->impl->_gcanvas,
lrintf(left - pad), lrintf(bottom - pad),
&scroll_x, &scroll_y);
@@ -2543,7 +2553,8 @@ ganv_canvas_get_zoom(const GanvCanvas* canvas)
void
ganv_canvas_move_contents_to(GanvCanvas* canvas, double x, double y)
{
- double min_x=HUGE_VAL, min_y=HUGE_VAL;
+ double min_x = HUGE_VAL;
+ double min_y = HUGE_VAL;
FOREACH_ITEM(canvas->impl->_items, i) {
const double x = GANV_ITEM(*i)->impl->x;
const double y = GANV_ITEM(*i)->impl->y;
@@ -2559,7 +2570,10 @@ ganv_canvas_arrange(GanvCanvas* canvas)
#ifdef HAVE_AGRAPH
GVNodes nodes = canvas->impl->layout_dot((char*)"");
- double least_x=HUGE_VAL, least_y=HUGE_VAL, most_x=0, most_y=0;
+ double least_x = HUGE_VAL;
+ double least_y = HUGE_VAL;
+ double most_x = 0.0;
+ double most_y = 0.0;
// Set numeric locale to POSIX for reading graphviz output with strtod
char* locale = strdup(setlocale(LC_NUMERIC, NULL));
@@ -2579,7 +2593,8 @@ ganv_canvas_arrange(GanvCanvas* canvas)
const double cx = lrint(strtod(x_str.c_str(), NULL) * dpp);
const double cy = lrint(strtod(y_str.c_str(), NULL) * dpp);
- double w, h;
+ double w = 0.0;
+ double h = 0.0;
if (GANV_IS_BOX(i->first)) {
w = ganv_box_get_width(GANV_BOX(i->first));
h = ganv_box_get_height(GANV_BOX(i->first));
@@ -2618,7 +2633,8 @@ ganv_canvas_arrange(GanvCanvas* canvas)
//cerr << "CWH: " << _width << ", " << _height << endl;
//cerr << "GWH: " << graph_width << ", " << graph_height << endl;
- double old_width, old_height;
+ double old_width = 0.0;
+ double old_height = 0.0;
g_object_get(G_OBJECT(canvas),
"width", &old_width,
"height", &old_height,
@@ -2669,7 +2685,10 @@ ganv_canvas_export_image(GanvCanvas* canvas,
cairo_destroy(cr);
// Get draw extent
- double x, y, w, h;
+ double x = 0.0;
+ double y = 0.0;
+ double w = 0.0;
+ double h = 0.0;
cairo_recording_surface_ink_extents(rec_surface, &x, &y, &w, &h);
// Create image surface with the appropriate size
@@ -2691,7 +2710,10 @@ ganv_canvas_export_image(GanvCanvas* canvas,
// Draw recording to image surface
cr = cairo_create(img);
if (draw_background) {
- double r, g, b, a;
+ double r = 0.0;
+ double g = 0.0;
+ double b = 0.0;
+ double a = 0.0;
color_to_rgba(DEFAULT_BACKGROUND_COLOR, &r, &g, &b, &a);
cairo_set_source_rgba(cr, r, g, b, a);
cairo_rectangle(cr, 0, 0, w + 2 * pad, h + 2 * pad);
@@ -2954,11 +2976,16 @@ ganv_canvas_unrealize(GtkWidget* widget)
static void
scroll_to(GanvCanvas* canvas, int cx, int cy)
{
- int scroll_width, scroll_height;
- int right_limit, bottom_limit;
- int old_zoom_xofs, old_zoom_yofs;
- int changed_x = FALSE, changed_y = FALSE;
- int canvas_width, canvas_height;
+ int scroll_width = 0;
+ int scroll_height = 0;
+ int right_limit = 0;
+ int bottom_limit = 0;
+ int old_zoom_xofs = 0;
+ int old_zoom_yofs = 0;
+ int changed_x = 0;
+ int changed_y = 0;
+ int canvas_width = 0;
+ int canvas_height = 0;
canvas_width = GTK_WIDGET(canvas)->allocation.width;
canvas_height = GTK_WIDGET(canvas)->allocation.height;
@@ -3092,11 +3119,11 @@ is_descendant(GanvItem* item, GanvItem* parent)
int
ganv_canvas_emit_event(GanvCanvas* canvas, GdkEvent* event)
{
- GdkEvent* ev;
- gint finished;
- GanvItem* item;
- GanvItem* parent;
- guint mask;
+ GdkEvent* ev = NULL;
+ gint finished = 0;
+ GanvItem* item = NULL;
+ GanvItem* parent = NULL;
+ guint mask = 0;
/* Perform checks for grabbed items */
@@ -3422,7 +3449,8 @@ pick_current_item(GanvCanvas* canvas, GdkEvent* event)
if (canvas->impl->pick_event.type != GDK_LEAVE_NOTIFY) {
/* these fields don't have the same offsets in both types of events */
- double x, y;
+ double x = 0.0;
+ double y = 0.0;
if (canvas->impl->pick_event.type == GDK_ENTER_NOTIFY) {
x = canvas->impl->pick_event.crossing.x - canvas->impl->zoom_xofs;
y = canvas->impl->pick_event.crossing.y - canvas->impl->zoom_yofs;
@@ -3500,14 +3528,12 @@ pick_current_item(GanvCanvas* canvas, GdkEvent* event)
static gint
ganv_canvas_button(GtkWidget* widget, GdkEventButton* event)
{
- int mask;
- int retval;
+ int mask = 0;
+ int retval = FALSE;
g_return_val_if_fail(GANV_IS_CANVAS(widget), FALSE);
g_return_val_if_fail(event != NULL, FALSE);
- retval = FALSE;
-
GanvCanvas* canvas = GANV_CANVAS(widget);
/*
@@ -3615,9 +3641,7 @@ ganv_canvas_key(GtkWidget* widget, GdkEventKey* event)
GanvCanvas* canvas = GANV_CANVAS(widget);
if (!ganv_canvas_emit_event(canvas, (GdkEvent*)event)) {
- GtkWidgetClass* widget_class;
-
- widget_class = GTK_WIDGET_CLASS(canvas_parent_class);
+ GtkWidgetClass* widget_class = GTK_WIDGET_CLASS(canvas_parent_class);
if (event->type == GDK_KEY_PRESS) {
if (widget_class->key_press_event) {
@@ -3689,19 +3713,18 @@ ganv_canvas_focus_out(GtkWidget* widget, GdkEventFocus* event)
static void
ganv_canvas_paint_rect(GanvCanvas* canvas, gint x0, gint y0, gint x1, gint y1)
{
- gint draw_x1, draw_y1;
- gint draw_x2, draw_y2;
- gint draw_width, draw_height;
-
g_return_if_fail(!canvas->impl->need_update);
- draw_x1 = MAX(x0, canvas->layout.hadjustment->value - canvas->impl->zoom_xofs);
- draw_y1 = MAX(y0, canvas->layout.vadjustment->value - canvas->impl->zoom_yofs);
- draw_x2 = MIN(draw_x1 + GTK_WIDGET(canvas)->allocation.width, x1);
- draw_y2 = MIN(draw_y1 + GTK_WIDGET(canvas)->allocation.height, y1);
+ gint draw_x1 =
+ MAX(x0, canvas->layout.hadjustment->value - canvas->impl->zoom_xofs);
+ gint draw_y1 =
+ MAX(y0, canvas->layout.vadjustment->value - canvas->impl->zoom_yofs);
+
+ gint draw_x2 = MIN(draw_x1 + GTK_WIDGET(canvas)->allocation.width, x1);
+ gint draw_y2 = MIN(draw_y1 + GTK_WIDGET(canvas)->allocation.height, y1);
- draw_width = draw_x2 - draw_x1;
- draw_height = draw_y2 - draw_y1;
+ gint draw_width = draw_x2 - draw_x1;
+ gint draw_height = draw_y2 - draw_y1;
if ((draw_width < 1) || (draw_height < 1)) {
return;
@@ -3716,18 +3739,25 @@ ganv_canvas_paint_rect(GanvCanvas* canvas, gint x0, gint y0, gint x1, gint y1)
cairo_t* cr = gdk_cairo_create(canvas->layout.bin_window);
- double win_x, win_y;
+ double win_x = 0.0;
+ double win_y = 0.0;
ganv_canvas_window_to_world(canvas, 0, 0, &win_x, &win_y);
cairo_translate(cr, -win_x, -win_y);
cairo_scale(cr, canvas->impl->pixels_per_unit, canvas->impl->pixels_per_unit);
if (canvas->impl->root->object.flags & GANV_ITEM_VISIBLE) {
- double wx1, wy1, ww, wh;
+ double wx1 = 0.0;
+ double wy1 = 0.0;
+ double ww = 0.0;
+ double wh = 0.0;
ganv_canvas_c2w(canvas, draw_x1, draw_y1, &wx1, &wy1);
ganv_canvas_c2w(canvas, draw_width, draw_height, &ww, &wh);
// Draw background
- double r, g, b, a;
+ double r = 0.0;
+ double g = 0.0;
+ double b = 0.0;
+ double a = 0.0;
color_to_rgba(DEFAULT_BACKGROUND_COLOR, &r, &g, &b, &a);
cairo_set_source_rgba(cr, r, g, b, a);
cairo_rectangle(cr, wx1, wy1, ww, wh);
@@ -3889,8 +3919,10 @@ void
ganv_canvas_set_scroll_region(GanvCanvas* canvas,
double x1, double y1, double x2, double y2)
{
- double wxofs, wyofs;
- int xofs, yofs;
+ double wxofs = 0.0;
+ double wyofs = 0.0;
+ int xofs = 0;
+ int yofs = 0;
g_return_if_fail(GANV_IS_CANVAS(canvas));
@@ -4076,7 +4108,10 @@ void
ganv_canvas_request_redraw_w(GanvCanvas* canvas,
double x1, double y1, double x2, double y2)
{
- int cx1, cx2, cy1, cy2;
+ int cx1 = 0;
+ int cx2 = 0;
+ int cy1 = 0;
+ int cy2 = 0;
ganv_canvas_w2c(canvas, x1, y1, &cx1, &cy1);
ganv_canvas_w2c(canvas, x2, y2, &cx2, &cy2);
ganv_canvas_request_redraw_c(canvas, cx1, cy1, cx2, cy2);
diff --git a/src/box.c b/src/box.c
index 01814d1..b6f9a23 100644
--- a/src/box.c
+++ b/src/box.c
@@ -155,7 +155,10 @@ ganv_box_request_redraw(GanvItem* item,
const GanvBoxCoords* coords,
gboolean world)
{
- double x1, y1, x2, y2;
+ double x1 = 0.0;
+ double y1 = 0.0;
+ double x2 = 0.0;
+ double y2 = 0.0;
ganv_box_bounds_item(coords, &x1, &y1, &x2, &y2);
if (!world) {
@@ -268,11 +271,16 @@ ganv_box_draw(GanvItem* item,
double y2 = impl->coords.y2;
ganv_item_i2w_pair(item, &x1, &y1, &x2, &y2);
- double dash_length, border_color, fill_color;
+ double dash_length = 0.0;
+ double border_color = 0.0;
+ double fill_color = 0.0;
ganv_node_get_draw_properties(
&box->node, &dash_length, &border_color, &fill_color);
- double r, g, b, a;
+ double r = 0.0;
+ double g = 0.0;
+ double b = 0.0;
+ double a = 0.0;
for (int i = (impl->coords.stacked ? 1 : 0); i >= 0; --i) {
const double x = 0.0 - (STACKED_OFFSET * i);
@@ -314,7 +322,10 @@ ganv_box_point(GanvItem* item, double x, double y, GanvItem** actual_item)
*actual_item = NULL;
- double x1, y1, x2, y2;
+ double x1 = 0.0;
+ double y1 = 0.0;
+ double x2 = 0.0;
+ double y2 = 0.0;
ganv_box_bounds_item(&impl->coords, &x1, &y1, &x2, &y2);
// Point is inside the box (distance 0)
@@ -351,7 +362,10 @@ ganv_box_is_within(const GanvNode* self,
double x2,
double y2)
{
- double bx1, by1, bx2, by2;
+ double bx1 = 0.0;
+ double by1 = 0.0;
+ double bx2 = 0.0;
+ double by2 = 0.0;
g_object_get(G_OBJECT(self),
"x1", &bx1,
"y1", &by1,
diff --git a/src/circle.c b/src/circle.c
index 723b229..4ec698b 100644
--- a/src/circle.c
+++ b/src/circle.c
@@ -298,13 +298,18 @@ ganv_circle_draw(GanvItem* item,
GanvCircle* circle = GANV_CIRCLE(item);
GanvCirclePrivate* impl = circle->impl;
- double r, g, b, a;
+ double r = 0.0;
+ double g = 0.0;
+ double b = 0.0;
+ double a = 0.0;
double x = impl->coords.x;
double y = impl->coords.y;
ganv_item_i2w(item, &x, &y);
- double dash_length, border_color, fill_color;
+ double dash_length = 0.0;
+ double border_color = 0.0;
+ double fill_color = 0.0;
ganv_node_get_draw_properties(
&circle->node, &dash_length, &border_color, &fill_color);
diff --git a/src/edge.c b/src/edge.c
index a1a5df2..a74546a 100644
--- a/src/edge.c
+++ b/src/edge.c
@@ -316,7 +316,10 @@ ganv_edge_update(GanvItem* item, int flags)
impl->old_coords = impl->coords;
// Get bounding box
- double x1, x2, y1, y2;
+ double x1 = 0.0;
+ double x2 = 0.0;
+ double y1 = 0.0;
+ double y2 = 0.0;
ganv_edge_bounds(item, &x1, &y1, &x2, &y2);
// Ensure bounding box has non-zero area
@@ -359,7 +362,10 @@ ganv_edge_draw(GanvItem* item,
double dx = src_x - dst_x;
double dy = src_y - dst_y;
- double r, g, b, a;
+ double r = 0.0;
+ double g = 0.0;
+ double b = 0.0;
+ double a = 0.0;
if (impl->highlighted) {
color_to_rgba(highlight_color(impl->color, 0x40), &r, &g, &b, &a);
} else {
diff --git a/src/group.c b/src/group.c
index 54a3765..5ef39f6 100644
--- a/src/group.c
+++ b/src/group.c
@@ -85,7 +85,7 @@ ganv_group_get_property(GObject* gobject, guint param_id,
static void
ganv_group_destroy(GtkObject* object)
{
- GanvGroup* group;
+ GanvGroup* group = NULL;
g_return_if_fail(GANV_IS_GROUP(object));
@@ -131,9 +131,9 @@ ganv_group_update(GanvItem* item, int flags)
static void
ganv_group_realize(GanvItem* item)
{
- GanvGroup* group;
- GList* list;
- GanvItem* i;
+ GanvGroup* group = NULL;
+ GList* list = NULL;
+ GanvItem* i = NULL;
group = GANV_GROUP(item);
@@ -151,9 +151,9 @@ ganv_group_realize(GanvItem* item)
static void
ganv_group_unrealize(GanvItem* item)
{
- GanvGroup* group;
- GList* list;
- GanvItem* i;
+ GanvGroup* group = NULL;
+ GList* list = NULL;
+ GanvItem* i = NULL;
group = GANV_GROUP(item);
@@ -171,9 +171,9 @@ ganv_group_unrealize(GanvItem* item)
static void
ganv_group_map(GanvItem* item)
{
- GanvGroup* group;
- GList* list;
- GanvItem* i;
+ GanvGroup* group = NULL;
+ GList* list = NULL;
+ GanvItem* i = NULL;
group = GANV_GROUP(item);
@@ -191,9 +191,9 @@ ganv_group_map(GanvItem* item)
static void
ganv_group_unmap(GanvItem* item)
{
- GanvGroup* group;
- GList* list;
- GanvItem* i;
+ GanvGroup* group = NULL;
+ GList* list = NULL;
+ GanvItem* i = NULL;
group = GANV_GROUP(item);
@@ -297,24 +297,21 @@ get_child_bounds(GanvItem* child, double* x1, double* y1, double* x2, double* y2
static void
ganv_group_bounds(GanvItem* item, double* x1, double* y1, double* x2, double* y2)
{
- GanvGroup* group;
- GanvItem* child;
- GList* list;
- double tx1, ty1, tx2, ty2;
- double minx = DBL_MAX;
- double miny = DBL_MAX;
- double maxx = DBL_MIN;
- double maxy = DBL_MIN;
- int set;
-
- group = GANV_GROUP(item);
+ GanvGroup* group = GANV_GROUP(item);
+ GanvItem* child = NULL;
+ GList* list = NULL;
+ double tx1 = 0.0;
+ double ty1 = 0.0;
+ double tx2 = 0.0;
+ double ty2 = 0.0;
+ double minx = DBL_MAX;
+ double miny = DBL_MAX;
+ double maxx = DBL_MIN;
+ double maxy = DBL_MIN;
+ int set = FALSE;
/* Get the bounds of the first visible item */
- child = NULL; /* Unnecessary but eliminates a warning. */
-
- set = FALSE;
-
for (list = group->impl->item_list; list; list = list->next) {
child = (GanvItem*)list->data;
@@ -395,8 +392,8 @@ ganv_group_add(GanvItem* parent, GanvItem* item)
static void
ganv_group_remove(GanvItem* parent, GanvItem* item)
{
- GanvGroup* group = GANV_GROUP(parent);
- GList* children;
+ GanvGroup* group = GANV_GROUP(parent);
+ GList* children = NULL;
g_return_if_fail(GANV_IS_GROUP(group));
g_return_if_fail(GANV_IS_ITEM(item));
@@ -432,13 +429,9 @@ ganv_group_remove(GanvItem* parent, GanvItem* item)
static void
ganv_group_class_init(GanvGroupClass* klass)
{
- GObjectClass* gobject_class;
- GtkObjectClass* object_class;
- GanvItemClass* item_class;
-
- gobject_class = (GObjectClass*)klass;
- object_class = (GtkObjectClass*)klass;
- item_class = (GanvItemClass*)klass;
+ GObjectClass* gobject_class = (GObjectClass*)klass;
+ GtkObjectClass* object_class = (GtkObjectClass*)klass;
+ GanvItemClass* item_class = (GanvItemClass*)klass;
group_parent_class = (GanvItemClass*)g_type_class_peek_parent(klass);
diff --git a/src/item.c b/src/item.c
index 06db304..fc5aac6 100644
--- a/src/item.c
+++ b/src/item.c
@@ -252,7 +252,7 @@ redraw_if_visible(GanvItem* item)
static void
ganv_item_dispose(GObject* object)
{
- GanvItem* item;
+ GanvItem* item = NULL;
g_return_if_fail(GANV_IS_ITEM(object));
@@ -517,8 +517,8 @@ ganv_item_i2w(GanvItem* item, double* x, double* y)
g_return_if_fail(x != NULL);
g_return_if_fail(y != NULL);*/
- double off_x;
- double off_y;
+ double off_x = 0.0;
+ double off_y = 0.0;
ganv_item_i2w_offset(item, &off_x, &off_y);
*x += off_x;
@@ -528,8 +528,8 @@ ganv_item_i2w(GanvItem* item, double* x, double* y)
void
ganv_item_i2w_pair(GanvItem* item, double* x1, double* y1, double* x2, double* y2)
{
- double off_x;
- double off_y;
+ double off_x = 0.0;
+ double off_y = 0.0;
ganv_item_i2w_offset(item, &off_x, &off_y);
*x1 += off_x;
@@ -550,8 +550,8 @@ ganv_item_i2w_pair(GanvItem* item, double* x1, double* y1, double* x2, double* y
void
ganv_item_w2i(GanvItem* item, double* x, double* y)
{
- double off_x;
- double off_y;
+ double off_x = 0.0;
+ double off_y = 0.0;
ganv_item_i2w_offset(item, &off_x, &off_y);
*x -= off_x;
@@ -652,8 +652,8 @@ boolean_handled_accumulator(GSignalInvocationHint* ihint,
(void)ihint;
(void)dummy;
- gboolean continue_emission;
- gboolean signal_handled;
+ gboolean continue_emission = FALSE;
+ gboolean signal_handled = FALSE;
signal_handled = g_value_get_boolean(handler_return);
g_value_set_boolean(return_accu, signal_handled);
@@ -666,9 +666,7 @@ boolean_handled_accumulator(GSignalInvocationHint* ihint,
static void
ganv_item_class_init(GanvItemClass* klass)
{
- GObjectClass* gobject_class;
-
- gobject_class = (GObjectClass*)klass;
+ GObjectClass* gobject_class = (GObjectClass*)klass;
item_parent_class = (GtkObjectClass*)g_type_class_peek_parent(klass);
diff --git a/src/module.c b/src/module.c
index e96932e..92ac3fe 100644
--- a/src/module.c
+++ b/src/module.c
@@ -167,7 +167,8 @@ measure(GanvModule* module, Metrics* m)
{
memset(m, '\0', sizeof(Metrics));
- double title_w, title_h;
+ double title_w = 0.0;
+ double title_h = 0.0;
title_size(module, &title_w, &title_h);
GanvCanvas* canvas = ganv_item_get_canvas(GANV_ITEM(module));
@@ -268,7 +269,8 @@ place_title(GanvModule* module, GanvDirection dir)
GanvBox* box = GANV_BOX(module);
GanvText* canvas_title = GANV_NODE(module)->impl->label;
- double title_w, title_h;
+ double title_w = 0.0;
+ double title_h = 0.0;
title_size(module, &title_w, &title_h);
if (!canvas_title) {
@@ -294,7 +296,8 @@ resize_right(GanvModule* module)
Metrics m;
measure(module, &m);
- double title_w, title_h;
+ double title_w = 0.0;
+ double title_h = 0.0;
title_size(module, &title_w, &title_h);
// Basic height contains title
@@ -370,7 +373,8 @@ resize_down(GanvModule* module)
Metrics m;
measure(module, &m);
- double title_w, title_h;
+ double title_w = 0.0;
+ double title_h = 0.0;
title_size(module, &title_w, &title_h);
const double port_depth = ganv_module_get_empty_port_depth(module);
@@ -821,7 +825,8 @@ ganv_module_embed(GanvModule* module,
return;
}
- double title_w, title_h;
+ double title_w = 0.0;
+ double title_h = 0.0;
title_size(module, &title_w, &title_h);
impl->embed_item = ganv_item_new(
diff --git a/src/node.c b/src/node.c
index 81d10a6..f93222b 100644
--- a/src/node.c
+++ b/src/node.c
@@ -32,6 +32,7 @@
#include <glib.h>
#include <gtk/gtk.h>
+#include <math.h>
#include <stddef.h>
guint signal_moved;
@@ -490,9 +491,11 @@ ganv_node_default_event(GanvItem* item,
GanvCanvas* canvas = ganv_item_get_canvas(GANV_ITEM(node));
// FIXME: put these somewhere better
- static double last_x, last_y;
- static double drag_start_x, drag_start_y;
- static gboolean dragging = FALSE;
+ static double last_x = NAN;
+ static double last_y = NAN;
+ static double drag_start_x = NAN;
+ static double drag_start_y = NAN;
+ static gboolean dragging = FALSE;
switch (event->type) {
case GDK_ENTER_NOTIFY:
@@ -526,7 +529,7 @@ ganv_node_default_event(GanvItem* item,
case GDK_BUTTON_RELEASE:
if (dragging) {
- gboolean selected;
+ gboolean selected = FALSE;
g_object_get(G_OBJECT(node), "selected", &selected, NULL);
ganv_canvas_ungrab_item(GANV_ITEM(node), event->button.time);
node->impl->grabbed = FALSE;
@@ -557,16 +560,16 @@ ganv_node_default_event(GanvItem* item,
case GDK_MOTION_NOTIFY:
if ((dragging && (event->motion.state & GDK_BUTTON1_MASK))) {
- gboolean selected;
+ gboolean selected = FALSE;
g_object_get(G_OBJECT(node), "selected", &selected, NULL);
double new_x = event->motion.x;
double new_y = event->motion.y;
if (event->motion.is_hint) {
- int t_x;
- int t_y;
- GdkModifierType state;
+ int t_x = 0;
+ int t_y = 0;
+ GdkModifierType state = (GdkModifierType)0;
gdk_window_get_pointer(event->motion.window, &t_x, &t_y, &state);
new_x = t_x;
new_y = t_y;
diff --git a/src/port.c b/src/port.c
index dcd3ac3..212b787 100644
--- a/src/port.c
+++ b/src/port.c
@@ -699,7 +699,7 @@ ganv_port_get_natural_width(const GanvPort* port)
if (ganv_canvas_get_direction(canvas) == GANV_DIRECTION_DOWN) {
w = ganv_module_get_empty_port_breadth(ganv_port_get_module(port));
} else if (label && (GANV_ITEM(label)->object.flags & GANV_ITEM_VISIBLE)) {
- double label_w;
+ double label_w = 0.0;
g_object_get(port->box.node.impl->label, "width", &label_w, NULL);
w = label_w + (PORT_LABEL_HPAD * 2.0);
} else {
@@ -708,7 +708,7 @@ ganv_port_get_natural_width(const GanvPort* port)
if (port->impl->value_label &&
(GANV_ITEM(port->impl->value_label)->object.flags
& GANV_ITEM_VISIBLE)) {
- double label_w;
+ double label_w = 0.0;
g_object_get(port->impl->value_label, "width", &label_w, NULL);
w += label_w + PORT_LABEL_HPAD;
}
diff --git a/src/text.c b/src/text.c
index 058d765..7e5a565 100644
--- a/src/text.c
+++ b/src/text.c
@@ -128,7 +128,8 @@ ganv_text_layout(GanvText* text)
cairo_font_options_destroy(opt);
pango_font_description_free(font);
- int width, height;
+ int width = 0;
+ int height = 0;
pango_layout_get_pixel_size(impl->layout, &width, &height);
impl->coords.width = width;
@@ -255,14 +256,18 @@ ganv_text_point(GanvItem* item, double x, double y, GanvItem** actual_item)
{
*actual_item = NULL;
- double x1, y1, x2, y2;
+ double x1 = 0.0;
+ double y1 = 0.0;
+ double x2 = 0.0;
+ double y2 = 0.0;
ganv_text_bounds_item(item, &x1, &y1, &x2, &y2);
if ((x >= x1) && (y >= y1) && (x <= x2) && (y <= y2)) {
return 0.0;
}
// Point is outside the box
- double dx, dy;
+ double dx = 0.0;
+ double dy = 0.0;
// Find horizontal distance to nearest edge
if (x < x1) {
@@ -305,7 +310,10 @@ ganv_text_draw(GanvItem* item,
ganv_text_layout(text);
}
- double r, g, b, a;
+ double r = 0.0;
+ double g = 0.0;
+ double b = 0.0;
+ double a = 0.0;
color_to_rgba(impl->color, &r, &g, &b, &a);
cairo_set_source_rgba(cr, r, g, b, a);
diff --git a/src/widget.c b/src/widget.c
index e67a485..262aef3 100644
--- a/src/widget.c
+++ b/src/widget.c
@@ -142,7 +142,8 @@ recalc_bounds(GanvWidget* witem)
item->impl->x2 = witem->impl->cx + witem->impl->cwidth;
item->impl->y2 = witem->impl->cy + witem->impl->cheight;
- int zoom_xofs, zoom_yofs;
+ int zoom_xofs = 0;
+ int zoom_yofs = 0;
ganv_canvas_get_zoom_offsets(item->impl->canvas, &zoom_xofs, &zoom_yofs);
if (witem->impl->widget) {
gtk_layout_move(GTK_LAYOUT(item->impl->canvas), witem->impl->widget,
@@ -172,7 +173,7 @@ ganv_widget_set_property(GObject* object,
GanvWidget* witem = GANV_WIDGET(object);
int update = FALSE;
int calc_bounds = FALSE;
- GObject* obj;
+ GObject* obj = NULL;
switch (param_id) {
case PROP_WIDGET:
@@ -187,7 +188,8 @@ ganv_widget_set_property(GObject* object,
witem->impl->destroy_id = g_signal_connect(obj, "destroy",
G_CALLBACK(do_destroy),
witem);
- int zoom_xofs, zoom_yofs;
+ int zoom_xofs = 0;
+ int zoom_yofs = 0;
ganv_canvas_get_zoom_offsets(item->impl->canvas, &zoom_xofs, &zoom_yofs);
gtk_layout_put(GTK_LAYOUT(item->impl->canvas), witem->impl->widget,
@@ -352,7 +354,8 @@ ganv_widget_point(GanvItem* item, double x, double y, GanvItem** actual_item)
*actual_item = item;
- double x1, y1;
+ double x1 = 0.0;
+ double y1 = 0.0;
ganv_canvas_c2w(item->impl->canvas, witem->impl->cx, witem->impl->cy, &x1, &y1);
const double pixels_per_unit = ganv_canvas_get_zoom(item->impl->canvas);
@@ -368,7 +371,7 @@ ganv_widget_point(GanvItem* item, double x, double y, GanvItem** actual_item)
/* Point is outside widget bounds */
- double dx;
+ double dx = 0.0;
if (x < x1) {
dx = x1 - x;
} else if (x > x2) {
@@ -377,7 +380,7 @@ ganv_widget_point(GanvItem* item, double x, double y, GanvItem** actual_item)
dx = 0.0;
}
- double dy;
+ double dy = 0.0;
if (y < y1) {
dy = y1 - y;
} else if (y > y2) {