diff --git a/src/ChangeLog b/src/ChangeLog index cbb0999d50e..8b651569acc 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,36 @@ +2011-06-10 Paul Eggert + + Fix minor problems found by static checking. + + * image.c (PixelGetMagickColor): Declare if ImageMagick headers don't. + + Make identifiers static if they are not used in other modules. + * data.c (Qcompiled_function, Qframe, Qvector): + * image.c (QimageMagick, Qsvg): + * minibuf.c (Qmetadata): + * window.c (resize_window_check, resize_root_window): Now static. + * window.h (resize_window_check, resize_root_window): Remove decls. + + * window.c (window_deletion_count, delete_deletable_window): + Remove; unused. + (window_body_lines): Now static. + (Fdelete_other_windows_internal): Mark vars as initialized. + Make sure 'resize_failed' is initialized. + (run_window_configuration_change_hook): Rename local to avoid shadowing. + (resize_window_apply): Remove unused local. + * window.h (delete_deletable_window): Remove decl. + + * image.c (gif_load, svg_load_image): Rename locals to avoid shadowing. + (imagemagick_load_image): Fix pointer signedness problem by changing + last arg from unsigned char * to char *. All uses changed. + Also, fix a local for similar reasons. + Remove unused locals. Remove locals to avoid shadowing. + (fn_rsvg_handle_free): Remove; unused. + (svg_load, svg_load_image): Fix pointer signedness problem. + (imagemagick_load_image): Don't use garbage pointer image_wand. + + * ftfont.c (ftfont_get_metrics, ftfont_drive_otf): Remove unused locals. + 2011-06-10 Chong Yidong * image.c (gif_load): Fix omitted cast error introduced by diff --git a/src/data.c b/src/data.c index a41ffe7a1f6..57d7753e393 100644 --- a/src/data.c +++ b/src/data.c @@ -90,7 +90,8 @@ static Lisp_Object Qsymbol, Qstring, Qcons, Qmarker, Qoverlay; Lisp_Object Qwindow; static Lisp_Object Qfloat, Qwindow_configuration; static Lisp_Object Qprocess; -Lisp_Object Qcompiled_function, Qbuffer, Qframe, Qvector; +static Lisp_Object Qcompiled_function, Qframe, Qvector; +Lisp_Object Qbuffer; static Lisp_Object Qchar_table, Qbool_vector, Qhash_table; static Lisp_Object Qsubrp, Qmany, Qunevalled; Lisp_Object Qfont_spec, Qfont_entity, Qfont_object; diff --git a/src/ftfont.c b/src/ftfont.c index cd8829a3e51..5037d54bc2f 100644 --- a/src/ftfont.c +++ b/src/ftfont.c @@ -1612,7 +1612,6 @@ ftfont_get_metrics (MFLTFont *font, MFLTGlyphString *gstring, if (g->code != FONT_INVALID_CODE) { FT_Glyph_Metrics *m; - int lbearing, rbearing, ascent, descent, xadv; if (FT_Load_Glyph (ft_face, g->code, FT_LOAD_DEFAULT) != 0) abort (); @@ -1867,7 +1866,6 @@ ftfont_drive_otf (MFLTFont *font, { MFLTGlyph *g; int min_from, max_to; - int j; int feature_idx = otfg->positioning_type >> 4; g = out->glyphs + out->used; diff --git a/src/image.c b/src/image.c index b6f54f01e95..f36e097b58c 100644 --- a/src/image.c +++ b/src/image.c @@ -7146,12 +7146,12 @@ gif_load (struct frame *f, struct image *img) /* Which sub-image are we to display? */ { - Lisp_Object index = image_spec_value (img->spec, QCindex, NULL); - idx = INTEGERP (index) ? XFASTINT (index) : 0; + Lisp_Object image_number = image_spec_value (img->spec, QCindex, NULL); + idx = INTEGERP (image_number) ? XFASTINT (image_number) : 0; if (idx < 0 || idx >= gif->ImageCount) { image_error ("Invalid image number `%s' in image `%s'", - index, img->spec); + image_number, img->spec); fn_DGifCloseFile (gif); return 0; } @@ -7365,7 +7365,7 @@ gif_load (struct frame *f, struct image *img) ***********************************************************************/ #if defined (HAVE_IMAGEMAGICK) -Lisp_Object Qimagemagick; +static Lisp_Object Qimagemagick; static int imagemagick_image_p (Lisp_Object); static int imagemagick_load (struct frame *, struct image *); @@ -7456,6 +7456,14 @@ imagemagick_image_p (Lisp_Object object) #define DrawRectangle DrawRectangleGif #include +/* ImageMagick 6.5.3 through 6.6.5 hid PixelGetMagickColor for some reason. + Emacs seems to work fine with the hidden version, so unhide it. */ +#include +#if 0x653 <= MagickLibVersion && MagickLibVersion <= 0x665 +extern WandExport void PixelGetMagickColor (const PixelWand *, + MagickPixelPacket *); +#endif + /* Helper function for imagemagick_load, which does the actual loading given contents and size, apart from frame and image structures, passed from imagemagick_load. Uses librimagemagick to do most of @@ -7471,7 +7479,7 @@ imagemagick_image_p (Lisp_Object object) static int imagemagick_load_image (struct frame *f, struct image *img, unsigned char *contents, unsigned int size, - unsigned char *filename) + char *filename) { unsigned long width; unsigned long height; @@ -7479,8 +7487,6 @@ imagemagick_load_image (struct frame *f, struct image *img, MagickBooleanType status; XImagePtr ximg; - Lisp_Object specified_bg; - XColor background; int x; int y; @@ -7491,7 +7497,7 @@ imagemagick_load_image (struct frame *f, struct image *img, MagickPixelPacket pixel; Lisp_Object image; Lisp_Object value; - Lisp_Object crop, geometry; + Lisp_Object crop; long ino; int desired_width, desired_height; double rotation; @@ -7552,23 +7558,18 @@ imagemagick_load_image (struct frame *f, struct image *img, im_image = ReadImage (image_info, exception); DestroyExceptionInfo (exception); - if (im_image != NULL) - { - image_wand = NewMagickWandFromImage (im_image); - DestroyImage(im_image); - status = MagickTrue; - } - else - status = MagickFalse; + if (im_image == NULL) + goto imagemagick_no_wand; + image_wand = NewMagickWandFromImage (im_image); + DestroyImage(im_image); } else { image_wand = NewMagickWand (); - status = MagickReadImageBlob (image_wand, contents, size); + if (MagickReadImageBlob (image_wand, contents, size) == MagickFalse) + goto imagemagick_error; } - if (status == MagickFalse) goto imagemagick_error; - /* If width and/or height is set in the display spec assume we want to scale to those values. If either h or w is unspecified, the unspecified should be calculated from the specified to preserve @@ -7609,7 +7610,7 @@ imagemagick_load_image (struct frame *f, struct image *img, than the alternatives, but it still reads the entire image into memory before croping, which is aparently difficult to avoid when using imagemagick. */ - int w, h, x, y; + int w, h; w = XFASTINT (XCAR (crop)); crop = XCDR (crop); if (CONSP (crop) && INTEGERP (XCAR (crop))) @@ -7723,7 +7724,7 @@ imagemagick_load_image (struct frame *f, struct image *img, method is also well tested. Some aspects of this method are ad-hoc and needs to be more researched. */ int imagedepth = 24;/*MagickGetImageDepth(image_wand);*/ - char* exportdepth = imagedepth <= 8 ? "I" : "BGRP";/*"RGBP";*/ + const char *exportdepth = imagedepth <= 8 ? "I" : "BGRP";/*"RGBP";*/ /* Try to create a x pixmap to hold the imagemagick pixmap. */ if (!x_create_x_image_and_pixmap (f, width, height, imagedepth, &ximg, &img->pixmap)) @@ -7796,6 +7797,7 @@ imagemagick_load_image (struct frame *f, struct image *img, imagemagick_error: DestroyMagickWand (image_wand); + imagemagick_no_wand: MagickWandTerminus (); /* TODO more cleanup. */ image_error ("Error parsing IMAGEMAGICK image `%s'", img->spec, Qnil); @@ -7825,7 +7827,7 @@ imagemagick_load (struct frame *f, struct image *img) image_error ("Cannot find image file `%s'", file_name, Qnil); return 0; } - success_p = imagemagick_load_image (f, img, 0, 0, SDATA (file)); + success_p = imagemagick_load_image (f, img, 0, 0, SSDATA (file)); } /* Else its not a file, its a lisp object. Load the image from a lisp object rather than a file. */ @@ -7890,7 +7892,7 @@ static int svg_load_image (struct frame *, struct image *, /* The symbol `svg' identifying images of this type. */ -Lisp_Object Qsvg; +static Lisp_Object Qsvg; /* Indices of image specification fields in svg_format, below. */ @@ -7973,7 +7975,6 @@ DEF_IMGLIB_FN (void, rsvg_handle_get_dimensions); DEF_IMGLIB_FN (gboolean, rsvg_handle_write); DEF_IMGLIB_FN (gboolean, rsvg_handle_close); DEF_IMGLIB_FN (GdkPixbuf *, rsvg_handle_get_pixbuf); -DEF_IMGLIB_FN (void, rsvg_handle_free); DEF_IMGLIB_FN (int, gdk_pixbuf_get_width); DEF_IMGLIB_FN (int, gdk_pixbuf_get_height); @@ -8006,7 +8007,6 @@ init_svg_functions (Lisp_Object libraries) LOAD_IMGLIB_FN (library, rsvg_handle_write); LOAD_IMGLIB_FN (library, rsvg_handle_close); LOAD_IMGLIB_FN (library, rsvg_handle_get_pixbuf); - LOAD_IMGLIB_FN (library, rsvg_handle_free); LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_width); LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_height); @@ -8032,7 +8032,6 @@ init_svg_functions (Lisp_Object libraries) #define fn_rsvg_handle_write rsvg_handle_write #define fn_rsvg_handle_close rsvg_handle_close #define fn_rsvg_handle_get_pixbuf rsvg_handle_get_pixbuf -#define fn_rsvg_handle_free rsvg_handle_free #define fn_gdk_pixbuf_get_width gdk_pixbuf_get_width #define fn_gdk_pixbuf_get_height gdk_pixbuf_get_height @@ -8074,7 +8073,7 @@ svg_load (struct frame *f, struct image *img) } /* Read the entire file into memory. */ - contents = slurp_file (SDATA (file), &size); + contents = slurp_file (SSDATA (file), &size); if (contents == NULL) { image_error ("Error loading SVG image `%s'", img->spec, Qnil); @@ -8117,7 +8116,7 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * { RsvgHandle *rsvg_handle; RsvgDimensionData dimension_data; - GError *error = NULL; + GError *err = NULL; GdkPixbuf *pixbuf; int width; int height; @@ -8136,13 +8135,13 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * rsvg_handle = fn_rsvg_handle_new (); /* Parse the contents argument and fill in the rsvg_handle. */ - fn_rsvg_handle_write (rsvg_handle, contents, size, &error); - if (error) goto rsvg_error; + fn_rsvg_handle_write (rsvg_handle, contents, size, &err); + if (err) goto rsvg_error; /* The parsing is complete, rsvg_handle is ready to used, close it for further writes. */ - fn_rsvg_handle_close (rsvg_handle, &error); - if (error) goto rsvg_error; + fn_rsvg_handle_close (rsvg_handle, &err); + if (err) goto rsvg_error; fn_rsvg_handle_get_dimensions (rsvg_handle, &dimension_data); if (! check_image_size (f, dimension_data.width, dimension_data.height)) @@ -8182,7 +8181,7 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * color. */ specified_bg = image_spec_value (img->spec, QCbackground, NULL); if (!STRINGP (specified_bg) - || !x_defined_color (f, SDATA (specified_bg), &background, 0)) + || !x_defined_color (f, SSDATA (specified_bg), &background, 0)) { #ifndef HAVE_NS background.pixel = FRAME_BACKGROUND_PIXEL (f); @@ -8257,7 +8256,7 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * /* FIXME: Use error->message so the user knows what is the actual problem with the image. */ image_error ("Error parsing SVG image `%s'", img->spec, Qnil); - fn_g_error_free (error); + fn_g_error_free (err); return 0; } diff --git a/src/minibuf.c b/src/minibuf.c index 8f1987298b3..1b555035cfe 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -1895,7 +1895,7 @@ the values STRING, PREDICATE and `lambda'. */) return Qt; } -Lisp_Object Qmetadata; +static Lisp_Object Qmetadata; extern Lisp_Object Qbuffer; DEFUN ("internal-complete-buffer", Finternal_complete_buffer, Sinternal_complete_buffer, 3, 3, 0, diff --git a/src/window.c b/src/window.c index 265dafa6b80..7a026b3a1c7 100644 --- a/src/window.c +++ b/src/window.c @@ -82,6 +82,7 @@ static int foreach_window_1 (struct window *, int (* fn) (struct window *, void *), void *); static Lisp_Object window_list_1 (Lisp_Object, Lisp_Object, Lisp_Object); +static int resize_window_check (struct window *, int); static void resize_window_apply (struct window *, int); static Lisp_Object select_window (Lisp_Object, Lisp_Object, int); @@ -121,9 +122,6 @@ static int window_initialized; /* Hook to run when window config changes. */ static Lisp_Object Qwindow_configuration_change_hook; -/* Incremented by 1 whenever a window is deleted. */ -static int window_deletion_count; - /* Used by the function window_scroll_pixel_based */ static int window_scroll_pixel_based_preserve_x; static int window_scroll_pixel_based_preserve_y; @@ -614,7 +612,7 @@ WINDOW can be any window and defaults to the selected one. */) /* Return the number of lines of W's body. Don't count any mode or header line of W. */ -int +static int window_body_lines (struct window *w) { int height = XFASTINT (w->total_lines); @@ -1974,14 +1972,6 @@ recombine_windows (Lisp_Object window) } } } - -/* If WINDOW can be deleted, delete it. */ -Lisp_Object -delete_deletable_window (Lisp_Object window) -{ - if (!NILP (call1 (Qwindow_deletable_p, window))) - call1 (Qdelete_window, window); -} /*********************************************************************** Window List @@ -2643,7 +2633,7 @@ selected frame and no others. */) return Qnil; } -Lisp_Object +static Lisp_Object resize_root_window (Lisp_Object window, Lisp_Object delta, Lisp_Object horizontal, Lisp_Object ignore) { return call4 (Qresize_root_window, window, delta, horizontal, ignore); @@ -2669,9 +2659,9 @@ window-start value is reasonable when this function is called. */) { struct window *w, *r, *s; struct frame *f; - Lisp_Object sibling, pwindow, swindow, delta; - EMACS_INT startpos; - int top, new_top, resize_failed; + Lisp_Object sibling, pwindow, swindow IF_LINT (= Qnil), delta; + EMACS_INT startpos IF_LINT (= 0); + int top IF_LINT (= 0), new_top, resize_failed; w = decode_any_window (window); XSETWINDOW (window, w); @@ -2757,10 +2747,10 @@ window-start value is reasonable when this function is called. */) windows_or_buffers_changed++; Vwindow_list = Qnil; FRAME_WINDOW_SIZES_CHANGED (f) = 1; + resize_failed = 0; if (NILP (w->buffer)) { - resize_failed = 0; /* Resize subwindows vertically. */ XSETINT (delta, XINT (r->total_lines) - XINT (w->total_lines)); w->top_line = r->top_line; @@ -3078,12 +3068,12 @@ run_window_configuration_change_hook (struct frame *f) if (!NILP (Flocal_variable_p (Qwindow_configuration_change_hook, buffer))) { - int count = SPECPDL_INDEX (); + int inner_count = SPECPDL_INDEX (); record_unwind_protect (select_window_norecord, Fselected_window ()); select_window_norecord (window); run_funs (Fbuffer_local_value (Qwindow_configuration_change_hook, buffer)); - unbind_to (count, Qnil); + unbind_to (inner_count, Qnil); } } } @@ -3533,7 +3523,7 @@ Note: This function does not operate on any subwindows of WINDOW. */) Note: This function does not check any of `window-fixed-size-p', `window-min-height' or `window-min-width'. It does check that window sizes do not drop below one line (two columns). */ -int +static int resize_window_check (struct window *w, int horflag) { struct window *c; @@ -3617,7 +3607,7 @@ resize_window_check (struct window *w, int horflag) static void resize_window_apply (struct window *w, int horflag) { - struct window *c, *p; + struct window *c; int pos; /* Note: Assigning new_normal requires that the new total size of the @@ -3809,7 +3799,7 @@ resize_frame_windows (struct frame *f, int size, int horflag) DEFUN ("split-window-internal", Fsplit_window_internal, Ssplit_window_internal, 4, 4, 0, doc: /* Split window OLD. Second argument TOTAL-SIZE specifies the number of lines or columns of the -new window. In any case TOTAL-SIZE must be a positive integer +new window. In any case TOTAL-SIZE must be a positive integer Third argument SIDE nil (or `below') specifies that the new window shall be located below WINDOW. SIDE `above' means the new window shall be diff --git a/src/window.h b/src/window.h index 236464775d3..1ebc99055a5 100644 --- a/src/window.h +++ b/src/window.h @@ -924,10 +924,6 @@ extern void init_window (void); extern void syms_of_window (void); extern void keys_of_window (void); extern void resize_frame_windows (struct frame *, int, int); -extern int resize_window_check (struct window *, int); -extern Lisp_Object delete_deletable_window (Lisp_Object); -extern Lisp_Object resize_root_window (Lisp_Object, Lisp_Object, Lisp_Object, - Lisp_Object); #endif /* not WINDOW_H_INCLUDED */