This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.25-285-g7224e32


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  7224e32d7be41b39358defc0e33d2737307aa06a (commit)
      from  1721145f0341d70a6d7807b172c5eb400b508fc0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=7224e32d7be41b39358defc0e33d2737307aa06a

commit 7224e32d7be41b39358defc0e33d2737307aa06a
Author: Carlos O'Donell <carlos@redhat.com>
Date:   Mon May 8 16:11:45 2017 -0400

    vfprintf.c: Refactor magic number 32 into EXTSIZ.
    
    The magic number 32 is used everywhere as extra size to
    use when doing certain operations. This commit refactors
    that into a macro so you can change this value if you're
    debugging something in a local build.

diff --git a/ChangeLog b/ChangeLog
index 49378f6..768274f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-05-08  Carlos O'Donell  <carlos@redhat.com>
+
+	* stdio-common/vfprintf.c (EXTSIZ): Define.
+	(vfprintf): Use EXTSIZ.
+	(printf_positional): Likewise.
+
 2017-05-08  Joseph Myers  <joseph@codesourcery.com>
 
 	* sysdeps/unix/sysv/linux/kernel-features.h
diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c
index 54b1ba2..2cf7c8a 100644
--- a/stdio-common/vfprintf.c
+++ b/stdio-common/vfprintf.c
@@ -45,6 +45,10 @@
 #define va_list	_IO_va_list
 #undef BUFSIZ
 #define BUFSIZ		_IO_BUFSIZ
+/* In some cases we need extra space for all the output which is not
+   counted in the width of the string. We assume 32 characters is
+   enough.  */
+#define EXTSIZ		32
 #define ARGCHECK(S, Format) \
   do									      \
     {									      \
@@ -1456,20 +1460,19 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
 	    left = 1;
 	  }
 
-	if (__glibc_unlikely (width >= INT_MAX / sizeof (CHAR_T) - 32))
+	if (__glibc_unlikely (width >= INT_MAX / sizeof (CHAR_T) - EXTSIZ))
 	  {
 	    __set_errno (EOVERFLOW);
 	    done = -1;
 	    goto all_done;
 	  }
 
-	if (width >= WORK_BUFFER_SIZE - 32)
+	if (width >= WORK_BUFFER_SIZE - EXTSIZ)
 	  {
-	    /* We have to use a special buffer.  The "32" is just a safe
-	       bet for all the output which is not counted in the width.  */
-	    size_t needed = ((size_t) width + 32) * sizeof (CHAR_T);
+	    /* We have to use a special buffer.  */
+	    size_t needed = ((size_t) width + EXTSIZ) * sizeof (CHAR_T);
 	    if (__libc_use_alloca (needed))
-	      workend = (CHAR_T *) alloca (needed) + width + 32;
+	      workend = (CHAR_T *) alloca (needed) + width + EXTSIZ;
 	    else
 	      {
 		workstart = (CHAR_T *) malloc (needed);
@@ -1478,7 +1481,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
 		    done = -1;
 		    goto all_done;
 		  }
-		workend = workstart + width + 32;
+		workend = workstart + width + EXTSIZ;
 	      }
 	  }
       }
@@ -1489,20 +1492,19 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
       width = read_int (&f);
 
       if (__glibc_unlikely (width == -1
-			    || width >= INT_MAX / sizeof (CHAR_T) - 32))
+			    || width >= INT_MAX / sizeof (CHAR_T) - EXTSIZ))
 	{
 	  __set_errno (EOVERFLOW);
 	  done = -1;
 	  goto all_done;
 	}
 
