Commit 7959e0d2 authored by Hans Breuer's avatar Hans Breuer

[scan-build] Result of operation is garbage or undefined (theoretical)

Simlify slightly overengineerd parent_handle_extents() to silence
scan-build complaining about theoretical undefined values.
Parents without handles simply must not exist, now also ensured by
a new unit-test.
Also removed the return value no caller cared for anyway.
parent e9299047
......@@ -255,35 +255,20 @@ parent_point_extents(Point *point, Rectangle *extents)
* which is initialized to the biggest rectangle containing
* all the objects handles
*/
gboolean
void
parent_handle_extents(DiaObject *obj, Rectangle *extents)
{
int idx;
coord *left_most = NULL, *top_most = NULL, *bottom_most = NULL, *right_most = NULL;
for (idx = 0; idx < obj->num_handles; idx++)
{
g_assert (obj->num_handles > 0);
/* initialize the rectangle with the first handle */
extents->left = extents->right = obj->handles[0]->pos.x;
extents->top = extents->bottom = obj->handles[0]->pos.y;
/* grow it with the other ones */
for (idx = 1; idx < obj->num_handles; idx++) {
Handle *handle = obj->handles[idx];
if (!left_most || *left_most > handle->pos.x)
left_most = &handle->pos.x;
if (!right_most || *right_most < handle->pos.x)
right_most = &handle->pos.x;
if (!top_most || *top_most > handle->pos.y)
top_most = &handle->pos.y;
if (!bottom_most || *bottom_most < handle->pos.y)
bottom_most = &handle->pos.y;
rectangle_add_point (extents, &handle->pos);
}
if (!left_most || !right_most || !top_most || !bottom_most)
return FALSE;
extents->left = *left_most;
extents->right = *right_most;
extents->top = *top_most;
extents->bottom = *bottom_most;
return TRUE;
}
/** Apply a function to all children of the given object (recursively,
......
......@@ -24,7 +24,7 @@
#include "geometry.h"
GList *parent_list_affected(GList *obj_list);
gboolean parent_handle_extents(DiaObject *obj, Rectangle *extents);
void parent_handle_extents(DiaObject *obj, Rectangle *extents);
Point parent_move_child_delta(Rectangle *p_ext, Rectangle *c_text, Point *delta);
void parent_point_extents(Point *point, Rectangle *extents);
gboolean parent_list_expand(GList *obj_list);
......
......@@ -86,6 +86,7 @@ _test_creation (gconstpointer user_data)
g_assert (o->bounding_box.left <= o->position.x && o->position.x <= o->bounding_box.right);
g_assert (o->bounding_box.top <= o->position.y && o->position.y <= o->bounding_box.bottom);
g_assert (o->num_handles > 0);
/* both handles can be NULL, but if not they must belong to the object */
for (i = 0; i < o->num_handles; ++i)
{
......@@ -811,7 +812,6 @@ _ot_item (gpointer key,
g_test_add_data_func (testpath, type, _test_move_handle);
g_free (testpath);
testpath = g_strdup_printf ("%s/%s/%s", base, name, "ConnectionPoints");
g_test_add_data_func (testpath, type, _test_connectionpoint_consistency);
g_free (testpath);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment