2011-03-13 Paul Eggert <eggert@cs.ucla.edu>
+ Fix more problems found by GCC 4.5.2's static checks.
+
+ * gtkutil.c (xg_get_pixbuf_from_pixmap): Add cast from char *
+ to unsigned char * to avoid compiler diagnostic.
+ (xg_free_frame_widgets): Make it clear that a local variable is
+ needed only if USE_GTK_TOOLTIP.
+ (gdk_window_get_screen): Make it clear that this macro is needed
+ only if USE_GTK_TOOLTIP.
+ (int_gtk_range_get_value): New function, which avoids a diagnostic
+ from gcc -Wbad-function-cast.
+ (xg_set_toolkit_scroll_bar_thumb): Use it.
+ (xg_tool_bar_callback, xg_tool_item_stale_p): Rewrite to avoid
+ diagnostic from gcc -Wbad-function-cast.
+ (get_utf8_string, xg_get_file_with_chooser):
+ Rename locals to avoid shadowing.
+ (create_dialog): Move locals to avoid shadowing.
+
+ * xgselect.c (xg_select): Remove unused var.
+
+ * image.c (four_corners_best): Mark locals as initialized.
+ (gif_load): Initialize transparent_p to zero (Bug#8238).
+ Mark another local as initialized.
+ (my_png_error, my_error_exit): Mark with NO_RETURN.
+
+ * image.c (clear_image_cache): Now static.
+ (DIM, HAVE_STDLIB_H_1): Remove unused macros.
+ (xpm_load): Redo to avoid "discards qualifiers" gcc warning.
+ (x_edge_detection): Remove unnecessary cast that
+ gcc -Wbad-function-cast diagnoses.
+ (gif_load): Fix pointer signedness.
+ (clear_image_cache, xbm_read_bitmap_data, x_detect_edges):
+ (jpeg_load, gif_load): Rename locals to avoid shadowing.
+
+2011-03-11 Paul Eggert <eggert@cs.ucla.edu>
+
Improve quality of tests for time stamp overflow.
For example, without this patch (encode-time 0 0 0 1 1
1152921504606846976) returns the obviously-bogus value (-948597
#endif
#ifndef HAVE_GTK3
+#ifdef USE_GTK_TOOLTIP
#define gdk_window_get_screen(w) gdk_drawable_get_screen (w)
+#endif
#define gdk_window_get_geometry(w, a, b, c, d) \
- gdk_window_get_geometry (w, a, b, c, d, 0)
+ gdk_window_get_geometry (w, a, b, c, d, 0)
#define gdk_x11_window_lookup_for_display(d, w) \
gdk_xid_table_lookup_for_display (d, w)
#define GDK_KEY_g GDK_g
#define XG_BIN_CHILD(x) gtk_bin_get_child (GTK_BIN (x))
+/* Get the current value of the range, truncated to an integer. */
+static int
+int_gtk_range_get_value (GtkRange *range)
+{
+ return gtk_range_get_value (range);
+}
+
\f
/***********************************************************************
Display handling functions
~0, XYPixmap);
if (!xim) return 0;
- tmp_buf = gdk_pixbuf_new_from_data (xim->data,
+ tmp_buf = gdk_pixbuf_new_from_data ((guchar *) xim->data,
GDK_COLORSPACE_RGB,
FALSE,
xim->bitmap_unit,
width = gdk_pixbuf_get_width (icon_buf);
height = gdk_pixbuf_get_height (icon_buf);
-
+
if (mask)
{
GdkPixbuf *mask_buf = xg_get_pixbuf_from_pixmap (f, mask);
Gtk+ assumes the pixmap is always there. */
icon_buf = xg_get_pixbuf_from_pix_and_mask (f, img->pixmap, img->mask);
- if (icon_buf)
+ if (icon_buf)
{
if (! old_widget)
old_widget = GTK_IMAGE (gtk_image_new_from_pixbuf (icon_buf));
gsize bytes_written;
unsigned char *p = (unsigned char *)str;
char *cp, *up;
- GError *error = NULL;
+ GError *err = NULL;
while (! (cp = g_locale_to_utf8 ((char *)p, -1, &bytes_read,
- &bytes_written, &error))
- && error->code == G_CONVERT_ERROR_ILLEGAL_SEQUENCE)
+ &bytes_written, &err))
+ && err->code == G_CONVERT_ERROR_ILLEGAL_SEQUENCE)
{
++nr_bad;
p += bytes_written+1;
- g_error_free (error);
- error = NULL;
+ g_error_free (err);
+ err = NULL;
}
- if (error)
+ if (err)
{
- g_error_free (error);
- error = NULL;
+ g_error_free (err);
+ err = NULL;
}
if (cp) g_free (cp);
p = (unsigned char *)str;
while (! (cp = g_locale_to_utf8 ((char *)p, -1, &bytes_read,
- &bytes_written, &error))
- && error->code == G_CONVERT_ERROR_ILLEGAL_SEQUENCE)
+ &bytes_written, &err))
+ && err->code == G_CONVERT_ERROR_ILLEGAL_SEQUENCE)
{
strncpy (up, (char *)p, bytes_written);
sprintf (up + bytes_written, "\\%03o", p[bytes_written]);
up[bytes_written+4] = '\0';
up += bytes_written+4;
p += bytes_written+1;
- g_error_free (error);
- error = NULL;
+ g_error_free (err);
+ err = NULL;
}
if (cp)
strcat (utf8_str, cp);
g_free (cp);
}
- if (error)
+ if (err)
{
- g_error_free (error);
- error = NULL;
+ g_error_free (err);
+ err = NULL;
}
}
return utf8_str;
{
if (FRAME_GTK_OUTER_WIDGET (f))
{
+#ifdef USE_GTK_TOOLTIP
struct x_output *x = f->output_data.x;
+#endif
gtk_widget_destroy (FRAME_GTK_OUTER_WIDGET (f));
FRAME_X_WINDOW (f) = 0; /* Set to avoid XDestroyWindow in xterm.c */
FRAME_GTK_OUTER_WIDGET (f) = 0;
GtkDialog *wd = GTK_DIALOG (wdialog);
GtkBox *cur_box = GTK_BOX (gtk_dialog_get_action_area (wd));
widget_value *item;
- GtkWidget *wvbox;
- GtkWidget *whbox_up;
GtkWidget *whbox_down;
/* If the number of buttons is greater than 4, make two rows of buttons
if (make_two_rows)
{
- wvbox = gtk_vbox_new (TRUE, button_spacing);
- whbox_up = gtk_hbox_new (FALSE, 0);
+ GtkWidget *wvbox = gtk_vbox_new (TRUE, button_spacing);
+ GtkWidget *whbox_up = gtk_hbox_new (FALSE, 0);
whbox_down = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (cur_box, wvbox, FALSE, FALSE, 0);
int mustmatch_p, int only_dir_p,
xg_get_file_func *func)
{
- char message[1024];
+ char msgbuf[1024];
GtkWidget *filewin, *wtoggle, *wbox, *wmessage;
GtkWindow *gwin = GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f));
if (x_gtk_file_dialog_help_text)
{
- message[0] = '\0';
+ msgbuf[0] = '\0';
/* Gtk+ 2.10 has the file name text entry box integrated in the dialog.
Show the C-l help text only for versions < 2.10. */
if (gtk_check_version (2, 10, 0) && action != GTK_FILE_CHOOSER_ACTION_SAVE)
- strcat (message, "\nType C-l to display a file name text entry box.\n");
- strcat (message, "\nIf you don't like this file selector, use the "
+ strcat (msgbuf, "\nType C-l to display a file name text entry box.\n");
+ strcat (msgbuf, "\nIf you don't like this file selector, use the "
"corresponding\nkey binding or customize "
"use-file-dialog to turn it off.");
- wmessage = gtk_label_new (message);
+ wmessage = gtk_label_new (msgbuf);
gtk_widget_show (wmessage);
}
changed = 1;
}
- if (changed || (int) gtk_range_get_value (GTK_RANGE (wscroll)) != value)
+ if (changed || int_gtk_range_get_value (GTK_RANGE (wscroll)) != value)
{
BLOCK_INPUT;
ignore_gtk_scrollbar to make the callback do nothing */
xg_ignore_gtk_scrollbar = 1;
- if ((int) gtk_range_get_value (GTK_RANGE (wscroll)) != value)
+ if (int_gtk_range_get_value (GTK_RANGE (wscroll)) != value)
gtk_range_set_value (GTK_RANGE (wscroll), (gdouble)value);
else if (changed)
gtk_adjustment_changed (adj);
{
/* The EMACS_INT cast avoids a warning. */
int idx = (int) (EMACS_INT) client_data;
- int mod = (int) (EMACS_INT) g_object_get_data (G_OBJECT (w),
- XG_TOOL_BAR_LAST_MODIFIER);
+ gpointer gmod = g_object_get_data (G_OBJECT (w), XG_TOOL_BAR_LAST_MODIFIER);
+ int mod = (int) (EMACS_INT) gmod;
FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (w), XG_FRAME_DATA);
Lisp_Object key, frame;
}
else
{
- Pixmap old_img
- = (Pixmap) g_object_get_data (G_OBJECT (wimage),
- XG_TOOL_BAR_IMAGE_DATA);
+ gpointer gold_img = g_object_get_data (G_OBJECT (wimage),
+ XG_TOOL_BAR_IMAGE_DATA);
+ Pixmap old_img = (Pixmap) gold_img;
if (old_img != img->pixmap)
return 1;
}
Image types
***********************************************************************/
-/* Value is the number of elements of vector VECTOR. */
-
-#define DIM(VECTOR) (sizeof (VECTOR) / sizeof *(VECTOR))
-
/* List of supported image types. Use define_image_type to add new
types. Use lookup_image_type to find a type for a given symbol. */
four_corners_best (XImagePtr_or_DC ximg, int *corners,
unsigned long width, unsigned long height)
{
- RGB_PIXEL_COLOR corner_pixels[4], best;
+ RGB_PIXEL_COLOR corner_pixels[4], best IF_LINT (= 0);
int i, best_count;
if (corners && corners[BOT_CORNER] >= 0)
If image-cache-eviction-delay is non-nil, this frees images in the cache
which weren't displayed for at least that many seconds. */
-void
+static void
clear_image_cache (struct frame *f, Lisp_Object filter)
{
struct image_cache *c = FRAME_IMAGE_CACHE (f);
FOR_EACH_FRAME (tail, frame)
{
- struct frame *f = XFRAME (frame);
- if (FRAME_IMAGE_CACHE (f) == c)
- clear_current_matrices (f);
+ struct frame *fr = XFRAME (frame);
+ if (FRAME_IMAGE_CACHE (fr) == c)
+ clear_current_matrices (fr);
}
++windows_or_buffers_changed;
if (LA1 == XBM_TK_NUMBER)
{
- char *p = strrchr (buffer, '_');
- p = p ? p + 1 : buffer;
- if (strcmp (p, "width") == 0)
+ char *q = strrchr (buffer, '_');
+ q = q ? q + 1 : buffer;
+ if (strcmp (q, "width") == 0)
*width = value;
- else if (strcmp (p, "height") == 0)
+ else if (strcmp (q, "height") == 0)
*height = value;
}
expect (XBM_TK_NUMBER);
{
Lisp_Object name;
Lisp_Object color;
+ char *empty_string = (char *) "";
if (!CONSP (XCAR (tail)))
{
- xpm_syms[i].name = "";
- xpm_syms[i].value = "";
+ xpm_syms[i].name = empty_string;
+ xpm_syms[i].value = empty_string;
continue;
}
name = XCAR (XCAR (tail));
strcpy (xpm_syms[i].name, SSDATA (name));
}
else
- xpm_syms[i].name = "";
+ xpm_syms[i].name = empty_string;
if (STRINGP (color))
{
xpm_syms[i].value = (char *) alloca (SCHARS (color) + 1);
strcpy (xpm_syms[i].value, SSDATA (color));
}
else
- xpm_syms[i].value = "";
+ xpm_syms[i].value = empty_string;
}
}
for (x = 1; x < img->width - 1; ++x, ++p)
{
- int r, g, b, y1, x1;
+ int r, g, b, yy, xx;
r = g = b = i = 0;
- for (y1 = y - 1; y1 < y + 2; ++y1)
- for (x1 = x - 1; x1 < x + 2; ++x1, ++i)
+ for (yy = y - 1; yy < y + 2; ++yy)
+ for (xx = x - 1; xx < x + 2; ++xx, ++i)
if (matrix[i])
{
- XColor *t = COLOR (colors, x1, y1);
+ XColor *t = COLOR (colors, xx, yy);
r += matrix[i] * t->red;
g += matrix[i] * t->green;
b += matrix[i] * t->blue;
color_adjust = make_number (0xffff / 2);
if (i == 9 && NUMBERP (color_adjust))
- x_detect_edges (f, img, trans, (int) XFLOATINT (color_adjust));
+ x_detect_edges (f, img, trans, XFLOATINT (color_adjust));
}
/* Error and warning handlers installed when the PNG library
is initialized. */
+static void my_png_error (png_struct *, const char *) NO_RETURN;
static void
my_png_error (png_struct *png_ptr, const char *msg)
{
/* Work around a warning about HAVE_STDLIB_H being redefined in
jconfig.h. */
#ifdef HAVE_STDLIB_H
-#define HAVE_STDLIB_H_1
#undef HAVE_STDLIB_H
#endif /* HAVE_STLIB_H */
};
+static void my_error_exit (j_common_ptr) NO_RETURN;
static void
my_error_exit (j_common_ptr cinfo)
{
if (rc == 1)
{
/* Called from my_error_exit. Display a JPEG error. */
- char buffer[JMSG_LENGTH_MAX];
- cinfo.err->format_message ((j_common_ptr) &cinfo, buffer);
+ char buf[JMSG_LENGTH_MAX];
+ cinfo.err->format_message ((j_common_ptr) &cinfo, buf);
image_error ("Error reading JPEG image `%s': %s", img->spec,
- build_string (buffer));
+ build_string (buf));
}
/* Close the input file and destroy the JPEG object. */
Lisp_Object file, specified_file;
Lisp_Object specified_data;
int rc, width, height, x, y, i;
- boolean transparent_p;
+ boolean transparent_p = 0;
XImagePtr ximg;
ColorMapObject *gif_color_map;
unsigned long pixel_colors[256];
int ino, image_height, image_width;
gif_memory_source memsrc;
unsigned char *raster;
- unsigned int transparency_color_index;
+ unsigned int transparency_color_index IF_LINT (= 0);
specified_file = image_spec_value (img->spec, QCfile, NULL);
specified_data = image_spec_value (img->spec, QCdata, NULL);
}
/* Open the GIF file. */
- gif = fn_DGifOpenFileName (SDATA (file));
+ gif = fn_DGifOpenFileName (SSDATA (file));
if (gif == NULL)
{
image_error ("Cannot open `%s'", file, Qnil);
for (x = 0; x < image_width; x++)
{
- int i = raster[(y * image_width) + x];
+ int c = raster[(y * image_width) + x];
XPutPixel (ximg, x + img->corners[LEFT_CORNER],
- row + img->corners[TOP_CORNER], pixel_colors[i]);
+ row + img->corners[TOP_CORNER], pixel_colors[c]);
}
row += interlace_increment[pass];
for (y = 0; y < image_height; ++y)
for (x = 0; x < image_width; ++x)
{
- int i = raster[y * image_width + x];
+ int c = raster[y * image_width + x];
XPutPixel (ximg, x + img->corners[LEFT_CORNER],
- y + img->corners[TOP_CORNER], pixel_colors[i]);
+ y + img->corners[TOP_CORNER], pixel_colors[c]);
}
}
GMainContext *context = g_main_context_default ();
int have_wfds = wfds != NULL;
int n_gfds = 0, our_tmo = 0, retval = 0, our_fds = 0;
- int prio, i, nfds, tmo_in_millisec;
+ int i, nfds, tmo_in_millisec;
if (rfds) memcpy (&all_rfds, rfds, sizeof (all_rfds));
else FD_ZERO (&all_rfds);
g_main_context_pending (context);
do {
- if (n_gfds > gfds_size)
+ if (n_gfds > gfds_size)
{
- while (n_gfds > gfds_size)
+ while (n_gfds > gfds_size)
gfds_size *= 2;
xfree (gfds);
gfds = xmalloc (sizeof (*gfds) * gfds_size);
gfds_size);
} while (n_gfds > gfds_size);
- for (i = 0; i < n_gfds; ++i)
+ for (i = 0; i < n_gfds; ++i)
{
if (gfds[i].events & G_IO_IN)
{
else
{
EMACS_TIME difference;
-
+
EMACS_SUB_TIME (difference, tmo, *timeout);
if (EMACS_TIME_NEG_P (difference)) our_tmo = 1;
}
if (nfds < 0)
retval = nfds;
- else if (nfds > 0)
+ else if (nfds > 0)
{
for (i = 0; i < max_fds+1; ++i)
{
if (our_fds > 0 || (nfds == 0 && our_tmo))
{
-
+
/* If Gtk+ is in use eventually gtk_main_iteration will be called,
unless retval is zero. */
#ifdef USE_GTK
g_main_context_dispatch (context);
/* To not have to recalculate timeout, return like this. */
- if (retval == 0)
+ if (retval == 0)
{
retval = -1;
errno = EINTR;
gfds = xmalloc (sizeof (*gfds)*gfds_size);
#endif /* defined (USE_GTK) || defined (HAVE_GCONF) */
}
-