diff options
| author | Paul Eggert | 2013-08-15 09:28:42 -0700 |
|---|---|---|
| committer | Paul Eggert | 2013-08-15 09:28:42 -0700 |
| commit | 691a357f3afffc2f40a6f04dea072933dcdf8bc0 (patch) | |
| tree | 84789637fcc308c77de5516e0fd75ea9d2eb71ba | |
| parent | f196836bc040fc9f36484c4d036a8a71870cdbf7 (diff) | |
| download | emacs-691a357f3afffc2f40a6f04dea072933dcdf8bc0.tar.gz emacs-691a357f3afffc2f40a6f04dea072933dcdf8bc0.zip | |
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.
| -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 @@ | |||
| 1 | 2013-08-15 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Fix minor problems found by static checking. | ||
| 4 | * frame.c (delete_frame): | ||
| 5 | * xdisp.c (next_element_from_display_vector): | ||
| 6 | Avoid uninitialized local. | ||
| 7 | * image.c (imagemagick_compute_animated_image): Port to C89. | ||
| 8 | Prefer usual GNU indentation style for loops. | ||
| 9 | Be more careful about bizarrely large sizes, by using ptrdiff_t | ||
| 10 | instead of int. | ||
| 11 | |||
| 1 | 2013-08-15 Dmitry Antipov <dmantipov@yandex.ru> | 12 | 2013-08-15 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 13 | ||
| 3 | Fix infinite frame selection loop (Bug#15025). | 14 | 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) | |||
| 1197 | /* Don't let the frame remain selected. */ | 1197 | /* Don't let the frame remain selected. */ |
| 1198 | if (f == sf) | 1198 | if (f == sf) |
| 1199 | { | 1199 | { |
| 1200 | Lisp_Object tail, frame1; | 1200 | Lisp_Object tail; |
| 1201 | Lisp_Object frame1 = Qnil; | ||
| 1201 | 1202 | ||
| 1202 | /* Look for another visible frame on the same terminal. | 1203 | /* Look for another visible frame on the same terminal. |
| 1203 | Do not call next_frame here because it may loop forever. | 1204 | 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; | |||
| 7877 | static MagickWand * | 7877 | static MagickWand * |
| 7878 | imagemagick_compute_animated_image (MagickWand *super_wand, int ino) | 7878 | imagemagick_compute_animated_image (MagickWand *super_wand, int ino) |
| 7879 | { | 7879 | { |
| 7880 | int i; | ||
| 7880 | MagickWand *composite_wand; | 7881 | MagickWand *composite_wand; |
| 7881 | 7882 | ||
| 7882 | MagickSetIteratorIndex (super_wand, 0); | 7883 | MagickSetIteratorIndex (super_wand, 0); |
| @@ -7886,56 +7887,59 @@ imagemagick_compute_animated_image (MagickWand *super_wand, int ino) | |||
| 7886 | else | 7887 | else |
| 7887 | composite_wand = animation_cache; | 7888 | composite_wand = animation_cache; |
| 7888 | 7889 | ||
| 7889 | for (int i = max (1, animation_index); i <= ino; i++) { | 7890 | for (i = max (1, animation_index); i <= ino; i++) |
| 7890 | MagickWand *sub_wand; | 7891 | { |
| 7891 | PixelIterator *source_iterator, *dest_iterator; | 7892 | MagickWand *sub_wand; |
| 7892 | PixelWand **source, **dest; | 7893 | PixelIterator *source_iterator, *dest_iterator; |
| 7893 | size_t source_width, dest_width; | 7894 | PixelWand **source, **dest; |
| 7894 | MagickPixelPacket pixel; | 7895 | size_t source_width, dest_width; |
| 7896 | MagickPixelPacket pixel; | ||
| 7895 | 7897 | ||
| 7896 | MagickSetIteratorIndex (super_wand, i); | 7898 | MagickSetIteratorIndex (super_wand, i); |
| 7897 | sub_wand = MagickGetImage (super_wand); | 7899 | sub_wand = MagickGetImage (super_wand); |
| 7898 | 7900 | ||
| 7899 | source_iterator = NewPixelIterator (sub_wand); | 7901 | source_iterator = NewPixelIterator (sub_wand); |
| 7900 | if (! source_iterator) | 7902 | if (! source_iterator) |
| 7901 | { | 7903 | { |
| 7902 | DestroyMagickWand (composite_wand); | 7904 | DestroyMagickWand (composite_wand); |
| 7903 | DestroyMagickWand (sub_wand); | 7905 | DestroyMagickWand (sub_wand); |
| 7904 | image_error ("Imagemagick pixel iterator creation failed", | 7906 | image_error ("Imagemagick pixel iterator creation failed", |
| 7905 | Qnil, Qnil); | 7907 | Qnil, Qnil); |
| 7906 | return NULL; | 7908 | return NULL; |
| 7907 | } | 7909 | } |
| 7908 | 7910 | ||
| 7909 | dest_iterator = NewPixelIterator (composite_wand); | 7911 | dest_iterator = NewPixelIterator (composite_wand); |
| 7910 | if (! dest_iterator) | 7912 | if (! dest_iterator) |
| 7911 | { | 7913 | { |
| 7912 | DestroyMagickWand (composite_wand); | 7914 | DestroyMagickWand (composite_wand); |
| 7913 | DestroyMagickWand (sub_wand); | 7915 | DestroyMagickWand (sub_wand); |
| 7914 | DestroyPixelIterator (source_iterator); | 7916 | DestroyPixelIterator (source_iterator); |
| 7915 | image_error ("Imagemagick pixel iterator creation failed", | 7917 | image_error ("Imagemagick pixel iterator creation failed", |
| 7916 | Qnil, Qnil); | 7918 | Qnil, Qnil); |
| 7917 | return NULL; | 7919 | return NULL; |
| 7918 | } | 7920 | } |
| 7919 | 7921 | ||
| 7920 | while ((source = PixelGetNextIteratorRow (source_iterator, &source_width)) | 7922 | while ((source = PixelGetNextIteratorRow (source_iterator, &source_width)) |
| 7921 | != NULL) { | 7923 | != NULL) |
| 7922 | dest = PixelGetNextIteratorRow (dest_iterator, &dest_width); | ||
| 7923 | for (int x = 0; x < source_width; x++) | ||
| 7924 | { | 7924 | { |
| 7925 | /* Copy over non-transparent pixels. */ | 7925 | ptrdiff_t x; |
| 7926 | if (PixelGetAlpha (source[x])) | 7926 | dest = PixelGetNextIteratorRow (dest_iterator, &dest_width); |
| 7927 | for (x = 0; x < source_width; x++) | ||
| 7927 | { | 7928 | { |
| 7928 | PixelGetMagickColor (source[x], &pixel); | 7929 | /* Copy over non-transparent pixels. */ |
| 7929 | PixelSetMagickColor (dest[x], &pixel); | 7930 | if (PixelGetAlpha (source[x])) |
| 7931 | { | ||
| 7932 | PixelGetMagickColor (source[x], &pixel); | ||
| 7933 | PixelSetMagickColor (dest[x], &pixel); | ||
| 7934 | } | ||
| 7930 | } | 7935 | } |
| 7936 | PixelSyncIterator(dest_iterator); | ||
| 7931 | } | 7937 | } |
| 7932 | PixelSyncIterator(dest_iterator); | ||
| 7933 | } | ||
| 7934 | 7938 | ||
| 7935 | DestroyPixelIterator (source_iterator); | 7939 | DestroyPixelIterator (source_iterator); |
| 7936 | DestroyPixelIterator (dest_iterator); | 7940 | DestroyPixelIterator (dest_iterator); |
| 7937 | DestroyMagickWand (sub_wand); | 7941 | DestroyMagickWand (sub_wand); |
| 7938 | } | 7942 | } |
| 7939 | 7943 | ||
| 7940 | /* Cache a copy for the next iteration. The current wand will be | 7944 | /* Cache a copy for the next iteration. The current wand will be |
| 7941 | destroyed by the caller. */ | 7945 | 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) | |||
| 7507 | /* For the last character of the box-face run, we need to look | 7507 | /* For the last character of the box-face run, we need to look |
| 7508 | either at the next glyph from the display vector, or at the | 7508 | either at the next glyph from the display vector, or at the |
| 7509 | face we saw before the display vector. */ | 7509 | face we saw before the display vector. */ |
| 7510 | next_face_id = it->saved_face_id; | ||
| 7510 | if (it->current.dpvec_index < it->dpend - it->dpvec - 1) | 7511 | if (it->current.dpvec_index < it->dpend - it->dpvec - 1) |
| 7511 | { | 7512 | { |
| 7512 | if (it->dpvec_face_id >= 0) | 7513 | if (it->dpvec_face_id >= 0) |
| @@ -7521,8 +7522,6 @@ next_element_from_display_vector (struct it *it) | |||
| 7521 | it->saved_face_id); | 7522 | it->saved_face_id); |
| 7522 | } | 7523 | } |
| 7523 | } | 7524 | } |
| 7524 | else | ||
| 7525 | next_face_id = it->saved_face_id; | ||
| 7526 | next_face = FACE_FROM_ID (it->f, next_face_id); | 7525 | next_face = FACE_FROM_ID (it->f, next_face_id); |
| 7527 | it->end_of_box_run_p = (this_face && this_face->box != FACE_NO_BOX | 7526 | it->end_of_box_run_p = (this_face && this_face->box != FACE_NO_BOX |
| 7528 | && (!next_face | 7527 | && (!next_face |