]> code.delx.au - gnu-emacs/commitdiff
Port --enable-gcc-warnings to GCC 6.1
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 18 May 2016 07:06:12 +0000 (00:06 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 18 May 2016 07:49:29 +0000 (00:49 -0700)
* 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.

20 files changed:
configure.ac
lib-src/etags.c
src/alloc.c
src/dispextern.h
src/dispnew.c
src/fontset.c
src/fringe.c
src/intervals.h
src/keyboard.c
src/macfont.m
src/msdos.c
src/nsfont.m
src/nsterm.h
src/nsterm.m
src/process.c
src/term.c
src/w32term.c
src/xdisp.c
src/xfaces.c
src/xterm.c

index 448c48d9caacab324e45b76d12d950c335497595..22ec4942141c528111652638b52bb1eb54a53e89 100644 (file)
@@ -930,6 +930,7 @@ AS_IF([test $gl_gcc_warnings = no],
   nw="$nw -Wformat-nonliteral"      # we do this a lot
   nw="$nw -Wvla"                    # Emacs uses <vla.h>.
   nw="$nw -Wswitch-default"         # Too many warnings for now
+  nw="$nw -Wunused-const-variable=2" # lisp.h declares const objects.
   nw="$nw -Winline"                 # OK to ignore 'inline'
   nw="$nw -Wstrict-overflow"        # OK to optimize assuming that
                                     # signed overflow has undefined behavior
index e8b71e6b96a3119ebace66cec8c25488279024ab..570d2178547ab12b104af4f078c7c9dc3aa0a2f8 100644 (file)
@@ -4070,13 +4070,13 @@ Yacc_entries (FILE *inf)
   ((assert ("" kw), true)   /* syntax error if not a literal string */ \
    && strneq ((cp), kw, sizeof (kw)-1)         /* cp points at kw */   \
    && notinname ((cp)[sizeof (kw)-1])          /* end of kw */         \
-   && ((cp) = skip_spaces ((cp)+sizeof (kw)-1))) /* skip spaces */
+   && ((cp) = skip_spaces ((cp) + sizeof (kw) - 1), true)) /* skip spaces */
 
 /* Similar to LOOKING_AT but does not use notinname, does not skip */
 #define LOOKING_AT_NOCASE(cp, kw) /* the keyword is a literal string */        \
   ((assert ("" kw), true) /* syntax error if not a literal string */   \
    && strncaseeq ((cp), kw, sizeof (kw)-1)     /* cp points at kw */   \
-   && ((cp) += sizeof (kw)-1))                 /* skip spaces */
+   && ((cp) += sizeof (kw) - 1, true))         /* skip spaces */
 
 /*
  * Read a file, but do no processing.  This is used to do regexp
index c5a4f425f6e2b826635c1a78cc6bf3683a3506f5..054e1ca23ca80fb3ff34e67832d5f8a9d6423242 100644 (file)
@@ -2174,89 +2174,96 @@ free_large_strings (void)
 static void
 compact_small_strings (void)
 {
-  struct sblock *b, *tb, *next;
-  sdata *from, *to, *end, *tb_end;
-  sdata *to_end, *from_end;
-
   /* TB is the sblock we copy to, TO is the sdata within TB we copy
      to, and TB_END is the end of TB.  */
-  tb = oldest_sblock;
-  tb_end = (sdata *) ((char *) tb + SBLOCK_SIZE);
-  to = tb->data;
-
-  /* Step through the blocks from the oldest to the youngest.  We
-     expect that old blocks will stabilize over time, so that less
-     copying will happen this way.  */
-  for (b = oldest_sblock; b; b = b->next)
+  struct sblock *tb = oldest_sblock;
+  if (tb)
     {
-      end = b->next_free;
-      eassert ((char *) end <= (char *) b + SBLOCK_SIZE);
+      sdata *tb_end = (sdata *) ((char *) tb + SBLOCK_SIZE);
+      sdata *to = tb->data;
 
-      for (from = b->data; from < end; from = from_end)
+      /* Step through the blocks from the oldest to the youngest.  We
+        expect that old blocks will stabilize over time, so that less
+        copying will happen this way.  */
+      struct sblock *b = tb;
+      do
        {
-         /* Compute the next FROM here because copying below may
-            overwrite data we need to compute it.  */
-         ptrdiff_t nbytes;
-         struct Lisp_String *s = from->string;
+         sdata *end = b->next_free;
+         eassert ((char *) end <= (char *) b + SBLOCK_SIZE);
+
+         for (sdata *from = b->data; from < end; )
+           {
+             /* Compute the next FROM here because copying below may
+                overwrite data we need to compute it.  */
+             ptrdiff_t nbytes;
+             struct Lisp_String *s = from->string;
 
 #ifdef GC_CHECK_STRING_BYTES
-         /* Check that the string size recorded in the string is the
-            same as the one recorded in the sdata structure.  */
-         if (s && string_bytes (s) != SDATA_NBYTES (from))
-           emacs_abort ();
+             /* Check that the string size recorded in the string is the
+                same as the one recorded in the sdata structure.  */
+             if (s && string_bytes (s) != SDATA_NBYTES (from))
+               emacs_abort ();
 #endif /* GC_CHECK_STRING_BYTES */
 
-         nbytes = s ? STRING_BYTES (s) : SDATA_NBYTES (from);
-         eassert (nbytes <= LARGE_STRING_BYTES);
+             nbytes = s ? STRING_BYTES (s) : SDATA_NBYTES (from);
+             eassert (nbytes <= LARGE_STRING_BYTES);
 
-         nbytes = SDATA_SIZE (nbytes);
-         from_end = (sdata *) ((char *) from + nbytes + GC_STRING_EXTRA);
+             nbytes = SDATA_SIZE (nbytes);
+             sdata *from_end = (sdata *) ((char *) from
+                                          + nbytes + GC_STRING_EXTRA);
 
 #ifdef GC_CHECK_STRING_OVERRUN
-         if (memcmp (string_overrun_cookie,
-                     (char *) from_end - GC_STRING_OVERRUN_COOKIE_SIZE,
-                     GC_STRING_OVERRUN_COOKIE_SIZE))
-           emacs_abort ();
+             if (memcmp (string_overrun_cookie,
+                         (char *) from_end - GC_STRING_OVERRUN_COOKIE_SIZE,
+                         GC_STRING_OVERRUN_COOKIE_SIZE))
+               emacs_abort ();
 #endif
 
-         /* Non-NULL S means it's alive.  Copy its data.  */
-         if (s)
-           {
-             /* If TB is full, proceed with the next sblock.  */
-             to_end = (sdata *) ((char *) to + nbytes + GC_STRING_EXTRA);
-             if (to_end > tb_end)
+             /* Non-NULL S means it's alive.  Copy its data.  */
+             if (s)
                {
-                 tb->next_free = to;
-                 tb = tb->next;
-                 tb_end = (sdata *) ((char *) tb + SBLOCK_SIZE);
-                 to = tb->data;
-                 to_end = (sdata *) ((char *) to + nbytes + GC_STRING_EXTRA);
-               }
+                 /* If TB is full, proceed with the next sblock.  */
+                 sdata *to_end = (sdata *) ((char *) to
+                                            + nbytes + GC_STRING_EXTRA);
+                 if (to_end > tb_end)
+                   {
+                     tb->next_free = to;
+                     tb = tb->next;
+                     tb_end = (sdata *) ((char *) tb + SBLOCK_SIZE);
+                     to = tb->data;
+                     to_end = (sdata *) ((char *) to + nbytes + GC_STRING_EXTRA);
+                   }
 
-             /* Copy, and update the string's `data' pointer.  */
-             if (from != to)
-               {
-                 eassert (tb != b || to < from);
-                 memmove (to, from, nbytes + GC_STRING_EXTRA);
-                 to->string->data = SDATA_DATA (to);
-               }
+                 /* Copy, and update the string's `data' pointer.  */
+                 if (from != to)
+                   {
+                     eassert (tb != b || to < from);
+                     memmove (to, from, nbytes + GC_STRING_EXTRA);
+                     to->string->data = SDATA_DATA (to);
+                   }
 
-             /* Advance past the sdata we copied to.  */
-             to = to_end;
+                 /* Advance past the sdata we copied to.  */
+                 to = to_end;
+               }
+             from = from_end;
            }
+         b = b->next;
        }
-    }
+      while (b);
 
