diff options
| author | Paul Eggert | 2016-05-18 00:06:12 -0700 |
|---|---|---|
| committer | Paul Eggert | 2016-05-18 00:49:29 -0700 |
| commit | 374f6a5f34a83d3e4c518f0726558642293fdd71 (patch) | |
| tree | 1b99d7c785c9916322ea03565b846a5056a0d25e /src/alloc.c | |
| parent | 6f5db0255cab2e17ab53ee68f6dc2f4d75978d80 (diff) | |
| download | emacs-374f6a5f34a83d3e4c518f0726558642293fdd71.tar.gz emacs-374f6a5f34a83d3e4c518f0726558642293fdd71.zip | |
Port --enable-gcc-warnings to GCC 6.1
* configure.ac (WERROR_CFLAGS): Omit -Wunused-const-variable=2.
* lib-src/etags.c (LOOKING_AT, LOOKING_AT_NOCASE):
Omit test whether pointer plus a constant equals a null pointer.
* src/alloc.c (compact_small_strings):
Avoid pointer arithmetic on null pointers.
* src/alloc.c (mark_face_cache):
* src/fontset.c (free_realized_fontsets, Fset_fontset_font):
* src/fringe.c (draw_fringe_bitmap_1)
(Fset_fringe_bitmap_face):
* src/macfont.m (macfont_draw):
* src/msdos.c (IT_set_face, IT_clear_screen):
* src/nsfont.m (nsfont_draw):
* src/nsterm.h (FRAME_DEFAULT_FACE):
* src/nsterm.m (ns_draw_window_cursor)
(ns_draw_vertical_window_border, ns_draw_window_divider)
(ns_dumpglyphs_box_or_relief)
(ns_maybe_dumpglyphs_background, ns_dumpglyphs_image)
(ns_dumpglyphs_stretch):
* src/w32term.c (w32_draw_vertical_window_border)
(w32_draw_window_divider, x_set_mouse_face_gc):
* src/xdisp.c (estimate_mode_line_height, init_iterator)
(handle_face_prop, handle_single_display_spec, pop_it)
(CHAR_COMPOSED_P, get_next_display_element)
(next_element_from_display_vector, extend_face_to_end_of_line)
(fill_gstring_glyph_string,BUILD_COMPOSITE_GLYPH_STRING):
* src/xfaces.c (Finternal_merge_in_global_face, Fface_font)
(lookup_named_face):
* src/xterm.c (x_draw_vertical_window_border)
(x_draw_window_divider, x_set_mouse_face_gc):
Prefer FACE_OPT_FROM_ID to FACE_FROM_ID when the result might be null.
* src/xterm.c (try_window_id):
Redo loop to convince GCC 6.1 that it is null pointer safe.
(x_color_cells):
Use eassume as necessary to pacify GCC 6.1.
* src/dispextern.h (FACE_FROM_ID, IMAGE_FROM_ID): Now returns non-null.
(FACE_OPT_FROM_ID, IMAGE_OPT_FROM_ID): New macro, with the old
behavior of the non-_OPT macro, to be used when the result
might be a null pointer.
* src/dispnew.c (buffer_posn_from_coords, marginal_area_string)
[HAVE_WINDOW_SYSTEM]:
* src/intervals.h (INTERVAL_WRITABLE_P):
* src/term.c (turn_off_face):
* src/xdisp.c (get_glyph_face_and_encoding, fill_image_glyph_string)
(produce_image_glyph, produce_xwidget_glyph):
* src/xfaces.c (lookup_named_face):
Remove unnecessary test for null pointer.
* src/keyboard.c (read_char): Suppress bogus -Wclobbered warning.
* src/process.c (would_block): New function.
(server_accept_connection, wait_reading_process_output, send_process):
Use it.
* src/xdisp.c (get_window_cursor_type, note_mouse_highlight):
Prefer IMAGE_OPT_FROM_ID to IMAGE_FROM_ID when the result
might be null.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 131 |
1 files changed, 69 insertions, 62 deletions
diff --git a/src/alloc.c b/src/alloc.c index c5a4f425f6e..054e1ca23ca 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -2174,89 +2174,96 @@ free_large_strings (void) | |||
| 2174 | static void | 2174 | static void |
| 2175 | compact_small_strings (void) | 2175 | compact_small_strings (void) |
| 2176 | { | 2176 | { |
| 2177 | struct sblock *b, *tb, *next; | ||
| 2178 | sdata *from, *to, *end, *tb_end; | ||
| 2179 | sdata *to_end, *from_end; | ||
| 2180 | |||
| 2181 | /* TB is the sblock we copy to, TO is the sdata within TB we copy | 2177 | /* TB is the sblock we copy to, TO is the sdata within TB we copy |
| 2182 | to, and TB_END is the end of TB. */ | 2178 | to, and TB_END is the end of TB. */ |
| 2183 | tb = oldest_sblock; | 2179 | struct sblock *tb = oldest_sblock; |
| 2184 | tb_end = (sdata *) ((char *) tb + SBLOCK_SIZE); | 2180 | if (tb) |
| 2185 | to = tb->data; | ||
| 2186 | |||
| 2187 | /* Step through the blocks from the oldest to the youngest. We | ||
| 2188 | expect that old blocks will stabilize over time, so that less | ||
| 2189 | copying will happen this way. */ | ||
| 2190 | for (b = oldest_sblock; b; b = b->next) | ||
| 2191 | { | 2181 | { |
| 2192 | end = b->next_free; | 2182 | sdata *tb_end = (sdata *) ((char *) tb + SBLOCK_SIZE); |
| 2193 | eassert ((char *) end <= (char *) b + SBLOCK_SIZE); | 2183 | sdata *to = tb->data; |
| 2194 | 2184 | ||
| 2195 | for (from = b->data; from < end; from = from_end) | 2185 | /* Step through the blocks from the oldest to the youngest. We |
| 2186 | expect that old blocks will stabilize over time, so that less | ||
| 2187 | copying will happen this way. */ | ||
| 2188 | struct sblock *b = tb; | ||
| 2189 | do | ||
| 2196 | { | 2190 | { |
| 2197 | /* Compute the next FROM here because copying below may | 2191 | sdata *end = b->next_free; |
| 2198 | overwrite data we need to compute it. */ | 2192 | eassert ((char *) end <= (char *) b + SBLOCK_SIZE); |
| 2199 | ptrdiff_t nbytes; | 2193 | |
| 2200 | struct Lisp_String *s = from->string; | 2194 | for (sdata *from = b->data; from < end; ) |
| 2195 | { | ||
| 2196 | /* Compute the next FROM here because copying below may | ||
| 2197 | overwrite data we need to compute it. */ | ||
| 2198 | ptrdiff_t nbytes; | ||
| 2199 | struct Lisp_String *s = from->string; | ||
| 2201 | 2200 | ||
| 2202 | #ifdef GC_CHECK_STRING_BYTES | 2201 | #ifdef GC_CHECK_STRING_BYTES |
| 2203 | /* Check that the string size recorded in the string is the | 2202 | /* Check that the string size recorded in the string is the |
| 2204 | same as the one recorded in the sdata structure. */ | 2203 | same as the one recorded in the sdata structure. */ |
| 2205 | if (s && string_bytes (s) != SDATA_NBYTES (from)) | 2204 | if (s && string_bytes (s) != SDATA_NBYTES (from)) |
| 2206 | emacs_abort (); | 2205 | emacs_abort (); |
| 2207 | #endif /* GC_CHECK_STRING_BYTES */ | 2206 | #endif /* GC_CHECK_STRING_BYTES */ |
| 2208 | 2207 | ||
| 2209 | nbytes = s ? STRING_BYTES (s) : SDATA_NBYTES (from); | 2208 | nbytes = s ? STRING_BYTES (s) : SDATA_NBYTES (from); |
| 2210 | eassert (nbytes <= LARGE_STRING_BYTES); | 2209 | eassert (nbytes <= LARGE_STRING_BYTES); |
| 2211 | 2210 | ||
| 2212 | nbytes = SDATA_SIZE (nbytes); | 2211 | nbytes = SDATA_SIZE (nbytes); |
| 2213 | from_end = (sdata *) ((char *) from + nbytes + GC_STRING_EXTRA); | 2212 | sdata *from_end = (sdata *) ((char *) from |
| 2213 | + nbytes + GC_STRING_EXTRA); | ||
| 2214 | 2214 | ||
| 2215 | #ifdef GC_CHECK_STRING_OVERRUN | 2215 | #ifdef GC_CHECK_STRING_OVERRUN |
| 2216 | if (memcmp (string_overrun_cookie, | 2216 | if (memcmp (string_overrun_cookie, |
| 2217 | (char *) from_end - GC_STRING_OVERRUN_COOKIE_SIZE, | 2217 | (char *) from_end - GC_STRING_OVERRUN_COOKIE_SIZE, |
| 2218 | GC_STRING_OVERRUN_COOKIE_SIZE)) | 2218 | GC_STRING_OVERRUN_COOKIE_SIZE)) |
| 2219 | emacs_abort (); | 2219 | emacs_abort (); |
| 2220 | #endif | 2220 | #endif |
| 2221 | 2221 | ||
| 2222 | /* Non-NULL S means it's alive. Copy its data. */ | 2222 | /* Non-NULL S means it's alive. Copy its data. */ |
| 2223 | if (s) | 2223 | if (s) |
| 2224 | { | ||
| 2225 | /* If TB is full, proceed with the next sblock. */ | ||
| 2226 | to_end = (sdata *) ((char *) to + nbytes + GC_STRING_EXTRA); | ||
| 2227 | if (to_end > tb_end) | ||
| 2228 | { | 2224 | { |
| 2229 | tb->next_free = to; | 2225 | /* If TB is full, proceed with the next sblock. */ |
| 2230 | tb = tb->next; | 2226 | sdata *to_end = (sdata *) ((char *) to |
| 2231 | tb_end = (sdata *) ((char *) tb + SBLOCK_SIZE); | 2227 | + nbytes + GC_STRING_EXTRA); |
| 2232 | to = tb->data; | 2228 | if (to_end > tb_end) |
| 2233 | to_end = (sdata *) ((char *) to + nbytes + GC_STRING_EXTRA); | 2229 | { |
| 2234 | } | 2230 | tb->next_free = to; |
| 2231 | tb = tb->next; | ||
| 2232 | tb_end = (sdata *) ((char *) tb + SBLOCK_SIZE); | ||
| 2233 | to = tb->data; | ||
| 2234 | to_end = (sdata *) ((char *) to + nbytes + GC_STRING_EXTRA); | ||
| 2235 | } | ||
| 2235 | 2236 | ||
| 2236 | /* Copy, and update the string's `data' pointer. */ | 2237 | /* Copy, and update the string's `data' pointer. */ |
| 2237 | if (from != to) | 2238 | if (from != to) |
| 2238 | { | 2239 | { |
| 2239 | eassert (tb != b || to < from); | 2240 | eassert (tb != b || to < from); |
| 2240 | memmove (to, from, nbytes + GC_STRING_EXTRA); | 2241 | memmove (to, from, nbytes + GC_STRING_EXTRA); |
| 2241 | to->string->data = SDATA_DATA (to); | 2242 | to->string->data = SDATA_DATA (to); |
| 2242 | } | 2243 | } |
| 2243 | 2244 | ||
| 2244 | /* Advance past the sdata we copied to. */ | 2245 | /* Advance past the sdata we copied to. */ |
| 2245 | to = to_end; | 2246 | to = to_end; |
| 2247 | } | ||
| 2248 | from = from_end; | ||
| 2246 | } | 2249 | } |
| 2250 | b = b->next; | ||
| 2247 | } | 2251 | } |
| 2248 | } | 2252 | while (b); |
| 2249 | 2253 | ||
| 2250 | /* The rest of the sblocks following TB don't contain live data, so | 2254 | /* The rest of the sblocks following TB don't contain live data, so |
| 2251 | we can free them. */ | 2255 | we can free them. */ |
| 2252 | for (b = tb->next; b; b = next) | 2256 | for (b = tb->next; b; ) |
| 2253 | { | 2257 | { |
| 2254 | next = b->next; | 2258 | struct sblock *next = b->next; |
| 2255 | lisp_free (b); | 2259 | lisp_free (b); |
| 2260 | b = next; | ||
| 2261 | } | ||
| 2262 | |||
| 2263 | tb->next_free = to; | ||
| 2264 | tb->next = NULL; | ||
| 2256 | } | 2265 | } |
| 2257 | 2266 | ||
| 2258 | tb->next_free = to; | ||
| 2259 | tb->next = NULL; | ||
| 2260 | current_sblock = tb; | 2267 | current_sblock = tb; |
| 2261 | } | 2268 | } |
| 2262 | 2269 | ||
| @@ -6119,7 +6126,7 @@ mark_face_cache (struct face_cache *c) | |||
| 6119 | int i, j; | 6126 | int i, j; |
| 6120 | for (i = 0; i < c->used; ++i) | 6127 | for (i = 0; i < c->used; ++i) |
| 6121 | { | 6128 | { |
| 6122 | struct face *face = FACE_FROM_ID (c->f, i); | 6129 | struct face *face = FACE_OPT_FROM_ID (c->f, i); |
| 6123 | 6130 | ||
| 6124 | if (face) | 6131 | if (face) |
| 6125 | { | 6132 | { |