emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r104677: Merge: Fixes for GLYPH_DEBUG


From: Paul Eggert
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r104677: Merge: Fixes for GLYPH_DEBUG found by GCC 4.6.0 static checking.
Date: Wed, 22 Jun 2011 11:20:15 -0700
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 104677 [merge]
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Wed 2011-06-22 11:20:15 -0700
message:
  Merge: Fixes for GLYPH_DEBUG found by GCC 4.6.0 static checking.
modified:
  src/ChangeLog
  src/dispextern.h
  src/dispnew.c
  src/scroll.c
  src/w32fns.c
  src/xdisp.c
  src/xfaces.c
  src/xfns.c
  src/xterm.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2011-06-22 16:15:41 +0000
+++ b/src/ChangeLog     2011-06-22 18:20:15 +0000
@@ -1,5 +1,33 @@
 2011-06-22  Paul Eggert  <address@hidden>
 
+       Fixes for GLYPH_DEBUG found by GCC 4.6.0 static checking.
+       The following patches are for when GLYPH_DEBUG && !XASSERT.
+       * dispextern.h (trace_redisplay_p, dump_glyph_string):
+       * dispnew.c (flush_stdout):
+       * xdisp.c (dump_glyph_row, dump_glyph_matrix, dump_glyph):
+       Mark as externally visible.
+       * dispnew.c (check_window_matrix_pointers): Now static.
+       * dispnew.c (window_to_frame_vpos):
+       * xfns.c (unwind_create_frame):
+       * xterm.c (x_check_font): Remove unused local.
+       * scroll.c (CHECK_BOUNDS):
+       * xfaces.c (cache_fache): Rename local to avoid shadowing.
+       * xfns.c, w32fns.c (image_cache_refcount, dpyinfo_refcount): Now static.
+       * xdisp.c (check_window_end): Now a no-op if !XASSERTS.
+       (debug_first_unchanged_at_end_vpos, debug_last_unchanged_at_beg_vpos)
+       (debug_dvpos, debug_dy, debug_delta, debug_delta_bytes, debug_end_vpos):
+       Now static.
+       (debug_method_add): Use va_list and vsprintf rather than relying
+       on undefined behavior with wrong number of arguments.
+       (dump_glyph, dump_glyph_row, Fdump_glyph_matrix):
+       Don't assume ptrdiff_t and EMACS_INT are the same width as int.
+       In this code, it's OK to assume C99 behavior for ptrdiff_t formats
+       since we're not interested in debugging glyphs with old libraries.
+       * xfaces.c (cache_face): Move debugging code earlier; this pacifies
+       GCC 4.6.0's static checking.
+
+2011-06-22  Paul Eggert  <address@hidden>
+
        Integer overflow and signedness fixes (Bug#8873).
        A few related buffer overrun fixes, too.
 

=== modified file 'src/dispextern.h'
--- a/src/dispextern.h  2011-06-22 06:16:16 +0000
+++ b/src/dispextern.h  2011-06-22 18:15:23 +0000
@@ -151,7 +151,7 @@
 
 #if GLYPH_DEBUG
 
-extern int trace_redisplay_p;
+extern int trace_redisplay_p EXTERNALLY_VISIBLE;
 #include <stdio.h>
 
 #define TRACE(X)                               \
@@ -3010,7 +3010,7 @@
 #ifdef HAVE_WINDOW_SYSTEM
 
 #if GLYPH_DEBUG
-extern void dump_glyph_string (struct glyph_string *);
+extern void dump_glyph_string (struct glyph_string *) EXTERNALLY_VISIBLE;
 #endif
 
 extern void x_get_glyph_overhangs (struct glyph *, struct frame *,

=== modified file 'src/dispnew.c'
--- a/src/dispnew.c     2011-06-18 19:15:06 +0000
+++ b/src/dispnew.c     2011-06-22 18:15:23 +0000
@@ -155,7 +155,6 @@
 static void make_current (struct glyph_matrix *, struct glyph_matrix *,
                           int);
 static void mirror_make_current (struct window *, int);
-void check_window_matrix_pointers (struct window *);
 #if GLYPH_DEBUG
 static void check_matrix_pointers (struct glyph_matrix *,
                                    struct glyph_matrix *);
@@ -1478,6 +1477,8 @@
    stdout.
 */
 
+void flush_stdout (void) EXTERNALLY_VISIBLE;
+
 void
 flush_stdout (void)
 {
@@ -3052,7 +3053,7 @@
    matrices of leaf window agree with their frame matrices about
    glyph pointers.  */
 
-void
+static void
 check_window_matrix_pointers (struct window *w)
 {
   while (w)
@@ -3116,12 +3117,10 @@
 static int
 window_to_frame_vpos (struct window *w, int vpos)
 {
-  struct frame *f = XFRAME (w->frame);
-
-  xassert (!FRAME_WINDOW_P (f));
+  xassert (!FRAME_WINDOW_P (XFRAME (w->frame)));
   xassert (vpos >= 0 && vpos <= w->desired_matrix->nrows);
   vpos += WINDOW_TOP_EDGE_LINE (w);
-  xassert (vpos >= 0 && vpos <= FRAME_LINES (f));
+  xassert (vpos >= 0 && vpos <= FRAME_LINES (XFRAME (w->frame)));
   return vpos;
 }
 

=== modified file 'src/scroll.c'
--- a/src/scroll.c      2011-04-14 02:20:00 +0000
+++ b/src/scroll.c      2011-06-22 18:15:23 +0000
@@ -268,10 +268,10 @@
 # define CHECK_BOUNDS                                                  \
   do                                                                   \
     {                                                                  \
-      int k;                                                           \
-      for (k = 0; k < window_size; ++k)                                        
\
-       xassert (copy_from[k] == -1                                     \
-                || (copy_from[k] >= 0 && copy_from[k] < window_size)); \
+      int ck;                                                          \
+      for (ck = 0; ck < window_size; ++ck)                             \
+       xassert (copy_from[ck] == -1                                    \
+                || (copy_from[ck] >= 0 && copy_from[ck] < window_size)); \
     }                                                                  \
   while (0);
 #endif

=== modified file 'src/w32fns.c'
--- a/src/w32fns.c      2011-06-10 06:55:18 +0000
+++ b/src/w32fns.c      2011-06-22 18:15:23 +0000
@@ -184,7 +184,7 @@
 static unsigned menu_free_timer = 0;
 
 #if GLYPH_DEBUG
-int image_cache_refcount, dpyinfo_refcount;
+static int image_cache_refcount, dpyinfo_refcount;
 #endif
 
 static HWND w32_visible_system_caret_hwnd;

=== modified file 'src/xdisp.c'
--- a/src/xdisp.c       2011-06-21 21:32:10 +0000
+++ b/src/xdisp.c       2011-06-22 18:15:23 +0000
@@ -2242,7 +2242,7 @@
 #endif /* not 0 */
 
 
-#if GLYPH_DEBUG
+#if GLYPH_DEBUG && XASSERTS
 
 /* Check that the window end of window W is what we expect it
    to be---the last row in the current matrix displaying text.  */
@@ -2264,11 +2264,11 @@
 
 #define CHECK_WINDOW_END(W)    check_window_end ((W))
 
-#else /* not GLYPH_DEBUG */
+#else
 
 #define CHECK_WINDOW_END(W)    (void) 0
 
-#endif /* not GLYPH_DEBUG */
+#endif
 
 
 
@@ -11101,40 +11101,42 @@
 
 /* First and last unchanged row for try_window_id.  */
 
-int debug_first_unchanged_at_end_vpos;
-int debug_last_unchanged_at_beg_vpos;
+static int debug_first_unchanged_at_end_vpos;
+static int debug_last_unchanged_at_beg_vpos;
 
 /* Delta vpos and y.  */
 
-int debug_dvpos, debug_dy;
+static int debug_dvpos, debug_dy;
 
 /* Delta in characters and bytes for try_window_id.  */
 
-EMACS_INT debug_delta, debug_delta_bytes;
+static EMACS_INT debug_delta, debug_delta_bytes;
 
 /* Values of window_end_pos and window_end_vpos at the end of
    try_window_id.  */
 
-EMACS_INT debug_end_vpos;
+static EMACS_INT debug_end_vpos;
 
 /* Append a string to W->desired_matrix->method.  FMT is a printf
-   format string.  A1...A9 are a supplement for a variable-length
-   argument list.  If trace_redisplay_p is non-zero also printf the
+   format string.  If trace_redisplay_p is non-zero also printf the
    resulting string to stderr.  */
 
+static void debug_method_add (struct window *, char const *, ...)
+  ATTRIBUTE_FORMAT_PRINTF (2, 3);
+
 static void
-debug_method_add (w, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9)
-     struct window *w;
-     char *fmt;
-     int a1, a2, a3, a4, a5, a6, a7, a8, a9;
+debug_method_add (struct window *w, char const *fmt, ...)
 {
   char buffer[512];
   char *method = w->desired_matrix->method;
   int len = strlen (method);
   int size = sizeof w->desired_matrix->method;
   int remaining = size - len - 1;
+  va_list ap;
 
-  sprintf (buffer, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9);
+  va_start (ap, fmt);
+  vsprintf (buffer, fmt, ap);
+  va_end (ap);
   if (len && remaining)
     {
       method[len] = '|';
@@ -16265,9 +16267,9 @@
 
 #if GLYPH_DEBUG
 
-void dump_glyph_row (struct glyph_row *, int, int);
-void dump_glyph_matrix (struct glyph_matrix *, int);
-void dump_glyph (struct glyph_row *, struct glyph *, int);
+void dump_glyph_row (struct glyph_row *, int, int) EXTERNALLY_VISIBLE;
+void dump_glyph_matrix (struct glyph_matrix *, int) EXTERNALLY_VISIBLE;
+void dump_glyph (struct glyph_row *, struct glyph *, int) EXTERNALLY_VISIBLE;
 
 
 /* Dump the contents of glyph matrix MATRIX on stderr.
@@ -16294,7 +16296,7 @@
   if (glyph->type == CHAR_GLYPH)
     {
       fprintf (stderr,
-              "  %5d %4c %6d %c %3d 0x%05x %c %4d %1.1d%1.1d\n",
+              "  %5td %4c %6"pI"d %c %3d 0x%05x %c %4d %1.1d%1.1d\n",
               glyph - row->glyphs[TEXT_AREA],
               'C',
               glyph->charpos,
@@ -16315,7 +16317,7 @@
   else if (glyph->type == STRETCH_GLYPH)
     {
       fprintf (stderr,
-              "  %5d %4c %6d %c %3d 0x%05x %c %4d %1.1d%1.1d\n",
+              "  %5td %4c %6"pI"d %c %3d 0x%05x %c %4d %1.1d%1.1d\n",
               glyph - row->glyphs[TEXT_AREA],
               'S',
               glyph->charpos,
@@ -16334,7 +16336,7 @@
   else if (glyph->type == IMAGE_GLYPH)
     {
       fprintf (stderr,
-              "  %5d %4c %6d %c %3d 0x%05x %c %4d %1.1d%1.1d\n",
+              "  %5td %4c %6"pI"d %c %3d 0x%05x %c %4d %1.1d%1.1d\n",
               glyph - row->glyphs[TEXT_AREA],
               'I',
               glyph->charpos,
@@ -16353,7 +16355,7 @@
   else if (glyph->type == COMPOSITE_GLYPH)
     {
       fprintf (stderr,
-              "  %5d %4c %6d %c %3d 0x%05x",
+              "  %5td %4c %6"pI"d %c %3d 0x%05x",
               glyph - row->glyphs[TEXT_AREA],
               '+',
               glyph->charpos,
@@ -16389,7 +16391,7 @@
       fprintf (stderr, "Row Start   End Used oE><\\CTZFesm     X    Y    W    
H    V    A    P\n");
       fprintf (stderr, 
"======================================================================\n");
 
-      fprintf (stderr, "%3d %5d %5d %4d %1.1d%1.1d%1.1d%1.1d\
+      fprintf (stderr, "%3d %5"pI"d %5"pI"d %4d %1.1d%1.1d%1.1d%1.1d\
 %1.1d%1.1d%1.1d%1.1d%1.1d%1.1d%1.1d%1.1d  %4d %4d %4d %4d %4d %4d %4d\n",
               vpos,
               MATRIX_ROW_START_CHARPOS (row),
@@ -16417,7 +16419,7 @@
       fprintf (stderr, "%9d %5d\t%5d\n", row->start.overlay_string_index,
               row->end.overlay_string_index,
               row->continuation_lines_width);
-      fprintf (stderr, "%9d %5d\n",
+      fprintf (stderr, "%9"pI"d %5"pI"d\n",
               CHARPOS (row->start.string_pos),
               CHARPOS (row->end.string_pos));
       fprintf (stderr, "%9d %5d\n", row->start.dpvec_index,
@@ -16482,7 +16484,7 @@
   struct window *w = XWINDOW (selected_window);
   struct buffer *buffer = XBUFFER (w->buffer);
 
-  fprintf (stderr, "PT = %d, BEGV = %d. ZV = %d\n",
+  fprintf (stderr, "PT = %"pI"d, BEGV = %"pI"d. ZV = %"pI"d\n",
           BUF_PT (buffer), BUF_BEGV (buffer), BUF_ZV (buffer));
   fprintf (stderr, "Cursor x = %d, y = %d, hpos = %d, vpos = %d\n",
           w->cursor.x, w->cursor.y, w->cursor.hpos, w->cursor.vpos);

=== modified file 'src/xfaces.c'
--- a/src/xfaces.c      2011-06-22 06:16:16 +0000
+++ b/src/xfaces.c      2011-06-22 18:15:23 +0000
@@ -4380,6 +4380,21 @@
       break;
   face->id = i;
 
+#if GLYPH_DEBUG
+  /* Check that FACE got a unique id.  */
+  {
+    int j, n;
+    struct face *face1;
+
+    for (j = n = 0; j < FACE_CACHE_BUCKETS_SIZE; ++j)
+      for (face1 = c->buckets[j]; face1; face1 = face1->next)
+       if (face1->id == i)
+         ++n;
+
+    xassert (n == 1);
+  }
+#endif /* GLYPH_DEBUG */
+
   /* Maybe enlarge C->faces_by_id.  */
   if (i == c->used)
     {
@@ -4396,21 +4411,6 @@
       c->used++;
     }
 
-#if GLYPH_DEBUG
-  /* Check that FACE got a unique id.  */
-  {
-    int j, n;
-    struct face *face;
-
-    for (j = n = 0; j < FACE_CACHE_BUCKETS_SIZE; ++j)
-      for (face = c->buckets[j]; face; face = face->next)
-       if (face->id == i)
-         ++n;
-
-    xassert (n == 1);
-  }
-#endif /* GLYPH_DEBUG */
-
   c->faces_by_id[i] = face;
 }
 

=== modified file 'src/xfns.c'
--- a/src/xfns.c        2011-06-21 01:38:04 +0000
+++ b/src/xfns.c        2011-06-22 18:15:23 +0000
@@ -145,7 +145,7 @@
 Lisp_Object Qfont_param;
 
 #if GLYPH_DEBUG
-int image_cache_refcount, dpyinfo_refcount;
+static int image_cache_refcount, dpyinfo_refcount;
 #endif
 
 #if defined (USE_GTK) && defined (HAVE_FREETYPE)
@@ -2927,7 +2927,7 @@
   /* If frame is ``official'', nothing to do.  */
   if (!CONSP (Vframe_list) || !EQ (XCAR (Vframe_list), frame))
     {
-#if GLYPH_DEBUG
+#if GLYPH_DEBUG && XASSERTS
       struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
 #endif
 

=== modified file 'src/xterm.c'
--- a/src/xterm.c       2011-06-22 06:16:16 +0000
+++ b/src/xterm.c       2011-06-22 18:15:23 +0000
@@ -9673,8 +9673,6 @@
 static void
 x_check_font (struct frame *f, struct font *font)
 {
-  Lisp_Object frame;
-
   xassert (font != NULL && ! NILP (font->props[FONT_TYPE_INDEX]));
   if (font->driver->check)
     xassert (font->driver->check (f, font) == 0);


reply via email to

[Prev in Thread] Current Thread [Next in Thread]