Commit 5d015810 authored by Manish Singh's avatar Manish Singh Committed by Manish Singh
Browse files

Fix a bunch of warnings from Sparse:

2004-11-13  Manish Singh  <yosh@gimp.org>

        Fix a bunch of warnings from Sparse:

        * app/actions/dockable-commands.c
        * app/actions/layers-actions.c
        * app/actions/view-commands.c
        * app/base/pixel-surround.c
        * app/config/gimpconfig-utils.c
        * app/config/gimpscanner.c
        * app/core/gimpbrushgenerated.c
        * app/core/gimpcontainer.c
        * app/core/gimpimage.c
        * app/dialogs/palette-import-dialog.c
        * app/file/gimprecentlist.c
        * app/plug-in/plug-in-params.c
        * app/text/gimptext-compat.c
        * app/text/gimptext-parasite.c
        * app/vectors/gimpbezierstroke.c
        * app/vectors/gimpstroke.c
        * app/widgets/gimpcellrendereraccel.c
        * app/widgets/gimpselectiondata.c
        * app/xcf/xcf.c
        * libgimp/gimp.c
        * libgimpthumb/gimpthumb-utils.c
        * libgimpthumb/gimpthumbnail.c
        * modules/cdisplay_proof.c
        * plug-ins/Lighting/lighting_ui.c
        * plug-ins/common/csource.c
        * plug-ins/common/glasstile.c
        * plug-ins/common/nova.c
        * plug-ins/common/pcx.c
        * plug-ins/common/pnm.c
        * plug-ins/common/randomize.c
        * plug-ins/common/screenshot.c
        * plug-ins/common/sel_gauss.c
        * plug-ins/common/spheredesigner.c
        * plug-ins/common/wind.c
        * plug-ins/gfig/gfig-dialog.c
        * plug-ins/gfig/gfig-dobject.c
        * plug-ins/gimpressionist/gimpressionist.c
        * plug-ins/ifscompose/ifscompose.c
        * plug-ins/print/gimp_main_window.c
        * plug-ins/print/print.c: Cleanup integer vs. pointer confusion.

        * app/base/temp-buf.c
        * app/dialogs/about-dialog.c
        * plug-ins/common/bumpmap.c
        * plug-ins/common/jigsaw.c
        * plug-ins/gfig/gfig-dobject.c: Cosmetic cleanups.

        * app/config/gimpconfig-deserialize.c
        * app/config/gimpconfig-path.c
        * app/config/gimpconfigwriter.c
        * app/core/gimpgradient.c
        * app/tools/gimpdrawtool.c
        * plug-ins/common/nlfilt.c
        * plug-ins/common/unsharp.c
        * plug-ins/common/zealouscrop.c: Define inline functions before they
        are used.

        * app/core/gimpdrawable-blend.c: PixelRegion definition was changed
        some time ago, but the initialization here didn't change. Fix it.

        * app/plug-in/plug-in-rc.c (plug_in_extra_deserialize): No need to
        assign token twice in a row.

        * libgimpbase/gimpdatafiles.c (gimp_datafiles_read_directories): No
        need to initialize file_data, since the code fills out all the fields.

        * plug-ins/common/CML_explorer.c
        * plug-ins/common/vpropagate.c: Declare function pointers fully.

        * plug-ins/common/grid.c (pix_composite): G_INLINE_FUNC isn't needed,
        we assume we can use the "inline" keyword always.

        * plug-ins/common/psd_save.c
        * plug-ins/common/vinvert.c
        * plug-ins/gfig/gfig-arc.c
        * plug-ins/gfig/gfig-bezier.c
        * plug-ins/gfig/gfig-circle.c
        * plug-ins/gfig/gfig-dialog.c
        * plug-ins/gfig/gfig-dobject.c
        * plug-ins/gfig/gfig-ellipse.c
        * plug-ins/gfig/gfig-line.c
        * plug-ins/gfig/gfig-poly.c
        * plug-ins/gfig/gfig-spiral.c
        * plug-ins/gfig/gfig-star.c
        * plug-ins/gfig/gfig.c
        * plug-ins/gimpressionist/orientmap.c
        * plug-ins/gimpressionist/placement.c
        * plug-ins/gimpressionist/sizemap.c
        * plug-ins/imagemap/imap_grid.c
        * plug-ins/imagemap/imap_main.c
        * plug-ins/imagemap/imap_preferences.c
        * plug-ins/imagemap/imap_settings.c
        * plug-ins/maze/maze.c
        * plug-ins/sel2path/curve.c
        * plug-ins/sel2path/fit.c
        * plug-ins/sel2path/pxl-outline.c
        * plug-ins/sel2path/spline.c
        * plug-ins/xjt/xjt.c: Functions with no args should be declared
        with (void).

        * plug-ins/common/retinex.c (MSRCR): Initialize max_preview to quiet
        the compiler.
