From: Paul Eggert Date: Sun, 24 Mar 2013 02:40:51 +0000 (-0700) Subject: Static checking by GCC 4.8-20130319. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~2026^2~526^2~104 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a9ebfa0b3eb23056f523742e53ce79279cae1bd0;p=emacs.git 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. --- diff --git a/src/ChangeLog b/src/ChangeLog index c4e57537522..16e70324af2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2013-03-24 Paul Eggert + + 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 * w32fns.c (emacs_abort) [CYGWIN]: Define `_open' as a macro to diff --git a/src/image.c b/src/image.c index 3eec8b6c13d..21f486176df 100644 --- a/src/image.c +++ b/src/image.c @@ -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++) diff --git a/src/process.c b/src/process.c index bafdca9bd63..ed71ff76e6a 100644 --- a/src/process.c +++ b/src/process.c @@ -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); } diff --git a/src/xdisp.c b/src/xdisp.c index 02a8e56b3bd..25b143d362a 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -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;