-  /* The rest of the sblocks following TB don't contain live data, so
-     we can free them.  */
-  for (b = tb->next; b; b = next)
-    {
-      next = b->next;
-      lisp_free (b);
+      /* The rest of the sblocks following TB don't contain live data, so
+        we can free them.  */
+      for (b = tb->next; b; )
+       {
+         struct sblock *next = b->next;
+         lisp_free (b);
+         b = next;
+       }
+
+      tb->next_free = to;
+      tb->next = NULL;
     }
 
-  tb->next_free = to;
-  tb->next = NULL;
   current_sblock = tb;
 }
 
@@ -6119,7 +6126,7 @@ mark_face_cache (struct face_cache *c)
       int i, j;
       for (i = 0; i < c->used; ++i)
        {
-         struct face *face = FACE_FROM_ID (c->f, i);
+         struct face *face = FACE_OPT_FROM_ID (c->f, i);
 
          if (face)
            {
index 70358724024c642a8b4bc6e896c851615f058ec7..4deebc146c82aaf31c38a0b34f5eebad42720117 100644 (file)
@@ -1811,13 +1811,20 @@ struct face_cache
   bool_bf menu_face_changed_p : 1;
 };
 
+/* Return a pointer to the cached face with ID on frame F.  */
+
+#define FACE_FROM_ID(F, ID)                                    \
+  (eassert (UNSIGNED_CMP (ID, <, FRAME_FACE_CACHE (F)->used)), \
+   eassume (FRAME_FACE_CACHE (F)->faces_by_id[ID]),            \
+   FRAME_FACE_CACHE (F)->faces_by_id[ID])
+
 /* Return a pointer to the face with ID on frame F, or null if such a
    face doesn't exist.  */
 
-#define FACE_FROM_ID(F, ID)                            \
-     (UNSIGNED_CMP (ID, <, FRAME_FACE_CACHE (F)->used) \
-      ? FRAME_FACE_CACHE (F)->faces_by_id[ID]          \
-      : NULL)
+#define FACE_OPT_FROM_ID(F, ID)                                \
+  (UNSIGNED_CMP (ID, <, FRAME_FACE_CACHE (F)->used)    \
+   ? FACE_FROM_ID (F, ID)                              \
+   : NULL)
 
 #ifdef HAVE_WINDOW_SYSTEM
 
@@ -3082,13 +3089,20 @@ struct image_cache
 };
 
 
+/* A pointer to the image with id ID on frame F.  */
+
+#define IMAGE_FROM_ID(F, ID)                                   \
+  (eassert (UNSIGNED_CMP (ID, <, FRAME_IMAGE_CACHE (F)->used)),        \
+   eassume (FRAME_IMAGE_CACHE (F)->images[ID]),                        \
+   FRAME_IMAGE_CACHE (F)->images[ID])
+
 /* Value is a pointer to the image with id ID on frame F, or null if
    no image with that id exists.  */
 
-#define IMAGE_FROM_ID(F, ID)                                   \
-     (((ID) >= 0 && (ID) < (FRAME_IMAGE_CACHE (F)->used))      \
-      ? FRAME_IMAGE_CACHE (F)->images[ID]                      \
-      : NULL)
+#define IMAGE_OPT_FROM_ID(F, ID)                               \
+  (UNSIGNED_CMP (ID, <, FRAME_IMAGE_CACHE (F)->used)           \
+   ? IMAGE_FROM_ID (F, ID)                                     \
+   : NULL)
 
 /* Size of bucket vector of image caches.  Should be prime.  */
 
index 51caa5b10e7a8bc56a4e73c136d83b1266bbf0b3..4cc908a3c2a76e8954297135c3e2fd5b6ad605a3 100644 (file)
@@ -5177,8 +5177,8 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p
 #ifdef HAVE_WINDOW_SYSTEM
   if (it.what == IT_IMAGE)
     {
-      if ((img = IMAGE_FROM_ID (it.f, it.image_id)) != NULL
-         && !NILP (img->spec))
+      img = IMAGE_OPT_FROM_ID (it.f, it.image_id);
+      if (img && !NILP (img->spec))
        *object = img->spec;
     }
 #endif
