[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master e35f99f: --enable-gcc-warnings now uses -Wjump-miss
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] master e35f99f: --enable-gcc-warnings now uses -Wjump-misses-init |
Date: |
Fri, 26 Feb 2016 16:24:15 +0000 |
branch: master
commit e35f99f2dd35a89b42961fc63c7e2772fb03c792
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>
--enable-gcc-warnings now uses -Wjump-misses-init
When configuring with --enable-gcc-warnings, also enable
-Wjump-misses-init, as it’s confusing to use a goto to skip over
an initialization. Fix the few places in the code that run afoul
of this warning.
* configure.ac (WERROR_CFLAGS): Add -Wjump-misses-init.
* src/doc.c (Fsubstitute_command_keys):
* src/image.c (svg_load_image):
* src/regex.c (re_match_2_internal):
* src/xdisp.c (redisplay_internal, redisplay_window):
Don’t jump over initialization.
---
configure.ac | 1 -
src/doc.c | 12 +++---
src/image.c | 125 ++++++++++++++++++++++++++++------------------------------
src/regex.c | 33 ++++++++-------
src/xdisp.c | 14 +++----
5 files changed, 89 insertions(+), 96 deletions(-)
diff --git a/configure.ac b/configure.ac
index 1cbd297..e750a43 100644
--- a/configure.ac
+++ b/configure.ac
@@ -911,7 +911,6 @@ else
nw="$nw -Wvla" # Emacs uses <vla.h>.
nw="$nw -Wswitch-default" # Too many warnings for now
nw="$nw -Winline" # OK to ignore 'inline'
- nw="$nw -Wjump-misses-init" # We sometimes safely jump over init.
nw="$nw -Wstrict-overflow" # OK to optimize assuming that
# signed overflow has undefined behavior
nw="$nw -Wsync-nand" # irrelevant here, and provokes ObjC
warning
diff --git a/src/doc.c b/src/doc.c
index a9273f0..ae80791 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -865,16 +865,14 @@ Otherwise, return a new string. */)
\<foo> just sets the keymap used for \[cmd]. */
else if (strp[0] == '\\' && (strp[1] == '{' || strp[1] == '<'))
{
- struct buffer *oldbuf;
- ptrdiff_t start_idx;
+ {
/* This is for computing the SHADOWS arg for describe_map_tree. */
Lisp_Object active_maps = Fcurrent_active_maps (Qnil, Qnil);
- Lisp_Object earlier_maps;
ptrdiff_t count = SPECPDL_INDEX ();
strp += 2; /* skip \{ or \< */
start = strp;
- start_idx = start - SDATA (string);
+ ptrdiff_t start_idx = start - SDATA (string);
while ((strp - SDATA (string) < SBYTES (string))
&& *strp != '}' && *strp != '>')
@@ -904,7 +902,7 @@ Otherwise, return a new string. */)
}
/* Now switch to a temp buffer. */
- oldbuf = current_buffer;
+ struct buffer *oldbuf = current_buffer;
set_buffer_internal (XBUFFER (Vprin1_to_string_buffer));
/* This is for an unusual case where some after-change
function uses 'format' or 'prin1' or something else that
@@ -929,7 +927,8 @@ Otherwise, return a new string. */)
{
/* Get the list of active keymaps that precede this one.
If this one's not active, get nil. */
- earlier_maps = Fcdr (Fmemq (tem, Freverse (active_maps)));
+ Lisp_Object earlier_maps
+ = Fcdr (Fmemq (tem, Freverse (active_maps)));
describe_map_tree (tem, 1, Fnreverse (earlier_maps),
Qnil, 0, 1, 0, 0, 1);
}
@@ -937,6 +936,7 @@ Otherwise, return a new string. */)
Ferase_buffer ();
set_buffer_internal (oldbuf);
unbind_to (count, Qnil);
+ }
subst_string:
start = SDATA (tem);
diff --git a/src/image.c b/src/image.c
index 9ba1a79..aa45b00 100644
--- a/src/image.c
+++ b/src/image.c
@@ -9257,8 +9257,8 @@ svg_load_image (struct frame *f, /* Pointer to
emacs frame structure. *
eassert (gdk_pixbuf_get_has_alpha (pixbuf));
eassert (gdk_pixbuf_get_bits_per_sample (pixbuf) == 8);
-#ifdef USE_CAIRO
{
+#ifdef USE_CAIRO
unsigned char *data = (unsigned char *) xmalloc (width*height*4);
uint32_t bgcolor = get_spec_bg_or_alpha_as_argb (img, f);
@@ -9284,82 +9284,77 @@ svg_load_image (struct frame *f, /* Pointer to
emacs frame structure. *
create_cairo_image_surface (img, data, width, height);
g_object_unref (pixbuf);
- }
#else
- /* Try to create a x pixmap to hold the svg pixmap. */
- XImagePtr ximg;
- if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0))
- {
- g_object_unref (pixbuf);
- return 0;
- }
+ /* Try to create a x pixmap to hold the svg pixmap. */
+ XImagePtr ximg;
+ if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0))
+ {
+ g_object_unref (pixbuf);
+ return 0;
+ }
- init_color_table ();
+ init_color_table ();
- /* Handle alpha channel by combining the image with a background
- color. */
- XColor background;
- Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL);
- if (!STRINGP (specified_bg)
- || !x_defined_color (f, SSDATA (specified_bg), &background, 0))
- x_query_frame_background_color (f, &background);
-
- /* SVG pixmaps specify transparency in the last byte, so right
- shift 8 bits to get rid of it, since emacs doesn't support
- transparency. */
- background.red >>= 8;
- background.green >>= 8;
- background.blue >>= 8;
-
- /* This loop handles opacity values, since Emacs assumes
- non-transparent images. Each pixel must be "flattened" by
- calculating the resulting color, given the transparency of the
- pixel, and the image background color. */
- for (int y = 0; y < height; ++y)
- {
- for (int x = 0; x < width; ++x)
- {
- int red;
- int green;
- int blue;
- int opacity;
-
- red = *pixels++;
- green = *pixels++;
- blue = *pixels++;
- opacity = *pixels++;
-
- red = ((red * opacity)
- + (background.red * ((1 << 8) - opacity)));
- green = ((green * opacity)
- + (background.green * ((1 << 8) - opacity)));
- blue = ((blue * opacity)
- + (background.blue * ((1 << 8) - opacity)));
-
- XPutPixel (ximg, x, y, lookup_rgb_color (f, red, green, blue));
- }
+ /* Handle alpha channel by combining the image with a background
+ color. */
+ XColor background;
+ Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground,
NULL);
+ if (!STRINGP (specified_bg)
+ || !x_defined_color (f, SSDATA (specified_bg), &background, 0))
+ x_query_frame_background_color (f, &background);
+
+ /* SVG pixmaps specify transparency in the last byte, so right
+ shift 8 bits to get rid of it, since emacs doesn't support
+ transparency. */
+ background.red >>= 8;
+ background.green >>= 8;
+ background.blue >>= 8;
+
+ /* This loop handles opacity values, since Emacs assumes
+ non-transparent images. Each pixel must be "flattened" by
+ calculating the resulting color, given the transparency of the
+ pixel, and the image background color. */
+ for (int y = 0; y < height; ++y)
+ {
+ for (int x = 0; x < width; ++x)
+ {
+ int red = *pixels++;
+ int green = *pixels++;
+ int blue = *pixels++;
+ int opacity = *pixels++;
+
+ red = ((red * opacity)
+ + (background.red * ((1 << 8) - opacity)));
+ green = ((green * opacity)
+ + (background.green * ((1 << 8) - opacity)));
+ blue = ((blue * opacity)
+ + (background.blue * ((1 << 8) - opacity)));
+
+ XPutPixel (ximg, x, y, lookup_rgb_color (f, red, green, blue));
+ }
- pixels += rowstride - 4 * width;
- }
+ pixels += rowstride - 4 * width;
+ }
#ifdef COLOR_TABLE_SUPPORT
- /* Remember colors allocated for this image. */
- img->colors = colors_in_color_table (&img->ncolors);
- free_color_table ();
+ /* Remember colors allocated for this image. */
+ img->colors = colors_in_color_table (&img->ncolors);
+ free_color_table ();
#endif /* COLOR_TABLE_SUPPORT */
- g_object_unref (pixbuf);
+ g_object_unref (pixbuf);
- img->width = width;
- img->height = height;
+ img->width = width;
+ img->height = height;
- /* Maybe fill in the background field while we have ximg handy.
- Casting avoids a GCC warning. */
- IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg);
+ /* Maybe fill in the background field while we have ximg handy.
+ Casting avoids a GCC warning. */
+ IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg);
- /* Put ximg into the image. */
- image_put_x_image (f, img, ximg, 0);
+ /* Put ximg into the image. */
+ image_put_x_image (f, img, ximg, 0);
#endif /* ! USE_CAIRO */
+ }
return 1;
diff --git a/src/regex.c b/src/regex.c
index 164eb46..d5c58ae 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -5140,8 +5140,6 @@ re_match_2_internal (struct re_pattern_buffer *bufp,
const_re_char *string1,
if (p == pend)
{
- ptrdiff_t dcnt;
-
/* End of pattern means we might have succeeded. */
DEBUG_PRINT ("end of pattern ... ");
@@ -5149,19 +5147,22 @@ re_match_2_internal (struct re_pattern_buffer *bufp,
const_re_char *string1,
longest match, try backtracking. */
if (d != end_match_2)
{
- /* 1 if this match ends in the same string (string1 or string2)
- as the best previous match. */
- boolean same_str_p = (FIRST_STRING_P (match_end)
- == FIRST_STRING_P (d));
- /* 1 if this match is the best seen so far. */
- boolean best_match_p;
-
- /* AIX compiler got confused when this was combined
- with the previous declaration. */
- if (same_str_p)
- best_match_p = d > match_end;
- else
- best_match_p = !FIRST_STRING_P (d);
+ /* True if this match is the best seen so far. */
+ bool best_match_p;
+
+ {
+ /* True if this match ends in the same string (string1
+ or string2) as the best previous match. */
+ bool same_str_p = (FIRST_STRING_P (match_end)
+ == FIRST_STRING_P (d));
+
+ /* AIX compiler got confused when this was combined
+ with the previous declaration. */
+ if (same_str_p)
+ best_match_p = d > match_end;
+ else
+ best_match_p = !FIRST_STRING_P (d);
+ }
DEBUG_PRINT ("backtracking.\n");
@@ -5290,7 +5291,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp,
const_re_char *string1,
nfailure_points_pushed - nfailure_points_popped);
DEBUG_PRINT ("%u registers pushed.\n", num_regs_pushed);
- dcnt = POINTER_TO_OFFSET (d) - pos;
+ ptrdiff_t dcnt = POINTER_TO_OFFSET (d) - pos;
DEBUG_PRINT ("Returning %td from re_match_2.\n", dcnt);
diff --git a/src/xdisp.c b/src/xdisp.c
index 4330f10..acb2754 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -13989,9 +13989,6 @@ redisplay_internal (void)
}
else if (FRAME_VISIBLE_P (sf) && !FRAME_OBSCURED_P (sf))
{
- Lisp_Object mini_window = FRAME_MINIBUF_WINDOW (sf);
- struct frame *mini_frame;
-
displayed_buffer = XBUFFER (XWINDOW (selected_window)->contents);
/* Use list_of_error, not Qerror, so that
we catch only errors and don't run the debugger. */
@@ -13999,8 +13996,8 @@ redisplay_internal (void)
list_of_error,
redisplay_window_error);
if (update_miniwindow_p)
- internal_condition_case_1 (redisplay_window_1, mini_window,
- list_of_error,
+ internal_condition_case_1 (redisplay_window_1,
+ FRAME_MINIBUF_WINDOW (sf), list_of_error,
redisplay_window_error);
/* Compare desired and current matrices, perform output. */
@@ -14050,8 +14047,8 @@ redisplay_internal (void)
have put text on a frame other than the selected one, so the
above call to update_frame would not have caught it. Catch
it here. */
- mini_window = FRAME_MINIBUF_WINDOW (sf);
- mini_frame = XFRAME (WINDOW_FRAME (XWINDOW (mini_window)));
+ Lisp_Object mini_window = FRAME_MINIBUF_WINDOW (sf);
+ struct frame *mini_frame = XFRAME (WINDOW_FRAME (XWINDOW (mini_window)));
if (mini_frame != sf && FRAME_WINDOW_P (mini_frame))
{
@@ -16041,6 +16038,7 @@ redisplay_window (Lisp_Object window, bool
just_this_one_p)
bool last_line_misfit = false;
ptrdiff_t beg_unchanged, end_unchanged;
int frame_line_height;
+ bool use_desired_matrix;
SET_TEXT_POS (lpoint, PT, PT_BYTE);
opoint = lpoint;
@@ -16763,7 +16761,7 @@ redisplay_window (Lisp_Object window, bool
just_this_one_p)
startp = run_window_scroll_functions (window, it.current.pos);
/* Redisplay the window. */
- bool use_desired_matrix = false;
+ use_desired_matrix = false;
if (!current_matrix_up_to_date_p
|| windows_or_buffers_changed
|| f->cursor_type_changed
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master e35f99f: --enable-gcc-warnings now uses -Wjump-misses-init,
Paul Eggert <=