diff options
-rw-r--r-- | src/ChangeLog | 11 | ||||
-rw-r--r-- | src/frame.c | 3 | ||||
-rw-r--r-- | src/image.c | 86 | ||||
-rw-r--r-- | src/xdisp.c | 3 |
4 files changed, 59 insertions, 44 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index b17dec01e2c..46591eb1952 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2013-08-15 Paul Eggert <eggert@cs.ucla.edu> + + Fix minor problems found by static checking. + * frame.c (delete_frame): + * xdisp.c (next_element_from_display_vector): + Avoid uninitialized local. + * image.c (imagemagick_compute_animated_image): Port to C89. + Prefer usual GNU indentation style for loops. + Be more careful about bizarrely large sizes, by using ptrdiff_t + instead of int. + 2013-08-15 Dmitry Antipov <dmantipov@yandex.ru> Fix infinite frame selection loop (Bug#15025). diff --git a/src/frame.c b/src/frame.c index 957f08b06c5..5ee001f4d98 100644 --- a/src/frame.c +++ b/src/frame.c @@ -1197,7 +1197,8 @@ delete_frame (Lisp_Object frame, Lisp_Object force) /* Don't let the frame remain selected. */ if (f == sf) { - Lisp_Object tail, frame1; + Lisp_Object tail; + Lisp_Object frame1 = Qnil; /* Look for another visible frame on the same terminal. Do not call next_frame here because it may loop forever. diff --git a/src/image.c b/src/image.c index 21b6f8979ee..3cab72edf74 100644 --- a/src/image.c +++ b/src/image.c @@ -7877,6 +7877,7 @@ static int animation_index = 0; static MagickWand * imagemagick_compute_animated_image (MagickWand *super_wand, int ino) { + int i; MagickWand *composite_wand; MagickSetIteratorIndex (super_wand, 0); @@ -7886,56 +7887,59 @@ imagemagick_compute_animated_image (MagickWand *super_wand, int ino) else composite_wand = animation_cache; - for (int i = max (1, animation_index); i <= ino; i++) { - MagickWand *sub_wand; - PixelIterator *source_iterator, *dest_iterator; - PixelWand **source, **dest; - size_t source_width, dest_width; - MagickPixelPacket pixel; + for (i = max (1, animation_index); i <= ino; i++) + { + MagickWand *sub_wand; + PixelIterator *source_iterator, *dest_iterator; + PixelWand **source, **dest; + size_t source_width, dest_width; + MagickPixelPacket pixel; - MagickSetIteratorIndex (super_wand, i); - sub_wand = MagickGetImage (super_wand); + MagickSetIteratorIndex (super_wand, i); + sub_wand = MagickGetImage (super_wand); - source_iterator = NewPixelIterator (sub_wand); - if (! source_iterator) - { - DestroyMagickWand (composite_wand); - DestroyMagickWand (sub_wand); - image_error ("Imagemagick pixel iterator creation failed", - Qnil, Qnil); - return NULL; - } + source_iterator = NewPixelIterator (sub_wand); + if (! source_iterator) + { + DestroyMagickWand (composite_wand); + DestroyMagickWand (sub_wand); + image_error ("Imagemagick pixel iterator creation failed", + Qnil, Qnil); + return NULL; + } - dest_iterator = NewPixelIterator (composite_wand); - if (! dest_iterator) - { - DestroyMagickWand (composite_wand); - DestroyMagickWand (sub_wand); - DestroyPixelIterator (source_iterator); - image_error ("Imagemagick pixel iterator creation failed", - Qnil, Qnil); - return NULL; - } + dest_iterator = NewPixelIterator (composite_wand); + if (! dest_iterator) + { + DestroyMagickWand (composite_wand); + DestroyMagickWand (sub_wand); + DestroyPixelIterator (source_iterator); + image_error ("Imagemagick pixel iterator creation failed", + Qnil, Qnil); + return NULL; + } - while ((source = PixelGetNextIteratorRow (source_iterator, &source_width)) - != NULL) { - dest = PixelGetNextIteratorRow (dest_iterator, &dest_width); - for (int x = 0; x < source_width; x++) + while ((source = PixelGetNextIteratorRow (source_iterator, &source_width)) + != NULL) { - /* Copy over non-transparent pixels. */ - if (PixelGetAlpha (source[x])) + ptrdiff_t x; + dest = PixelGetNextIteratorRow (dest_iterator, &dest_width); + for (x = 0; x < source_width; x++) { - PixelGetMagickColor (source[x], &pixel); - PixelSetMagickColor (dest[x], &pixel); + /* Copy over non-transparent pixels. */ + if (PixelGetAlpha (source[x])) + { + PixelGetMagickColor (source[x], &pixel); + PixelSetMagickColor (dest[x], &pixel); + } } + PixelSyncIterator(dest_iterator); } - PixelSyncIterator(dest_iterator); - } - DestroyPixelIterator (source_iterator); - DestroyPixelIterator (dest_iterator); - DestroyMagickWand (sub_wand); - } + DestroyPixelIterator (source_iterator); + DestroyPixelIterator (dest_iterator); + DestroyMagickWand (sub_wand); + } /* Cache a copy for the next iteration. The current wand will be destroyed by the caller. */ diff --git a/src/xdisp.c b/src/xdisp.c index 25a2ed23a97..ea1cd7dd2bc 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -7507,6 +7507,7 @@ next_element_from_display_vector (struct it *it) /* For the last character of the box-face run, we need to look either at the next glyph from the display vector, or at the face we saw before the display vector. */ + next_face_id = it->saved_face_id; if (it->current.dpvec_index < it->dpend - it->dpvec - 1) { if (it->dpvec_face_id >= 0) @@ -7521,8 +7522,6 @@ next_element_from_display_vector (struct it *it) it->saved_face_id); } } - else - next_face_id = it->saved_face_id; next_face = FACE_FROM_ID (it->f, next_face_id); it->end_of_box_run_p = (this_face && this_face->box != FACE_NO_BOX && (!next_face |