@@ -5275,7 +5275,7 @@ mode_line_string (struct window *w, enum window_part part,
          if (glyph->type == IMAGE_GLYPH)
            {
              struct image *img;
-             img = IMAGE_FROM_ID (WINDOW_XFRAME (w), glyph->u.img_id);
+             img = IMAGE_OPT_FROM_ID (WINDOW_XFRAME (w), glyph->u.img_id);
              if (img != NULL)
                *object = img->spec;
              y0 -= row->ascent - glyph->ascent;
@@ -5362,7 +5362,7 @@ marginal_area_string (struct window *w, enum window_part part,
          if (glyph->type == IMAGE_GLYPH)
            {
              struct image *img;
-             img = IMAGE_FROM_ID (WINDOW_XFRAME (w), glyph->u.img_id);
+             img = IMAGE_OPT_FROM_ID (WINDOW_XFRAME (w), glyph->u.img_id);
              if (img != NULL)
                *object = img->spec;
              y0 -= row->ascent - glyph->ascent;
index 4ab13674318d588797c067f62090a2c2a664ed05..d87901d42b80953383cafefa34d4e4e16486e376 100644 (file)
@@ -1304,7 +1304,7 @@ free_realized_fontsets (Lisp_Object base)
            {
              struct frame *f = XFRAME (FONTSET_FRAME (this));
              int face_id = XINT (XCDR (XCAR (tail)));
-             struct face *face = FACE_FROM_ID (f, face_id);
+             struct face *face = FACE_OPT_FROM_ID (f, face_id);
 
              /* Face THIS itself is also freed by the following call.  */
              free_realized_face (f, face);
@@ -1636,7 +1636,7 @@ appended.  By default, FONT-SPEC overrides the previous settings.  */)
            continue;
          if (fontset_id != FRAME_FONTSET (f))
            continue;
-         face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
+         face = FACE_OPT_FROM_ID (f, DEFAULT_FACE_ID);
          if (face)
            font_object = font_load_for_lface (f, face->lface, font_spec);
          else
index 061f78658cffd13481e1f1f316a95ede77efaa95..55f37b887878c288f4f3a459e58e7e233397c817 100644 (file)
@@ -620,7 +620,7 @@ draw_fringe_bitmap_1 (struct window *w, struct glyph_row *row, int left_p, int o
       break;
     }
 
-  p.face = FACE_FROM_ID (f, face_id);
+  p.face = FACE_OPT_FROM_ID (f, face_id);
 
   if (p.face == NULL)
     {
@@ -1627,7 +1627,7 @@ If FACE is nil, reset face to default fringe face.  */)
     {
       struct frame *f = SELECTED_FRAME ();
 
-      if (FACE_FROM_ID (f, FRINGE_FACE_ID)
+      if (FACE_OPT_FROM_ID (f, FRINGE_FACE_ID)
          && lookup_derived_face (f, face, FRINGE_FACE_ID, 1) < 0)
        error ("No such face");
     }
index b8cdcfdc0f5e9dbd7ae4aecf1c3d29a8a2fed8e2..6a5a4129abc4cc9af95b54c0a5cc17d99b78d316 100644 (file)
@@ -197,12 +197,12 @@ set_interval_plist (INTERVAL i, Lisp_Object plist)
 
 /* Is this interval writable?  Replace later with cache access.  */
 #define INTERVAL_WRITABLE_P(i)                                 \
-  (i && (NILP (textget ((i)->plist, Qread_only))               \
-         || !NILP (textget ((i)->plist, Qinhibit_read_only))   \
-        || ((CONSP (Vinhibit_read_only)                        \
-             ? !NILP (Fmemq (textget ((i)->plist, Qread_only), \
-                             Vinhibit_read_only))              \
-             : !NILP (Vinhibit_read_only)))))                  \
+  (NILP (textget ((i)->plist, Qread_only))                     \
+   || !NILP (textget ((i)->plist, Qinhibit_read_only))         \
+   || ((CONSP (Vinhibit_read_only)                             \
+       ? !NILP (Fmemq (textget ((i)->plist, Qread_only),       \
+                       Vinhibit_read_only))                    \
+       : !NILP (Vinhibit_read_only))))
 
 /* Macros to tell whether insertions before or after this interval
    should stick to it.  Now we have Vtext_property_default_nonsticky,
index fe04b3f2b5e190caa1bcf163054ececd1d963919..ef2e2788bf306998231476bd450e383cf8e2998d 100644 (file)
@@ -2280,6 +2280,11 @@ read_decoded_event_from_main_queue (struct timespec *end_time,
     }
 }
 
+#if 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wclobbered"
+#endif
+
 /* Read a character from the keyboard; call the redisplay if needed.  */
 /* commandflag 0 means do not autosave, but do redisplay.
    -1 means do not redisplay, but do autosave.
@@ -3120,6 +3125,10 @@ read_char (int commandflag, Lisp_Object map,
   return c;
 }
 
+#if 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
+# pragma GCC diagnostic pop
+#endif
+
 /* Record a key that came from a mouse menu.
    Record it for echoing, for this-command-keys, and so on.  */
 
index 04456283fa1877696107c9a9691fb86efe26d574..79001344769fdb8473c4f9c6db097fc270763de7 100644 (file)
@@ -2856,7 +2856,8 @@ macfont_draw (struct glyph_string *s, int from, int to, int x, int y,
     {
       if (s->hl == DRAW_MOUSE_FACE)
         {
-          face = FACE_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
+          face = FACE_OPT_FROM_ID (s->f,
+                                  MOUSE_HL_INFO (s->f)->mouse_face_face_id);
           if (!face)
             face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
         }
index 62411ea2f6d223ac2aaf800a7ea23d13d6f91b3b..c2b19a651733cc10a545454fb7ce3e98f824e11e 100644 (file)
@@ -795,8 +795,8 @@ static void
 IT_set_face (int face)
 {
   struct frame *sf = SELECTED_FRAME ();
-  struct face *fp  = FACE_FROM_ID (sf, face);
-  struct face *dfp = FACE_FROM_ID (sf, DEFAULT_FACE_ID);
+  struct face *fp  = FACE_OPT_FROM_ID (sf, face);
+  struct face *dfp = FACE_OPT_FROM_ID (sf, DEFAULT_FACE_ID);
   unsigned long fg, bg, dflt_fg, dflt_bg;
   struct tty_display_info *tty = FRAME_TTY (sf);
 
@@ -1076,7 +1076,7 @@ IT_clear_screen (struct frame *f)
      any valid faces and will abort.  Instead, use the initial screen
      colors; that should mimic what a Unix tty does, which simply clears
      the screen with whatever default colors are in use.  */
-  if (FACE_FROM_ID (SELECTED_FRAME (), DEFAULT_FACE_ID) == NULL)
+  if (FACE_OPT_FROM_ID (SELECTED_FRAME (), DEFAULT_FACE_ID) == NULL)
     ScreenAttrib = (initial_screen_colors[0] << 4) | initial_screen_colors[1];
   else
     IT_set_face (0);
index 92e7d1154bf9580cf0b734262025289e1d032881..7c97c6fd0ae0e1b396abc420b29f6f1f6aab1102 100644 (file)
@@ -1071,7 +1071,7 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
       face = s->face;
       break;
     case NS_DUMPGLYPH_MOUSEFACE:
-      face = FACE_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
+      face = FACE_OPT_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
       if (!face)
         face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
       break;
index 6cad337f3f866798c28c35d17332230a073cee15..c2285c90e6217093813a00f04c055e3a16f15576 100644 (file)
@@ -1014,7 +1014,7 @@ struct x_output
 #define FRAME_NS_TITLEBAR_HEIGHT(f) ((f)->output_data.ns->titlebar_height)
 #define FRAME_TOOLBAR_HEIGHT(f) ((f)->output_data.ns->toolbar_height)
 
-#define FRAME_DEFAULT_FACE(f) FACE_FROM_ID (f, DEFAULT_FACE_ID)
+#define FRAME_DEFAULT_FACE(f) FACE_OPT_FROM_ID (f, DEFAULT_FACE_ID)
 
 #define FRAME_NS_VIEW(f) ((f)->output_data.ns->view)
 #define FRAME_CURSOR_COLOR(f) ((f)->output_data.ns->cursor_color)
index 1d48c041bad7bf2f0f910b63c16466869d386b39..b815d775d765553329dac664530f6e783ab2113d 100644 (file)
@@ -2878,7 +2878,7 @@ ns_draw_window_cursor (struct window *w, struct glyph_row *glyph_row,
   ns_clip_to_row (w, glyph_row, ANY_AREA, NO); /* do ns_focus(f, &r, 1); if remove */
 
 
-  face = FACE_FROM_ID (f, phys_cursor_glyph->face_id);
+  face = FACE_OPT_FROM_ID (f, phys_cursor_glyph->face_id);
   if (face && NS_FACE_BACKGROUND (face)
       == ns_index_color (FRAME_CURSOR_COLOR (f), f))
     {
@@ -2950,7 +2950,7 @@ ns_draw_vertical_window_border (struct window *w, int x, int y0, int y1)
 
   NSTRACE ("ns_draw_vertical_window_border");
 
-  face = FACE_FROM_ID (f, VERTICAL_BORDER_FACE_ID);
+  face = FACE_OPT_FROM_ID (f, VERTICAL_BORDER_FACE_ID);
   if (face)
       [ns_lookup_indexed_color(face->foreground, f) set];
 
@@ -2972,7 +2972,7 @@ ns_draw_window_divider (struct window *w, int x0, int x1, int y0, int y1)
 
   NSTRACE ("ns_draw_window_divider");
 
-  face = FACE_FROM_ID (f, WINDOW_DIVIDER_FACE_ID);
+  face = FACE_OPT_FROM_ID (f, WINDOW_DIVIDER_FACE_ID);
   if (face)
       [ns_lookup_indexed_color(face->foreground, f) set];
 
@@ -3305,9 +3305,9 @@ ns_dumpglyphs_box_or_relief (struct glyph_string *s)
 
   if (s->hl == DRAW_MOUSE_FACE)
     {
-      face = FACE_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
+      face = FACE_OPT_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
       if (!face)
-        face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
+        face = FACE_OPT_FROM_ID (s->f, MOUSE_FACE_ID);
     }
   else
     face = s->face;
@@ -3372,8 +3372,9 @@ ns_maybe_dumpglyphs_background (struct glyph_string *s, char force_p)
           struct face *face;
           if (s->hl == DRAW_MOUSE_FACE)
             {
-              face = FACE_FROM_ID (s->f,
-                                  MOUSE_HL_INFO (s->f)->mouse_face_face_id);
+              face
+               = FACE_OPT_FROM_ID (s->f,
+                                   MOUSE_HL_INFO (s->f)->mouse_face_face_id);
               if (!face)
                 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
             }
@@ -3439,7 +3440,7 @@ ns_dumpglyphs_image (struct glyph_string *s, NSRect r)
      with its background color), we must clear just the image area. */
   if (s->hl == DRAW_MOUSE_FACE)
     {
-      face = FACE_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
+      face = FACE_OPT_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
       if (!face)
        face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
     }
@@ -3556,7 +3557,8 @@ ns_dumpglyphs_stretch (struct glyph_string *s)
 
       if (s->hl == DRAW_MOUSE_FACE)
        {
-         face = FACE_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
+         face = FACE_OPT_FROM_ID (s->f,
+                                 MOUSE_HL_INFO (s->f)->mouse_face_face_id);
          if (!face)
            face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
        }
index eed875db70b1ac96ffe5f198ab5d9a464828b9fd..3e5b83d27dc0d2d6a815f0b1607663fa8770a764 100644 (file)
@@ -151,6 +151,18 @@ bool inhibit_sentinels;
 # define SOCK_CLOEXEC 0
 #endif
 
+/* True if ERRNUM represents an error where the system call would
+   block if a blocking variant were used.  */
+static bool
+would_block (int errnum)
+{
+#ifdef EWOULDBLOCK
+  if (EWOULDBLOCK != EAGAIN && errnum == EWOULDBLOCK)
+    return true;
+#endif
+  return errnum == EAGAIN;
+}
+
 #ifndef HAVE_ACCEPT4
 
 /* Emulate GNU/Linux accept4 and socket well enough for this module.  */
@@ -4453,15 +4465,7 @@ server_accept_connection (Lisp_Object server, int channel)
   if (s < 0)
     {
       int code = errno;
-
-      if (code == EAGAIN)
-       return;
-#ifdef EWOULDBLOCK
-      if (code == EWOULDBLOCK)
-       return;
-#endif
-
-      if (!NILP (ps->log))
+      if (!would_block (code) && !NILP (ps->log))
        call3 (ps->log, server, Qnil,
               concat3 (build_string ("accept failed with code"),
                        Fnumber_to_string (make_number (code)),
@@ -5016,12 +5020,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
                  int nread = read_process_output (proc, wait_proc->infd);
                  if (nread < 0)
                    {
-                   if (errno == EIO || errno == EAGAIN)
-                     break;
-#ifdef EWOULDBLOCK
-                   if (errno == EWOULDBLOCK)
-                     break;
-#endif
+                     if (errno == EIO || would_block (errno))
+                       break;
                    }
                  else
                    {
@@ -5405,11 +5405,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
                  if (do_display)
                    redisplay_preserve_echo_area (12);
                }
-#ifdef EWOULDBLOCK
-             else if (nread == -1 && errno == EWOULDBLOCK)
-               ;
-#endif
-             else if (nread == -1 && errno == EAGAIN)
+             else if (nread == -1 && would_block (errno))
                ;
 #ifdef WINDOWSNT
              /* FIXME: Is this special case still needed?  */
@@ -6147,11 +6143,7 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len,
 
          if (rv < 0)
            {
-             if (errno == EAGAIN
-#ifdef EWOULDBLOCK
-                 || errno == EWOULDBLOCK
-#endif
-                 )
+             if (would_block (errno))
                /* Buffer is full.  Wait, accepting input;
                   that may allow the program
                   to finish doing output and read more.  */
index 43972109655ca360dfc3f8c32e95ee0b4ac680b2..07cc3a955f3621435a1f690072e6c8bdc081e77f 100644 (file)
@@ -1954,8 +1954,6 @@ turn_off_face (struct frame *f, int face_id)
   struct face *face = FACE_FROM_ID (f, face_id);
   struct tty_display_info *tty = FRAME_TTY (f);
 
-  eassert (face != NULL);
-
   if (tty->TS_exit_attribute_mode)
     {
       /* Capability "me" will turn off appearance modes double-bright,
index 72e1245ae59ff2399bf8070ef7b09c05536bc879..14a43c15641ea7d2d04d836e1b195e3ffc15d605 100644 (file)
@@ -613,7 +613,7 @@ w32_draw_vertical_window_border (struct window *w, int x, int y0, int y1)
   r.bottom = y1;
 
   hdc = get_frame_dc (f);
-  face = FACE_FROM_ID (f, VERTICAL_BORDER_FACE_ID);
+  face = FACE_OPT_FROM_ID (f, VERTICAL_BORDER_FACE_ID);
   if (face)
     w32_fill_rect (f, hdc, face->foreground, &r);
   else
@@ -630,9 +630,11 @@ w32_draw_window_divider (struct window *w, int x0, int x1, int y0, int y1)
 {
   struct frame *f = XFRAME (WINDOW_FRAME (w));
   HDC hdc = get_frame_dc (f);
-  struct face *face = FACE_FROM_ID (f, WINDOW_DIVIDER_FACE_ID);
-  struct face *face_first = FACE_FROM_ID (f, WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID);
-  struct face *face_last = FACE_FROM_ID (f, WINDOW_DIVIDER_LAST_PIXEL_FACE_ID);
+  struct face *face = FACE_OPT_FROM_ID (f, WINDOW_DIVIDER_FACE_ID);
+  struct face *face_first
+    = FACE_OPT_FROM_ID (f, WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID);
+  struct face *face_last
+    = FACE_OPT_FROM_ID (f, WINDOW_DIVIDER_LAST_PIXEL_FACE_ID);
   unsigned long color = face ? face->foreground : FRAME_FOREGROUND_PIXEL (f);
   unsigned long color_first = (face_first
                               ? face_first->foreground
@@ -991,7 +993,7 @@ x_set_mouse_face_gc (struct glyph_string *s)
 
   /* What face has to be used last for the mouse face?  */
   face_id = MOUSE_HL_INFO (s->f)->mouse_face_face_id;
-  face = FACE_FROM_ID (s->f, face_id);
+  face = FACE_OPT_FROM_ID (s->f, face_id);
   if (face == NULL)
     face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
 
index d0ff95257cefa2263a6944591779676d1253e499..bec7339d064489b94d9cb2e5810ee3309d02ca33 100644 (file)
@@ -1813,7 +1813,7 @@ estimate_mode_line_height (struct frame *f, enum face_id face_id)
         cache and mode line face are not yet initialized.  */
       if (FRAME_FACE_CACHE (f))
        {
-         struct face *face = FACE_FROM_ID (f, face_id);
+         struct face *face = FACE_OPT_FROM_ID (f, face_id);
          if (face)
            {
              if (face->font)
@@ -2918,7 +2918,7 @@ init_iterator (struct it *it, struct window *w,
 
       /* If we have a boxed mode line, make the first character appear
         with a left box line.  */
-      face = FACE_FROM_ID (it->f, remapped_base_face_id);
+      face = FACE_OPT_FROM_ID (it->f, remapped_base_face_id);
       if (face && face->box != FACE_NO_BOX)
        it->start_of_box_run_p = true;
     }
@@ -3877,9 +3877,9 @@ handle_face_prop (struct it *it)
        {
          struct face *new_face = FACE_FROM_ID (it->f, new_face_id);
          /* If it->face_id is -1, old_face below will be NULL, see
-            the definition of FACE_FROM_ID.  This will happen if this
+            the definition of FACE_OPT_FROM_ID.  This will happen if this
             is the initial call that gets the face.  */
-         struct face *old_face = FACE_FROM_ID (it->f, it->face_id);
+         struct face *old_face = FACE_OPT_FROM_ID (it->f, it->face_id);
 
          /* If the value of face_id of the iterator is -1, we have to
             look in front of IT's position and see whether there is a
@@ -3888,7 +3888,7 @@ handle_face_prop (struct it *it)
            {
              int prev_face_id = face_before_it_pos (it);
 
-             old_face = FACE_FROM_ID (it->f, prev_face_id);
+             old_face = FACE_OPT_FROM_ID (it->f, prev_face_id);
            }
 
          /* If the new face has a box, but the old face does not,
@@ -3988,7 +3988,7 @@ handle_face_prop (struct it *it)
       if (new_face_id != it->face_id)
        {
          struct face *new_face = FACE_FROM_ID (it->f, new_face_id);
-         struct face *old_face = FACE_FROM_ID (it->f, it->face_id);
+         struct face *old_face = FACE_OPT_FROM_ID (it->f, it->face_id);
 
          /* If new face has a box but old face hasn't, this is the
             start of a run of characters with box, i.e. it has a
@@ -4847,7 +4847,6 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
          it->font_height = XCAR (XCDR (spec));
          if (!NILP (it->font_height))
            {
-             struct face *face = FACE_FROM_ID (it->f, it->face_id);
              int new_height = -1;
 
              if (CONSP (it->font_height)
@@ -4866,6 +4865,7 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
                {
                  /* Call function with current height as argument.
                     Value is the new height.  */
+                 struct face *face = FACE_FROM_ID (it->f, it->face_id);
                  Lisp_Object height;
                  height = safe_call1 (it->font_height,
                                       face->lface[LFACE_HEIGHT_INDEX]);
@@ -4887,6 +4887,7 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
                  /* Evaluate IT->font_height with `height' bound to the
                     current specified height to get the new height.  */
                  ptrdiff_t count = SPECPDL_INDEX ();
+                 struct face *face = FACE_FROM_ID (it->f, it->face_id);
 
                  specbind (Qheight, face->lface[LFACE_HEIGHT_INDEX]);
                  value = safe_eval (it->font_height);
@@ -6096,7 +6097,7 @@ pop_it (struct it *it)
       break;
     case GET_FROM_STRING:
       {
-       struct face *face = FACE_FROM_ID (it->f, it->face_id);
+       struct face *face = FACE_OPT_FROM_ID (it->f, it->face_id);
 
        /* Restore the face_box_p flag, since it could have been
           overwritten by the face of the object that we just finished
@@ -6777,7 +6778,7 @@ static next_element_function const get_next_element[NUM_IT_METHODS] =
    || ((IT)->cmp_it.stop_pos == (CHARPOS)                              \
        && composition_reseat_it (&(IT)->cmp_it, CHARPOS, BYTEPOS,      \
                                 END_CHARPOS, (IT)->w,                  \
-                                FACE_FROM_ID ((IT)->f, (IT)->face_id), \
+                                FACE_OPT_FROM_ID ((IT)->f, (IT)->face_id),     \
                                 (IT)->string)))
 
 
@@ -7206,7 +7207,7 @@ get_next_display_element (struct it *it)
       if (it->method == GET_FROM_STRING && it->sp)
        {
          int face_id = underlying_face_id (it);
-         struct face *face = FACE_FROM_ID (it->f, face_id);
+         struct face *face = FACE_OPT_FROM_ID (it->f, face_id);
 
          if (face)
            {
@@ -7739,8 +7740,8 @@ next_element_from_display_vector (struct it *it)
       /* Glyphs in the display vector could have the box face, so we
         need to set the related flags in the iterator, as
         appropriate.  */
-      this_face = FACE_FROM_ID (it->f, it->face_id);
-      prev_face = FACE_FROM_ID (it->f, prev_face_id);
+      this_face = FACE_OPT_FROM_ID (it->f, it->face_id);
+      prev_face = FACE_OPT_FROM_ID (it->f, prev_face_id);
 
       /* Is this character the first character of a box-face run?  */
       it->start_of_box_run_p = (this_face && this_face->box != FACE_NO_BOX
@@ -7765,7 +7766,7 @@ next_element_from_display_vector (struct it *it)
                                            it->saved_face_id);
            }
        }
-      next_face = FACE_FROM_ID (it->f, next_face_id);
+      next_face = FACE_OPT_FROM_ID (it->f, next_face_id);
       it->end_of_box_run_p = (this_face && this_face->box != FACE_NO_BOX
                              && (!next_face
                                  || next_face->box == FACE_NO_BOX));
@@ -18662,7 +18663,7 @@ try_window_id (struct window *w)
       eassert (MATRIX_ROW_DISPLAYS_TEXT_P (first_unchanged_at_end_row));
       row = find_last_row_displaying_text (w->current_matrix, &it,
                                           first_unchanged_at_end_row);
-      eassert (row && MATRIX_ROW_DISPLAYS_TEXT_P (row));
+      eassume (row && MATRIX_ROW_DISPLAYS_TEXT_P (row));
       adjust_window_ends (w, row, true);
       eassert (w->window_end_bytepos >= 0);
       IF_DEBUG (debug_method_add (w, "A"));
@@ -18692,10 +18693,9 @@ try_window_id (struct window *w)
       struct glyph_row *current_row = current_matrix->rows + vpos;
       struct glyph_row *desired_row = desired_matrix->rows + vpos;
 
-      for (row = NULL;
-          row == NULL && vpos >= first_vpos;
-          --vpos, --current_row, --desired_row)
+      for (row = NULL; !row; --vpos, --current_row, --desired_row)
        {
+         eassert (first_vpos <= vpos);
          if (desired_row->enabled_p)
            {
              if (MATRIX_ROW_DISPLAYS_TEXT_P (desired_row))
@@ -18705,7 +18705,6 @@ try_window_id (struct window *w)
            row  = current_row;
        }
 
-      eassert (row != NULL);
       w->window_end_vpos = vpos + 1;
       w->window_end_pos = Z - MATRIX_ROW_END_CHARPOS (row);
       w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (row);
@@ -19630,15 +19629,14 @@ extend_face_to_end_of_line (struct it *it)
     return;
 
   /* The default face, possibly remapped. */
-  default_face = FACE_FROM_ID (f, lookup_basic_face (f, DEFAULT_FACE_ID));
+  default_face = FACE_OPT_FROM_ID (f, lookup_basic_face (f, DEFAULT_FACE_ID));
 
   /* Face extension extends the background and box of IT->face_id
      to the end of the line.  If the background equals the background
      of the frame, we don't have to do anything.  */
-  if (it->face_before_selective_p)
-    face = FACE_FROM_ID (f, it->saved_face_id);
-  else
-    face = FACE_FROM_ID (f, it->face_id);
+  face = FACE_OPT_FROM_ID (f, (it->face_before_selective_p
+                              ? it->face_id
+                              : it->saved_face_id));
 
   if (FRAME_WINDOW_P (f)
       && MATRIX_ROW_DISPLAYS_TEXT_P (it->glyph_row)
@@ -24612,7 +24610,6 @@ get_glyph_face_and_encoding (struct frame *f, struct glyph *glyph,
   face = FACE_FROM_ID (f, glyph->face_id);
 
   /* Make sure X resources of the face are allocated.  */
-  eassert (face != NULL);
   prepare_face_for_display (f, face);
 
   if (face->font)
@@ -24744,7 +24741,7 @@ fill_gstring_glyph_string (struct glyph_string *s, int face_id,
   s->cmp_id = glyph->u.cmp.id;
   s->cmp_from = glyph->slice.cmp.from;
   s->cmp_to = glyph->slice.cmp.to + 1;
-  s->face = FACE_FROM_ID (s->f, face_id);
+  s->face = FACE_OPT_FROM_ID (s->f, face_id);
   lgstring = composition_gstring_from_id (s->cmp_id);
   s->font = XFONT_OBJECT (LGSTRING_FONT (lgstring));
   glyph++;
@@ -24873,7 +24870,6 @@ fill_image_glyph_string (struct glyph_string *s)
 {
   eassert (s->first_glyph->type == IMAGE_GLYPH);
   s->img = IMAGE_FROM_ID (s->f, s->first_glyph->u.img_id);
-  eassert (s->img);
   s->slice = s->first_glyph->slice.img;
   s->face = FACE_FROM_ID (s->f, s->first_glyph->face_id);
   s->font = s->face->font;
@@ -25337,7 +25333,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p)
 #define BUILD_COMPOSITE_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \
   do {                                                                     \
     int face_id = (row)->glyphs[area][START].face_id;                      \
-    struct face *base_face = FACE_FROM_ID (f, face_id);                            \
+    struct face *base_face = FACE_OPT_FROM_ID (f, face_id);                \
     ptrdiff_t cmp_id = (row)->glyphs[area][START].u.cmp.id;                \
     struct composition *cmp = composition_table[cmp_id];                   \
     XChar2b *char2b;                                                       \
@@ -25960,7 +25956,6 @@ produce_image_glyph (struct it *it)
   eassert (it->what == IT_IMAGE);
 
   face = FACE_FROM_ID (it->f, it->face_id);
-  eassert (face);
   /* Make sure X resources of the face is loaded.  */
   prepare_face_for_display (it->f, face);
 
@@ -25975,7 +25970,6 @@ produce_image_glyph (struct it *it)
     }
 
   img = IMAGE_FROM_ID (it->f, it->image_id);
-  eassert (img);
   /* Make sure X resources of the image is loaded.  */
   prepare_image_for_display (it->f, img);
 
@@ -26131,7 +26125,6 @@ produce_xwidget_glyph (struct it *it)
   eassert (it->what == IT_XWIDGET);
 
   struct face *face = FACE_FROM_ID (it->f, it->face_id);
-  eassert (face);
   /* Make sure X resources of the face is loaded.  */
   prepare_face_for_display (it->f, face);
 
@@ -28018,7 +28011,7 @@ get_window_cursor_type (struct window *w, struct glyph *glyph, int *width,
              /* Using a block cursor on large images can be very annoying.
                 So use a hollow cursor for "large" images.
                 If image is not transparent (no mask), also use hollow cursor.  */
-             struct image *img = IMAGE_FROM_ID (f, glyph->u.img_id);
+             struct image *img = IMAGE_OPT_FROM_ID (f, glyph->u.img_id);
              if (img != NULL && IMAGEP (img->spec))
                {
                  /* Arbitrarily, interpret "Large" as >32x32 and >NxN
@@ -30105,7 +30098,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
       /* Look for :pointer property on image.  */
       if (glyph != NULL && glyph->type == IMAGE_GLYPH)
        {
-         struct image *img = IMAGE_FROM_ID (f, glyph->u.img_id);
+         struct image *img = IMAGE_OPT_FROM_ID (f, glyph->u.img_id);
          if (img != NULL && IMAGEP (img->spec))
            {
              Lisp_Object image_map, hotspot;
index ac1370003dfaa4af6a68386fe81f13468d6206d1..c42e55333cf4056817d0a0c5357ec65ef8773ca4 100644 (file)
@@ -3694,7 +3694,7 @@ Default face attributes override any local face attributes.  */)
   if (EQ (face, Qdefault))
     {
       struct face_cache *c = FRAME_FACE_CACHE (f);
-      struct face *newface, *oldface = FACE_FROM_ID (f, DEFAULT_FACE_ID);
+      struct face *newface, *oldface = FACE_OPT_FROM_ID (f, DEFAULT_FACE_ID);
       Lisp_Object attrs[LFACE_VECTOR_SIZE];
 
       /* This can be NULL (e.g., in batch mode).  */
@@ -3777,7 +3777,7 @@ return the font name used for CHARACTER.  */)
     {
       struct frame *f = decode_live_frame (frame);
       int face_id = lookup_named_face (f, face, true);
-      struct face *fface = FACE_FROM_ID (f, face_id);
+      struct face *fface = FACE_OPT_FROM_ID (f, face_id);
 
       if (! fface)
        return Qnil;
@@ -4429,15 +4429,13 @@ lookup_named_face (struct frame *f, Lisp_Object symbol, bool signal_p)
 {
   Lisp_Object attrs[LFACE_VECTOR_SIZE];
   Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE];
-  struct face *default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
+  struct face *default_face = FACE_OPT_FROM_ID (f, DEFAULT_FACE_ID);
 
   if (default_face == NULL)
     {
       if (!realize_basic_faces (f))
        return -1;
       default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
-      if (default_face == NULL)
-       emacs_abort (); /* realize_basic_faces must have set it up  */
     }
 
   if (! get_lface_attributes (f, symbol, symbol_attrs, signal_p, 0))
@@ -4600,9 +4598,6 @@ lookup_derived_face (struct frame *f, Lisp_Object symbol, int face_id,
   Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE];
   struct face *default_face = FACE_FROM_ID (f, face_id);
 
-  if (!default_face)
-    emacs_abort ();
-
   if (!get_lface_attributes (f, symbol, symbol_attrs, signal_p, 0))
     return -1;
 
@@ -4706,7 +4701,7 @@ x_supports_face_attributes_p (struct frame *f,
       merge_face_vectors (f, attrs, merged_attrs, 0);
 
       face_id = lookup_face (f, merged_attrs);
-      face = FACE_FROM_ID (f, face_id);
+      face = FACE_OPT_FROM_ID (f, face_id);
 
       if (! face)
        error ("Cannot make face");
@@ -4976,14 +4971,12 @@ face for italic.  */)
     attrs[i] = Qunspecified;
   merge_face_ref (f, attributes, attrs, true, 0);
 
-  def_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
+  def_face = FACE_OPT_FROM_ID (f, DEFAULT_FACE_ID);
   if (def_face == NULL)
     {
       if (! realize_basic_faces (f))
        error ("Cannot realize default face");
       def_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
-      if (def_face == NULL)
-       emacs_abort ();  /* realize_basic_faces must have set it up  */
     }
 
   /* Dispatch to the appropriate handler.  */
@@ -5453,7 +5446,7 @@ realize_x_face (struct face_cache *cache, Lisp_Object attrs[LFACE_VECTOR_SIZE])
 
   /* Determine the font to use.  Most of the time, the font will be
      the same as the font of the default face, so try that first.  */
-  default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
+  default_face = FACE_OPT_FROM_ID (f, DEFAULT_FACE_ID);
   if (default_face
       && lface_same_font_attributes_p (default_face->lface, attrs))
     {
@@ -6093,7 +6086,6 @@ face_at_string_position (struct window *w, Lisp_Object string,
     *endptr = -1;
 
   base_face = FACE_FROM_ID (f, base_face_id);
-  eassert (base_face);
 
   /* Optimize the default case that there is no face property.  */
   if (NILP (prop)
@@ -6140,7 +6132,7 @@ merge_faces (struct frame *f, Lisp_Object face_name, int face_id,
   Lisp_Object attrs[LFACE_VECTOR_SIZE];
   struct face *base_face;
 
-  base_face = FACE_FROM_ID (f, base_face_id);
+  base_face = FACE_OPT_FROM_ID (f, base_face_id);
   if (!base_face)
     return base_face_id;
 
@@ -6168,7 +6160,7 @@ merge_faces (struct frame *f, Lisp_Object face_name, int face_id,
       struct face *face;
       if (face_id < 0)
        return base_face_id;
-      face = FACE_FROM_ID (f, face_id);
+      face = FACE_OPT_FROM_ID (f, face_id);
       if (!face)
        return base_face_id;
       merge_face_vectors (f, face->lface, attrs, 0);
@@ -6288,7 +6280,7 @@ DEFUN ("dump-face", Fdump_face, Sdump_face, 0, 1, 0, doc: /* */)
     {
       struct face *face;
       CHECK_NUMBER (n);
-      face = FACE_FROM_ID (SELECTED_FRAME (), XINT (n));
+      face = FACE_OPT_FROM_ID (SELECTED_FRAME (), XINT (n));
       if (face == NULL)
        error ("Not a valid face");
       dump_realized_face (face);
index 28856cfe192d1d533cad7977d17682228d79998e..beef61d1618036383417d3cb0833678fcbb9a9e1 100644 (file)
@@ -1062,7 +1062,7 @@ x_draw_vertical_window_border (struct window *w, int x, int y0, int y1)
   struct frame *f = XFRAME (WINDOW_FRAME (w));
   struct face *face;
 
-  face = FACE_FROM_ID (f, VERTICAL_BORDER_FACE_ID);
+  face = FACE_OPT_FROM_ID (f, VERTICAL_BORDER_FACE_ID);
   if (face)
     XSetForeground (FRAME_X_DISPLAY (f), f->output_data.x->normal_gc,
                    face->foreground);
@@ -1081,9 +1081,11 @@ static void
 x_draw_window_divider (struct window *w, int x0, int x1, int y0, int y1)
 {
   struct frame *f = XFRAME (WINDOW_FRAME (w));
-  struct face *face = FACE_FROM_ID (f, WINDOW_DIVIDER_FACE_ID);
-  struct face *face_first = FACE_FROM_ID (f, WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID);
-  struct face *face_last = FACE_FROM_ID (f, WINDOW_DIVIDER_LAST_PIXEL_FACE_ID);
+  struct face *face = FACE_OPT_FROM_ID (f, WINDOW_DIVIDER_FACE_ID);
+  struct face *face_first
+    = FACE_OPT_FROM_ID (f, WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID);
+  struct face *face_last
+    = FACE_OPT_FROM_ID (f, WINDOW_DIVIDER_LAST_PIXEL_FACE_ID);
   unsigned long color = face ? face->foreground : FRAME_FOREGROUND_PIXEL (f);
   unsigned long color_first = (face_first
                               ? face_first->foreground
@@ -1505,7 +1507,7 @@ x_set_mouse_face_gc (struct glyph_string *s)
 
   /* What face has to be used last for the mouse face?  */
   face_id = MOUSE_HL_INFO (s->f)->mouse_face_face_id;
-  face = FACE_FROM_ID (s->f, face_id);
+  face = FACE_OPT_FROM_ID (s->f, face_id);
   if (face == NULL)
     face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
 
@@ -2156,6 +2158,7 @@ static const XColor *
 x_color_cells (Display *dpy, int *ncells)
 {
   struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
+  eassume (dpyinfo);
 
   if (dpyinfo->color_cells == NULL)
     {
@@ -2352,17 +2355,19 @@ x_alloc_nearest_color_1 (Display *dpy, Colormap cmap, XColor *color)
          equal to a cached pixel color recorded earlier, there was a
          change in the colormap, so clear the color cache.  */
       struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
-      XColor *cached_color;
+      eassume (dpyinfo);
 
-      if (dpyinfo->color_cells
-         && (cached_color = &dpyinfo->color_cells[color->pixel],
-             (cached_color->red != color->red
-              || cached_color->blue != color->blue
-              || cached_color->green != color->green)))
+      if (dpyinfo->color_cells)
        {
-         xfree (dpyinfo->color_cells);
-         dpyinfo->color_cells = NULL;
-         dpyinfo->ncolor_cells = 0;
+         XColor *cached_color = &dpyinfo->color_cells[color->pixel];
+         if (cached_color->red != color->red
+             || cached_color->blue != color->blue
+             || cached_color->green != color->green)
+           {
+             xfree (dpyinfo->color_cells);
+             dpyinfo->color_cells = NULL;
+             dpyinfo->ncolor_cells = 0;
+           }
        }
     }