Static checking by GCC 4.8-20130319.
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 24 Mar 2013 02:40:51 +0000 (19:40 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 24 Mar 2013 02:40:51 +0000 (19:40 -0700)
* image.c (gif_load): Assume pass < 3 to pacify GCC.
* process.c (Fset_process_datagram_address)
(Fmake_network_process): Check get_lisp_to_sockaddr_size return value.
* xdisp.c (get_char_face_and_encoding):
(get_glyph_face_and_encoding): Ensure that *CHAR2B is initialized.
(get_glyph_face_and_encoding): Prepare face before possibly using it.
(get_per_char_metric): Don't use CHAR2B if it might not be initialized.

src/ChangeLog
src/image.c
src/process.c
src/xdisp.c

index c4e5753..16e7032 100644 (file)
@@ -1,3 +1,14 @@
+2013-03-24  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Static checking by GCC 4.8-20130319.
+       * image.c (gif_load): Assume pass < 3 to pacify GCC.
+       * process.c (Fset_process_datagram_address)
+       (Fmake_network_process): Check get_lisp_to_sockaddr_size return value.
+       * xdisp.c (get_char_face_and_encoding):
+       (get_glyph_face_and_encoding): Ensure that *CHAR2B is initialized.
+       (get_glyph_face_and_encoding): Prepare face before possibly using it.
+       (get_per_char_metric): Don't use CHAR2B if it might not be initialized.
+
 2013-03-24  Ken Brown  <kbrown@cornell.edu>
 
        * w32fns.c (emacs_abort) [CYGWIN]: Define `_open' as a macro to
index 3eec8b6..21f4861 100644 (file)
@@ -7373,11 +7373,10 @@ gif_load (struct frame *f, struct image *img)
               y < subimg_height;
               y++, row += interlace_increment[pass])
            {
-             if (row >= subimg_height)
+             while (subimg_height <= row)
                {
+                 lint_assume (pass < 3);
                  row = interlace_start[++pass];
-                 while (row >= subimg_height)
-                   row = interlace_start[++pass];
                }
 
              for (x = 0; x < subimg_width; x++)
index bafdca9..ed71ff7 100644 (file)
@@ -2155,7 +2155,7 @@ Returns nil upon error setting address, ADDRESS otherwise.  */)
   channel = XPROCESS (process)->infd;
 
   len = get_lisp_to_sockaddr_size (address, &family);
-  if (datagram_address[channel].len != len)
+  if (len == 0 || datagram_address[channel].len != len)
     return Qnil;
   conv_lisp_to_sockaddr (family, address, datagram_address[channel].sa, len);
   return address;
@@ -3269,7 +3269,8 @@ usage: (make-network-process &rest ARGS)  */)
                {
                  int rfamily, rlen;
                  rlen = get_lisp_to_sockaddr_size (remote, &rfamily);
-                 if (rfamily == lres->ai_family && rlen == lres->ai_addrlen)
+                 if (rlen != 0 && rfamily == lres->ai_family
+                     && rlen == lres->ai_addrlen)
                    conv_lisp_to_sockaddr (rfamily, remote,
                                           datagram_address[s].sa, rlen);
                }
index 02a8e56..25b143d 100644 (file)
@@ -22391,16 +22391,16 @@ get_char_face_and_encoding (struct frame *f, int c, int face_id,
                            XChar2b *char2b, int display_p)
 {
   struct face *face = FACE_FROM_ID (f, face_id);
+  unsigned code = 0;
 
   if (face->font)
     {
-      unsigned code = face->font->driver->encode_char (face->font, c);
+      code = face->font->driver->encode_char (face->font, c);
 
-      if (code != FONT_INVALID_CODE)
-       STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF));
-      else
-       STORE_XCHAR2B (char2b, 0, 0);
+      if (code == FONT_INVALID_CODE)
+       code = 0;
     }
+  STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF));
 
   /* Make sure X resources of the face are allocated.  */
 #ifdef HAVE_X_WINDOWS
@@ -22424,31 +22424,30 @@ get_glyph_face_and_encoding (struct frame *f, struct glyph *glyph,
                             XChar2b *char2b, int *two_byte_p)
 {
   struct face *face;
+  unsigned code = 0;
 
   eassert (glyph->type == CHAR_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 (two_byte_p)
     *two_byte_p = 0;
 
   if (face->font)
     {
-      unsigned code;
-
       if (CHAR_BYTE8_P (glyph->u.ch))
        code = CHAR_TO_BYTE8 (glyph->u.ch);
       else
        code = face->font->driver->encode_char (face->font, glyph->u.ch);
 
-      if (code != FONT_INVALID_CODE)
-       STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF));
-      else
-       STORE_XCHAR2B (char2b, 0, 0);
+      if (code == FONT_INVALID_CODE)
+       code = 0;
     }
 
-  /* Make sure X resources of the face are allocated.  */
-  eassert (face != NULL);
-  PREPARE_FACE_FOR_DISPLAY (f, face);
+  STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF));
   return face;
 }
 
@@ -22758,9 +22757,12 @@ static struct font_metrics *
 get_per_char_metric (struct font *font, XChar2b *char2b)
 {
   static struct font_metrics metrics;
-  unsigned code = (XCHAR2B_BYTE1 (char2b) << 8) | XCHAR2B_BYTE2 (char2b);
+  unsigned code;
 
-  if (! font || code == FONT_INVALID_CODE)
+  if (! font)
+    return NULL;
+  code = (XCHAR2B_BYTE1 (char2b) << 8) | XCHAR2B_BYTE2 (char2b);
+  if (code == FONT_INVALID_CODE)
     return NULL;
   font->driver->text_extents (font, &code, 1, &metrics);
   return &metrics;