This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


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

Re: [PATCH RFA] Another utils.c patch


On Mar 19, 12:20am, Kevin Buettner wrote:
> Subject: [PATCH RFA] Another utils.c patch
> This fixes another bug uncovered by running the testsuite for the
> IA-64...  may I check this one in?
> 
> 	* utils.c (floatformat_from_doublest): Make sure space that we're
> 	writing the float to is completely initialized to zeroes, even
> 	when the number of bits in the float is not evenly divisible
> 	by FLOATFORMAT_CHAR_BIT.
> 
> Index: utils.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/utils.c,v
> retrieving revision 1.4
> diff -u -p -r1.4 utils.c
> --- utils.c	2000/03/04 02:23:06	1.4
> +++ utils.c	2000/03/19 07:12:00
> @@ -2722,7 +2722,8 @@ floatformat_from_doublest (fmt, from, to
>    unsigned char *uto = (unsigned char *) to;
>  
>    memcpy (&dfrom, from, sizeof (dfrom));
> -  memset (uto, 0, fmt->totalsize / FLOATFORMAT_CHAR_BIT);
> +  memset (uto, 0, fmt->totalsize / FLOATFORMAT_CHAR_BIT
> +                  + ((fmt->totalsize % FLOATFORMAT_CHAR_BIT) == 0 ? 0 : 1));
>    if (dfrom == 0)
>      return;			/* Result is zero */
>    if (dfrom != dfrom)		/* Result is NaN */
> 
>-- End of excerpt from Kevin Buettner

I withdraw the patch above in favor of the one below.  (The patch above
is not as concise as the one below.  But they should both produce the
same results.)

	* utils.c (floatformat_from_doublest): Make sure space that we're
	writing the float to is completely initialized to zeroes, even
	when the number of bits in the float is not evenly divisible
	by FLOATFORMAT_CHAR_BIT.

Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.4
diff -u -p -r1.4 utils.c
--- utils.c	2000/03/04 02:23:06	1.4
+++ utils.c	2000/03/19 17:36:49
@@ -2722,7 +2722,8 @@ floatformat_from_doublest (fmt, from, to
   unsigned char *uto = (unsigned char *) to;
 
   memcpy (&dfrom, from, sizeof (dfrom));
-  memset (uto, 0, fmt->totalsize / FLOATFORMAT_CHAR_BIT);
+  memset (uto, 0, (fmt->totalsize + FLOATFORMAT_CHAR_BIT - 1) 
+                    / FLOATFORMAT_CHAR_BIT);
   if (dfrom == 0)
     return;			/* Result is zero */
   if (dfrom != dfrom)		/* Result is NaN */


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