parent ec9ee41f
2004-11-13 Manish Singh <yosh@gimp.org>
Fix a bunch of warnings from Sparse:
* app/actions/dockable-commands.c
* app/actions/layers-actions.c
* app/actions/view-commands.c
* app/base/pixel-surround.c
* app/config/gimpconfig-utils.c
* app/config/gimpscanner.c
* app/core/gimpbrushgenerated.c
* app/core/gimpcontainer.c
* app/core/gimpimage.c
* app/dialogs/palette-import-dialog.c
* app/file/gimprecentlist.c
* app/plug-in/plug-in-params.c
* app/text/gimptext-compat.c
* app/text/gimptext-parasite.c
* app/vectors/gimpbezierstroke.c
* app/vectors/gimpstroke.c
* app/widgets/gimpcellrendereraccel.c
* app/widgets/gimpselectiondata.c
* app/xcf/xcf.c
* libgimp/gimp.c
* libgimpthumb/gimpthumb-utils.c
* libgimpthumb/gimpthumbnail.c
* modules/cdisplay_proof.c
* plug-ins/Lighting/lighting_ui.c
* plug-ins/common/csource.c
* plug-ins/common/glasstile.c
* plug-ins/common/nova.c
* plug-ins/common/pcx.c
* plug-ins/common/pnm.c
* plug-ins/common/randomize.c
* plug-ins/common/screenshot.c
* plug-ins/common/sel_gauss.c
* plug-ins/common/spheredesigner.c
* plug-ins/common/wind.c
* plug-ins/gfig/gfig-dialog.c
* plug-ins/gfig/gfig-dobject.c
* plug-ins/gimpressionist/gimpressionist.c
* plug-ins/ifscompose/ifscompose.c
* plug-ins/print/gimp_main_window.c
* plug-ins/print/print.c: Cleanup integer vs. pointer confusion.
* app/base/temp-buf.c
* app/dialogs/about-dialog.c
* plug-ins/common/bumpmap.c
* plug-ins/common/jigsaw.c
* plug-ins/gfig/gfig-dobject.c: Cosmetic cleanups.
* app/config/gimpconfig-deserialize.c
* app/config/gimpconfig-path.c
* app/config/gimpconfigwriter.c
* app/core/gimpgradient.c
* app/tools/gimpdrawtool.c
* plug-ins/common/nlfilt.c
* plug-ins/common/unsharp.c
* plug-ins/common/zealouscrop.c: Define inline functions before they
are used.
* app/core/gimpdrawable-blend.c: PixelRegion definition was changed
some time ago, but the initialization here didn't change. Fix it.
* app/plug-in/plug-in-rc.c (plug_in_extra_deserialize): No need to
assign token twice in a row.
* libgimpbase/gimpdatafiles.c (gimp_datafiles_read_directories): No
need to initialize file_data, since the code fills out all the fields.
* plug-ins/common/CML_explorer.c
* plug-ins/common/vpropagate.c: Declare function pointers fully.
* plug-ins/common/grid.c (pix_composite): G_INLINE_FUNC isn't needed,
we assume we can use the "inline" keyword always.
* plug-ins/common/psd_save.c
* plug-ins/common/vinvert.c
* plug-ins/gfig/gfig-arc.c
* plug-ins/gfig/gfig-bezier.c
* plug-ins/gfig/gfig-circle.c
* plug-ins/gfig/gfig-dialog.c
* plug-ins/gfig/gfig-dobject.c
* plug-ins/gfig/gfig-ellipse.c
* plug-ins/gfig/gfig-line.c
* plug-ins/gfig/gfig-poly.c
* plug-ins/gfig/gfig-spiral.c
* plug-ins/gfig/gfig-star.c
* plug-ins/gfig/gfig.c
* plug-ins/gimpressionist/orientmap.c
* plug-ins/gimpressionist/placement.c
* plug-ins/gimpressionist/sizemap.c
* plug-ins/imagemap/imap_grid.c
* plug-ins/imagemap/imap_main.c
* plug-ins/imagemap/imap_preferences.c
* plug-ins/imagemap/imap_settings.c
* plug-ins/maze/maze.c
* plug-ins/sel2path/curve.c
* plug-ins/sel2path/fit.c
* plug-ins/sel2path/pxl-outline.c
* plug-ins/sel2path/spline.c
* plug-ins/xjt/xjt.c: Functions with no args should be declared
with (void).
* plug-ins/common/retinex.c (MSRCR): Initialize max_preview to quiet
the compiler.
2004-11-14 Sven Neumann <sven@gimp.org>
* themes/Default/images/Makefile.am
......
......@@ -334,7 +334,7 @@ dockable_change_screen_cmd_callback (GtkAction *action,
dialog = gimp_query_int_box ("Move Dock to Screen",
dock,
NULL, 0,
NULL, NULL,
"Enter destination screen",
cur_screen, 0, num_screens - 1,
G_OBJECT (dock), "destroy",
......
......@@ -385,7 +385,7 @@ layers_actions_update (GimpActionGroup *group,
{
GimpImage *gimage = action_data_get_image (data);
GimpLayer *layer = NULL;
GimpLayerMask *mask = FALSE; /* layer mask */
GimpLayerMask *mask = NULL; /* layer mask */
gboolean fs = FALSE; /* floating sel */
gboolean ac = FALSE; /* active channel */
gboolean sel = FALSE;
......
......@@ -669,7 +669,7 @@ view_change_screen_cmd_callback (GtkAction *action,
dialog = gimp_query_int_box ("Move Display to Screen",
gdisp->shell,
NULL, 0,
NULL, NULL,
"Enter destination screen",
cur_screen, 0, num_screens - 1,
G_OBJECT (gdisp->shell), "destroy",
......
......@@ -81,7 +81,7 @@ pixel_surround_lock (PixelSurround *ps,
if (ps->tile)
{
tile_release (ps->tile, FALSE);
ps->tile = 0;
ps->tile = NULL;
}
/* copy pixels, one by one */
......@@ -132,7 +132,7 @@ pixel_surround_release (PixelSurround *ps)
if (ps->tile)
{
tile_release (ps->tile, FALSE);
ps->tile = 0;
ps->tile = NULL;
}
}
......@@ -142,7 +142,7 @@ pixel_surround_clear (PixelSurround *ps)
if (ps->buff)
{
g_free (ps->buff);
ps->buff = 0;
ps->buff = NULL;
ps->buff_size = 0;
}
}
......@@ -434,12 +434,12 @@ temp_buf_copy_area (TempBuf *src,
gint dest_y)
{
TempBuf *new;
PixelRegion srcPR = { 0 };
PixelRegion destPR = { 0 };
PixelRegion srcPR = { 0, };
PixelRegion destPR = { 0, };
guchar empty[MAX_CHANNELS] = { 0, 0, 0, 0 };
gint x1, y1, x2, y2;
g_return_val_if_fail (src != NULL, dest);
g_return_val_if_fail (src != NULL, dest);
g_return_val_if_fail (!dest || dest->bytes == src->bytes, dest);
g_return_val_if_fail (width + dest_x > 0, dest);
......
......@@ -89,6 +89,19 @@ static GTokenType gimp_config_deserialize_any (GValue *value,
static inline gboolean scanner_string_utf8_valid (GScanner *scanner,
const gchar *token_name);
static inline gboolean
scanner_string_utf8_valid (GScanner *scanner,
const gchar *token_name)
{
if (g_utf8_validate (scanner->value.v_string, -1, NULL))
return TRUE;
g_scanner_error (scanner,
_("value for token %s is not a valid UTF-8 string"),
token_name);
return FALSE;
}
/**
* gimp_config_deserialize_properties:
......@@ -777,17 +790,3 @@ gimp_config_deserialize_any (GValue *value,
return G_TOKEN_RIGHT_PAREN;
}
static inline gboolean
scanner_string_utf8_valid (GScanner *scanner,
const gchar *token_name)
{
if (g_utf8_validate (scanner->value.v_string, -1, NULL))
return TRUE;
g_scanner_error (scanner,
_("value for token %s is not a valid UTF-8 string"),
token_name);
return FALSE;
}
......@@ -39,6 +39,29 @@ static gchar * gimp_config_path_expand_only (const gchar *path,
GError **error);
static inline gchar * extract_token (const gchar **str);
static inline gchar *
extract_token (const gchar **str)
{
const gchar *p;
gchar *token;
if (strncmp (*str, "${", 2))
return NULL;
p = *str + 2;
while (*p && (*p != '}'))
p = g_utf8_next_char (p);
if (!p)
return NULL;
token = g_strndup (*str + 2, g_utf8_pointer_to_offset (*str + 2, p));
*str = p + 1; /* after the closing bracket */
return token;
}
/**
* gimp_config_path_expand:
......@@ -230,27 +253,3 @@ gimp_config_path_expand_only (const gchar *path,
return expanded;
}
static inline gchar *
extract_token (const gchar **str)
{
const gchar *p;
gchar *token;
if (strncmp (*str, "${", 2))
return NULL;
p = *str + 2;
while (*p && (*p != '}'))
p = g_utf8_next_char (p);
if (!p)
return NULL;
token = g_strndup (*str + 2, g_utf8_pointer_to_offset (*str + 2, p));
*str = p + 1; /* after the closing bracket */
return token;
}
......@@ -266,8 +266,8 @@ gimp_config_diff (GimpConfig *a,
{
GList *diff;
g_return_val_if_fail (GIMP_IS_CONFIG (a), FALSE);
g_return_val_if_fail (GIMP_IS_CONFIG (b), FALSE);
g_return_val_if_fail (GIMP_IS_CONFIG (a), NULL);
g_return_val_if_fail (GIMP_IS_CONFIG (b), NULL);
if (G_TYPE_FROM_INSTANCE (a) == G_TYPE_FROM_INSTANCE (b))
diff = gimp_config_diff_same (a, b, flags);
......
......@@ -67,6 +67,29 @@ static inline void gimp_config_writer_newline (GimpConfigWriter *writer);
static gboolean gimp_config_writer_close_file (GimpConfigWriter *writer,
GError **error);
static inline void
gimp_config_writer_flush (GimpConfigWriter *writer)
{
if (write (writer->fd, writer->buffer->str, writer->buffer->len) < 0)
g_set_error (&writer->error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,
g_strerror (errno));
g_string_truncate (writer->buffer, 0);
}
static inline void
gimp_config_writer_newline (GimpConfigWriter *writer)
{
gint i;
g_string_append_c (writer->buffer, '\n');
if (writer->comment)
g_string_append_len (writer->buffer, "# ", 2);
for (i = 0; i < writer->depth; i++)
g_string_append_len (writer->buffer, " ", 4);
}
/**
* gimp_config_writer_new_file:
......@@ -565,31 +588,6 @@ gimp_config_writer_comment (GimpConfigWriter *writer,
#undef LINE_LENGTH
}
static inline void
gimp_config_writer_flush (GimpConfigWriter *writer)
{
if (write (writer->fd, writer->buffer->str, writer->buffer->len) < 0)
g_set_error (&writer->error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,
g_strerror (errno));
g_string_truncate (writer->buffer, 0);
}
static inline void
gimp_config_writer_newline (GimpConfigWriter *writer)
{
gint i;
g_string_append_c (writer->buffer, '\n');
if (writer->comment)
g_string_append_len (writer->buffer, "# ", 2);
for (i = 0; i < writer->depth; i++)
g_string_append_len (writer->buffer, " ", 4);
}
static gboolean
gimp_config_writer_close_file (GimpConfigWriter *writer,
GError **error)
......
......@@ -439,7 +439,8 @@ gimp_scanner_parse_matrix2 (GScanner *scanner,
old_scope_id = g_scanner_set_scope (scanner, scope_id);
if (! g_scanner_scope_lookup_symbol (scanner, scope_id, "matrix"))
g_scanner_scope_add_symbol (scanner, scope_id, "matrix", 0);
g_scanner_scope_add_symbol (scanner, scope_id,
"matrix", GINT_TO_POINTER (0));
token = G_TOKEN_LEFT_PAREN;
......
......@@ -428,7 +428,7 @@ gimp_brush_generated_dirty (GimpData *data)
gbrush->mask = temp_buf_new (width * 2 + 1,
height * 2 + 1,
1, width, height, 0);
1, width, height, NULL);
centerp = temp_buf_data (gbrush->mask) + height * gbrush->mask->width + width;
......
......@@ -428,7 +428,7 @@ gimp_brush_generated_dirty (GimpData *data)
gbrush->mask = temp_buf_new (width * 2 + 1,
height * 2 + 1,
1, width, height, 0);
1, width, height, NULL);
centerp = temp_buf_data (gbrush->mask) + height * gbrush->mask->width + width;
......
......@@ -428,7 +428,7 @@ gimp_brush_generated_dirty (GimpData *data)
gbrush->mask = temp_buf_new (width * 2 + 1,
height * 2 + 1,
1, width, height, 0);
1, width, height, NULL);
centerp = temp_buf_data (gbrush->mask) + height * gbrush->mask->width + width;
......
......@@ -492,7 +492,7 @@ gimp_container_deserialize (GimpConfig *config,
if (! GIMP_CONFIG_GET_INTERFACE (child)->deserialize (GIMP_CONFIG (child),
scanner,
nest_level + 1,
FALSE))
NULL))
{
if (add_child)
g_object_unref (child);
......
......@@ -157,10 +157,13 @@ static PixelRegion distR =
{
NULL, /* data */
NULL, /* tiles */
NULL, /* curtile */
0, 0, /* offx, offy */
0, /* rowstride */
0, 0, /* w, h */
0, 0, /* x, y */
0, 0, /* w, h */
4, /* bytes */
FALSE, /* dirty */
0 /* process count */
};
......
......@@ -79,6 +79,67 @@ static inline gdouble gimp_gradient_calc_sphere_decreasing_factor (gdouble mid
static GimpDataClass *parent_class = NULL;
static inline gdouble
gimp_gradient_calc_linear_factor (gdouble middle,
gdouble pos)
{
if (pos <= middle)
{
if (middle < EPSILON)
return 0.0;
else
return 0.5 * pos / middle;
}
else
{
pos -= middle;
middle = 1.0 - middle;
if (middle < EPSILON)
return 1.0;
else
return 0.5 + 0.5 * pos / middle;
}
}
static inline gdouble
gimp_gradient_calc_curved_factor (gdouble middle,
gdouble pos)
{
if (middle < EPSILON)
middle = EPSILON;
return pow (pos, log (0.5) / log (middle));
}
static inline gdouble
gimp_gradient_calc_sine_factor (gdouble middle,
gdouble pos)
{
pos = gimp_gradient_calc_linear_factor (middle, pos);
return (sin ((-G_PI / 2.0) + G_PI * pos) + 1.0) / 2.0;
}
static inline gdouble
gimp_gradient_calc_sphere_increasing_factor (gdouble middle,
gdouble pos)
{
pos = gimp_gradient_calc_linear_factor (middle, pos) - 1.0;
return sqrt (1.0 - pos * pos); /* Works for convex increasing and concave decreasing */
}
static inline gdouble
gimp_gradient_calc_sphere_decreasing_factor (gdouble middle,
gdouble pos)
{
pos = gimp_gradient_calc_linear_factor (middle, pos);
return 1.0 - sqrt(1.0 - pos * pos); /* Works for convex decreasing and concave increasing */
}
GType
gimp_gradient_get_type (void)
......@@ -510,67 +571,6 @@ gimp_gradient_get_segment_at (GimpGradient *gradient,
return NULL;
}
static inline gdouble
gimp_gradient_calc_linear_factor (gdouble middle,
gdouble pos)
{
if (pos <= middle)
{
if (middle < EPSILON)
return 0.0;
else
return 0.5 * pos / middle;
}
else
{
pos -= middle;
middle = 1.0 - middle;
if (middle < EPSILON)
return 1.0;
else
return 0.5 + 0.5 * pos / middle;
}
}
static inline gdouble
gimp_gradient_calc_curved_factor (gdouble middle,
gdouble pos)
{
if (middle < EPSILON)
middle = EPSILON;
return pow (pos, log (0.5) / log (middle));
}
static inline gdouble
gimp_gradient_calc_sine_factor (gdouble middle,
gdouble pos)
{
pos = gimp_gradient_calc_linear_factor (middle, pos);
return (sin ((-G_PI / 2.0) + G_PI * pos) + 1.0) / 2.0;
}
static inline gdouble
gimp_gradient_calc_sphere_increasing_factor (gdouble middle,
gdouble pos)
{
pos = gimp_gradient_calc_linear_factor (middle, pos) - 1.0;
return sqrt (1.0 - pos * pos); /* Works for convex increasing and concave decreasing */
}
static inline gdouble
gimp_gradient_calc_sphere_decreasing_factor (gdouble middle,
gdouble pos)
{
pos = gimp_gradient_calc_linear_factor (middle, pos);
return 1.0 - sqrt(1.0 - pos * pos); /* Works for convex decreasing and concave increasing */
}
/* gradient segment functions */
GimpGradientSegment *
......
......@@ -1457,7 +1457,7 @@ gimp_image_is_empty (const GimpImage *gimage)
GimpLayer *
gimp_image_floating_sel (const GimpImage *gimage)
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
return gimage->floating_sel;
}
......
......@@ -108,7 +108,7 @@ PangoColor grad1ent[] =
PangoColor foregr0und = { 37522, 51914, 57568 };
PangoColor backgr0und = { 0, 0, 0 };
static GimpAboutInfo about_info = { 0 };
static GimpAboutInfo about_info = { 0, };
static gboolean pp = FALSE;
static gboolean about_dialog_load_logo (GtkWidget *window);
......
......@@ -270,7 +270,7 @@ palette_import_dialog_new (Gimp *gimp)
/* Palette file name entry */
import_dialog->filename_entry =
gimp_file_entry_new (_("Select palette file"), 0, FALSE, FALSE);
gimp_file_entry_new (_("Select palette file"), NULL, FALSE, FALSE);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 2,
NULL, 0.0, 0.5,
import_dialog->filename_entry, 1, FALSE);
......
......@@ -161,7 +161,7 @@ gimp_recent_list_update_item (GList *items,
static void
parse_info_init (ParseInfo *info)
{
info->states = g_slist_prepend (NULL, STATE_START);
info->states = g_slist_prepend (NULL, GINT_TO_POINTER (STATE_START));
info->items = NULL;