-      if (width >= WORK_BUFFER_SIZE - 32)
+      if (width >= WORK_BUFFER_SIZE - EXTSIZ)
 	{
-	  /* We have to use a special buffer.  The "32" is just a safe
-	     bet for all the output which is not counted in the width.  */
-	  size_t needed = ((size_t) width + 32) * sizeof (CHAR_T);
+	  /* We have to use a special buffer.  */
+	  size_t needed = ((size_t) width + EXTSIZ) * sizeof (CHAR_T);
 	  if (__libc_use_alloca (needed))
-	    workend = (CHAR_T *) alloca (needed) + width + 32;
+	    workend = (CHAR_T *) alloca (needed) + width + EXTSIZ;
 	  else
 	    {
 	      workstart = (CHAR_T *) malloc (needed);
@@ -1511,7 +1513,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
 		  done = -1;
 		  goto all_done;
 		}
-	      workend = workstart + width + 32;
+	      workend = workstart + width + EXTSIZ;
 	    }
 	}
       if (*f == L_('$'))
@@ -1562,23 +1564,23 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
 	}
       else
 	prec = 0;
-      if (prec > width && prec > WORK_BUFFER_SIZE - 32)
+      if (prec > width && prec > WORK_BUFFER_SIZE - EXTSIZ)
 	{
 	  /* Deallocate any previously allocated buffer because it is
 	     too small.  */
 	  if (__glibc_unlikely (workstart != NULL))
 	    free (workstart);
 	  workstart = NULL;
-	  if (__glibc_unlikely (prec >= INT_MAX / sizeof (CHAR_T) - 32))
+	  if (__glibc_unlikely (prec >= INT_MAX / sizeof (CHAR_T) - EXTSIZ))
 	    {
 	      __set_errno (EOVERFLOW);
 	      done = -1;
 	      goto all_done;
 	    }
-	  size_t needed = ((size_t) prec + 32) * sizeof (CHAR_T);
+	  size_t needed = ((size_t) prec + EXTSIZ) * sizeof (CHAR_T);
 
 	  if (__libc_use_alloca (needed))
-	    workend = (CHAR_T *) alloca (needed) + prec + 32;
+	    workend = (CHAR_T *) alloca (needed) + prec + EXTSIZ;
 	  else
 	    {
 	      workstart = (CHAR_T *) malloc (needed);
@@ -1587,7 +1589,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
 		  done = -1;
 		  goto all_done;
 		}
-	      workend = workstart + prec + 32;
+	      workend = workstart + prec + EXTSIZ;
 	    }
 	}
       JUMP (*f, step2_jumps);
@@ -1964,23 +1966,23 @@ printf_positional (_IO_FILE *s, const CHAR_T *format, int readonly_format,
 	}
 
       /* Maybe the buffer is too small.  */
-      if (MAX (prec, width) + 32 > WORK_BUFFER_SIZE)
+      if (MAX (prec, width) + EXTSIZ > WORK_BUFFER_SIZE)
 	{
-	  if (__libc_use_alloca ((MAX (prec, width) + 32)
+	  if (__libc_use_alloca ((MAX (prec, width) + EXTSIZ)
 				 * sizeof (CHAR_T)))
-	    workend = ((CHAR_T *) alloca ((MAX (prec, width) + 32)
+	    workend = ((CHAR_T *) alloca ((MAX (prec, width) + EXTSIZ)
 					  * sizeof (CHAR_T))
-		       + (MAX (prec, width) + 32));
+		       + (MAX (prec, width) + EXTSIZ));
 	  else
 	    {
-	      workstart = (CHAR_T *) malloc ((MAX (prec, width) + 32)
+	      workstart = (CHAR_T *) malloc ((MAX (prec, width) + EXTSIZ)
 					     * sizeof (CHAR_T));
 	      if (workstart == NULL)
 		{
 		  done = -1;
 		  goto all_done;
 		}
-	      workend = workstart + (MAX (prec, width) + 32);
+	      workend = workstart + (MAX (prec, width) + EXTSIZ);
 	    }
 	}
 

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog               |    6 +++++
 stdio-common/vfprintf.c |   52 ++++++++++++++++++++++++----------------------
 2 files changed, 33 insertions(+), 25 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]