[PATCH RFA] Another utils.c patch

David Taylor taylor@cygnus.com
Sat Apr 1 00:00:00 GMT 2000


    Date: Mon, 20 Mar 2000 12:35:19 -0700
    From: Kevin Buettner <kevinb@cygnus.com>

    On Mar 20, 12:45pm, David Taylor wrote:

    >        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));
    > 
    > Approved.

    Thanks for approving this so quickly.  However, I had withdrawn the
    above patch in favor of the one below.  I would prefer to get approval
    for the one below.  They are, however, functionally equivalent.  If
    you prefer the one above for some reason, I can check that one in
    instead.

Either version is okay; I prefer the newer one, but either is acceptable.

	    * 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 */



More information about the Gdb-patches mailing list