diff options
author | Pavel Cisler <pavel@eazel.com> | 2000-09-05 20:38:10 +0000 |
---|---|---|
committer | Pavel Cisler <pce@src.gnome.org> | 2000-09-05 20:38:10 +0000 |
commit | add783964b40df9dcae367f7ee3985c00e48cf8e (patch) | |
tree | 5d687872f47da87a4da2892d97288040261f5ed7 /librsvg | |
parent | 1b18a656209f630d30bc0e68eb8842950644e6ba (diff) | |
download | nautilus-add783964b40df9dcae367f7ee3985c00e48cf8e.tar.gz |
Fix all the warnings -Wuninitialized found. Quite a number of them were
2000-09-05 Pavel Cisler <pavel@eazel.com>
* components/help/converters/gnome-db2html2/gdb3html.c:
(xml_parse_document):
* components/help/hyperbola-nav-index.c: (end_element):
* components/services/summary/nautilus-view/nautilus-summary-view.c
: (logout_button_cb):
* components/services/time/service/trilobite-eazel-time-service.c:
(trilobite_eazel_time_service_do_http_request):
* components/tree/nautilus-tree-view.c:
* configure.in:
* libnautilus-extensions/bonobo-stream-vfs.c:
(bonobo_stream_vfs_open):
* libnautilus-extensions/nautilus-background.c:
(nautilus_background_draw), (nautilus_background_draw_aa):
* libnautilus-extensions/nautilus-customization-data.c:
(nautilus_customization_data_new):
* libnautilus-extensions/nautilus-directory-background.c:
(nautilus_directory_background_write_desktop_settings):
* libnautilus-extensions/nautilus-file-operations.c:
(nautilus_file_operations_move_to_trash), (do_empty_trash):
* libnautilus-extensions/nautilus-file.c: (nautilus_file_dump):
* libnautilus-extensions/nautilus-icon-canvas-item.c:
(draw_or_measure_label_text), (emblem_layout_next):
* libnautilus-extensions/nautilus-icon-factory.c:
(get_image_from_cache):
* libnautilus-extensions/nautilus-icon-text-item.c:
(iti_paint_text):
* libnautilus-extensions/nautilus-list.c: (draw_cell), (draw_row):
* libnautilus-extensions/nautilus-mime-actions.c:
(nautilus_mime_add_application_to_short_list_for_uri):
* libnautilus-extensions/nautilus-program-chooser.c:
(program_file_pair_get_short_status_text),
(program_file_pair_get_long_status_text):
* libnautilus-extensions/nautilus-program-choosing.c:
(nautilus_choose_component_for_file),
(nautilus_choose_application_for_file):
* libnautilus-extensions/nautilus-scalable-font.c:
(nautilus_scalable_font_draw_text_lines_with_dimensions):
* libnautilus-extensions/nautilus-theme.c:
(nautilus_theme_make_selector):
* librsvg/rsvg-ft.c: (rsvg_ft_get_glyph):
* librsvg/test-ft-gtk.c: (set_text):
* librsvg/test-ft.c: (save_pixbuf_to_file_internal),
(save_pixbuf_to_file):
* librsvg/test-rsvg.c: (save_pixbuf_to_file_internal),
(save_pixbuf_to_file):
* src/file-manager/fm-directory-view.c: (display_pending_files),
(compute_menu_item_info):
* src/file-manager/fm-icon-view.c: (compute_menu_item_info):
* src/file-manager/fm-list-view.c: (get_column_from_attribute):
* src/nautilus-application.c: (nautilus_application_startup):
* src/nautilus-search-bar-criterion.c:
(nautilus_search_bar_criterion_next_new),
(nautilus_search_bar_criterion_get_location),
(get_date_modified_location_for):
* src/nautilus-sidebar-tabs.c: (draw_one_tab_themed),
(draw_or_layout_all_tabs):
* src/nautilus-toolbar.c: (nautilus_toolbar_size_allocate):
* src/nautilus-window-manage-views.c:
(nautilus_window_get_current_location_title):
* test/test-nautilus-label.c: (justification_changed_callback):
Fix all the warnings -Wuninitialized found.
Quite a number of them were actual bugs.
Turn on -Wuninitialized in configure.in now that ORBit generates
warning-free code.
Diffstat (limited to 'librsvg')
-rw-r--r-- | librsvg/rsvg-ft.c | 2 | ||||
-rw-r--r-- | librsvg/test-ft-gtk.c | 5 | ||||
-rw-r--r-- | librsvg/test-ft.c | 126 | ||||
-rw-r--r-- | librsvg/test-rsvg.c | 55 |
4 files changed, 110 insertions, 78 deletions
diff --git a/librsvg/rsvg-ft.c b/librsvg/rsvg-ft.c index 837df054d..35d42dd75 100644 --- a/librsvg/rsvg-ft.c +++ b/librsvg/rsvg-ft.c @@ -480,6 +480,8 @@ rsvg_ft_get_glyph (RsvgFTFont *font, FT_UInt glyph_ix, double sx, double sy, FT_Vector delta; double expansion, scale; + result = NULL; + if (glyph_ix == 0) return NULL; diff --git a/librsvg/test-ft-gtk.c b/librsvg/test-ft-gtk.c index ce907afe6..d0605a443 100644 --- a/librsvg/test-ft-gtk.c +++ b/librsvg/test-ft-gtk.c @@ -368,6 +368,8 @@ static void set_text (TestCtx *ctx, const char *fn) { int n_lines; char **lines; + lines = NULL; + f = fopen (fn, "r"); if (f == NULL) { g_warning ("Error opening file %s\n", fn); @@ -384,6 +386,9 @@ static void set_text (TestCtx *ctx, const char *fn) { else if (!(n_lines & (n_lines - 1))) { lines = g_renew (char *, lines, n_lines << 1); } + + g_assert (lines != NULL); + len = strlen (line); if (len > 0 && line[len - 1] == '\n') line[--len] = 0; diff --git a/librsvg/test-ft.c b/librsvg/test-ft.c index d21eadcf5..710ad3047 100644 --- a/librsvg/test-ft.c +++ b/librsvg/test-ft.c @@ -115,78 +115,65 @@ art_render_freetype(ArtRender * render, const RsvgFTFont *font, /* utility routine for saving a pixbuf to a png file. * This was adapted from Iain Holmes' code in gnome-iconedit, and probably * should be in a utility library, possibly in gdk-pixbuf itself. + * + * It is split up into save_pixbuf_to_file and save_pixbuf_to_file_internal + * to work around a gcc warning about handle possibly getting clobbered by + * longjmp. Declaring handle 'volatile FILE *' didn't work as it should have. */ -static gboolean save_pixbuf_to_file(GdkPixbuf * pixbuf, char *filename) +static gboolean +save_pixbuf_to_file_internal (GdkPixbuf *pixbuf, char *filename, FILE *handle) { - FILE *handle; - char *buffer; + char *buffer; gboolean has_alpha; int width, height, depth, rowstride; - guchar *pixels; - png_structp png_ptr; - png_infop info_ptr; - png_text text[2]; - int i; - - g_return_val_if_fail(pixbuf != NULL, FALSE); - g_return_val_if_fail(filename != NULL, FALSE); - g_return_val_if_fail(filename[0] != '\0', FALSE); - - if (!strcmp(filename, "-")) - handle = stdout; - else - handle = fopen(filename, "wb"); - if (handle == NULL) { - return FALSE; - } - - png_ptr = - png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, - NULL); + guchar *pixels; + png_structp png_ptr; + png_infop info_ptr; + png_text text[2]; + int i; + + png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (png_ptr == NULL) { - fclose(handle); return FALSE; } - info_ptr = png_create_info_struct(png_ptr); + info_ptr = png_create_info_struct (png_ptr); if (info_ptr == NULL) { - png_destroy_write_struct(&png_ptr, (png_infopp) NULL); - fclose(handle); - return FALSE; + png_destroy_write_struct (&png_ptr, (png_infopp)NULL); + return FALSE; } - if (setjmp(png_ptr->jmpbuf)) { - png_destroy_write_struct(&png_ptr, &info_ptr); - fclose(handle); + if (setjmp (png_ptr->jmpbuf)) { + png_destroy_write_struct (&png_ptr, &info_ptr); return FALSE; } - png_init_io(png_ptr, handle); + png_init_io (png_ptr, (FILE *)handle); - has_alpha = gdk_pixbuf_get_has_alpha(pixbuf); - width = gdk_pixbuf_get_width(pixbuf); - height = gdk_pixbuf_get_height(pixbuf); - depth = gdk_pixbuf_get_bits_per_sample(pixbuf); - pixels = gdk_pixbuf_get_pixels(pixbuf); - rowstride = gdk_pixbuf_get_rowstride(pixbuf); + has_alpha = gdk_pixbuf_get_has_alpha (pixbuf); + width = gdk_pixbuf_get_width (pixbuf); + height = gdk_pixbuf_get_height (pixbuf); + depth = gdk_pixbuf_get_bits_per_sample (pixbuf); + pixels = gdk_pixbuf_get_pixels (pixbuf); + rowstride = gdk_pixbuf_get_rowstride (pixbuf); - png_set_IHDR(png_ptr, info_ptr, width, height, - depth, PNG_COLOR_TYPE_RGB_ALPHA, - PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_DEFAULT, - PNG_FILTER_TYPE_DEFAULT); + png_set_IHDR (png_ptr, info_ptr, width, height, + depth, PNG_COLOR_TYPE_RGB_ALPHA, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, + PNG_FILTER_TYPE_DEFAULT); /* Some text to go with the png image */ text[0].key = "Title"; text[0].text = filename; text[0].compression = PNG_TEXT_COMPRESSION_NONE; text[1].key = "Software"; - text[1].text = "Test-ft"; + text[1].text = "Test-Rsvg"; text[1].compression = PNG_TEXT_COMPRESSION_NONE; - png_set_text(png_ptr, info_ptr, text, 2); + png_set_text (png_ptr, info_ptr, text, 2); /* Write header data */ - png_write_info(png_ptr, info_ptr); + png_write_info (png_ptr, info_ptr); /* if there is no alpha in the data, allocate buffer to expand into */ if (has_alpha) { @@ -194,12 +181,12 @@ static gboolean save_pixbuf_to_file(GdkPixbuf * pixbuf, char *filename) } else { buffer = g_malloc(4 * width); } - - /* pump the raster data into libpng, one scan line at a time */ + + /* pump the raster data into libpng, one scan line at a time */ for (i = 0; i < height; i++) { if (has_alpha) { png_bytep row_pointer = pixels; - png_write_row(png_ptr, row_pointer); + png_write_row (png_ptr, row_pointer); } else { /* expand RGB to RGBA using an opaque alpha value */ int x; @@ -211,19 +198,44 @@ static gboolean save_pixbuf_to_file(GdkPixbuf * pixbuf, char *filename) *buffer_ptr++ = *source_ptr++; *buffer_ptr++ = 255; } - png_write_row(png_ptr, (png_bytep) buffer); + png_write_row (png_ptr, (png_bytep) buffer); } pixels += rowstride; } + + png_write_end (png_ptr, info_ptr); + png_destroy_write_struct (&png_ptr, &info_ptr); + + g_free (buffer); - png_write_end(png_ptr, info_ptr); - png_destroy_write_struct(&png_ptr, &info_ptr); + return TRUE; +} - g_free(buffer); +static gboolean +save_pixbuf_to_file (GdkPixbuf *pixbuf, char *filename) +{ + FILE *handle; + gboolean result; - if (handle != stdout) - fclose(handle); - return TRUE; + g_return_val_if_fail (pixbuf != NULL, FALSE); + g_return_val_if_fail (filename != NULL, FALSE); + g_return_val_if_fail (filename[0] != '\0', FALSE); + + if (!strcmp (filename, "-")) { + handle = stdout; + } else { + handle = fopen (filename, "wb"); + } + + if (handle == NULL) { + return FALSE; + } + + result = save_pixbuf_to_file_internal (pixbuf, filename, handle); + if (!result || handle != stdout) + fclose (handle); + + return result; } static void test_pixmap_destroy(guchar * pixels, gpointer data) diff --git a/librsvg/test-rsvg.c b/librsvg/test-rsvg.c index 55c3395f5..49c591619 100644 --- a/librsvg/test-rsvg.c +++ b/librsvg/test-rsvg.c @@ -40,11 +40,14 @@ /* utility routine for saving a pixbuf to a png file. * This was adapted from Iain Holmes' code in gnome-iconedit, and probably * should be in a utility library, possibly in gdk-pixbuf itself. + * + * It is split up into save_pixbuf_to_file and save_pixbuf_to_file_internal + * to work around a gcc warning about handle possibly getting clobbered by + * longjmp. Declaring handle 'volatile FILE *' didn't work as it should have. */ static gboolean -save_pixbuf_to_file (GdkPixbuf *pixbuf, char *filename) +save_pixbuf_to_file_internal (GdkPixbuf *pixbuf, char *filename, FILE *handle) { - FILE *handle; char *buffer; gboolean has_alpha; int width, height, depth, rowstride; @@ -53,39 +56,24 @@ save_pixbuf_to_file (GdkPixbuf *pixbuf, char *filename) png_infop info_ptr; png_text text[2]; int i; - - g_return_val_if_fail (pixbuf != NULL, FALSE); - g_return_val_if_fail (filename != NULL, FALSE); - g_return_val_if_fail (filename[0] != '\0', FALSE); - - if (!strcmp (filename, "-")) - handle = stdout; - else - handle = fopen (filename, "wb"); - if (handle == NULL) { - return FALSE; - } - + png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (png_ptr == NULL) { - fclose (handle); return FALSE; } info_ptr = png_create_info_struct (png_ptr); if (info_ptr == NULL) { png_destroy_write_struct (&png_ptr, (png_infopp)NULL); - fclose (handle); return FALSE; } if (setjmp (png_ptr->jmpbuf)) { png_destroy_write_struct (&png_ptr, &info_ptr); - fclose (handle); return FALSE; } - png_init_io (png_ptr, handle); + png_init_io (png_ptr, (FILE *)handle); has_alpha = gdk_pixbuf_get_has_alpha (pixbuf); width = gdk_pixbuf_get_width (pixbuf); @@ -145,11 +133,36 @@ save_pixbuf_to_file (GdkPixbuf *pixbuf, char *filename) g_free (buffer); - if (handle != stdout) - fclose (handle); return TRUE; } +static gboolean +save_pixbuf_to_file (GdkPixbuf *pixbuf, char *filename) +{ + FILE *handle; + gboolean result; + + g_return_val_if_fail (pixbuf != NULL, FALSE); + g_return_val_if_fail (filename != NULL, FALSE); + g_return_val_if_fail (filename[0] != '\0', FALSE); + + if (!strcmp (filename, "-")) { + handle = stdout; + } else { + handle = fopen (filename, "wb"); + } + + if (handle == NULL) { + return FALSE; + } + + result = save_pixbuf_to_file_internal (pixbuf, filename, handle); + if (!result || handle != stdout) + fclose (handle); + + return result; +} + int main (int argc, char **argv) { |