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.
This commit is contained in:
Paul Eggert 2013-08-15 09:28:42 -07:00
parent f196836bc0
commit 691a357f3a
4 changed files with 63 additions and 48 deletions

View file

@ -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).

View file

@ -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.

View file

@ -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;
}
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++)
source_iterator = NewPixelIterator (sub_wand);
if (! source_iterator)
{
/* Copy over non-transparent pixels. */
if (PixelGetAlpha (source[x]))
{
PixelGetMagickColor (source[x], &pixel);
PixelSetMagickColor (dest[x], &pixel);
}
DestroyMagickWand (composite_wand);
DestroyMagickWand (sub_wand);
image_error ("Imagemagick pixel iterator creation failed",
Qnil, Qnil);
return NULL;
}
PixelSyncIterator(dest_iterator);
}
DestroyPixelIterator (source_iterator);
DestroyPixelIterator (dest_iterator);
DestroyMagickWand (sub_wand);
}
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)
{
ptrdiff_t x;
dest = PixelGetNextIteratorRow (dest_iterator, &dest_width);
for (x = 0; x < source_width; x++)
{
/* Copy over non-transparent pixels. */
if (PixelGetAlpha (source[x]))
{
PixelGetMagickColor (source[x], &pixel);
PixelSetMagickColor (dest[x], &pixel);
}
}
PixelSyncIterator(dest_iterator);
}
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. */

View file

@ -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