Re: [RFA/mips] Fix crash trying to print long double float

Andrew Cagney
2004-08-06T21:03:03Z

> One question:
>
>
>>> @@ -633,12 +633,13 @@ floatformat_from_doublest (const struct
>>> static const struct floatformat *
>>> floatformat_from_length (int len)
>>> {
>>> + const struct floatformat *format;
>>> if (len * TARGET_CHAR_BIT == TARGET_FLOAT_BIT)
>>> - return TARGET_FLOAT_FORMAT;
>>> + format = TARGET_FLOAT_FORMAT;
>>> else if (len * TARGET_CHAR_BIT == TARGET_DOUBLE_BIT)
>>> - return TARGET_DOUBLE_FORMAT;
>>> + format = TARGET_DOUBLE_FORMAT;
>>> else if (len * TARGET_CHAR_BIT == TARGET_LONG_DOUBLE_BIT)
>>> - return TARGET_LONG_DOUBLE_FORMAT;
>>> + format = TARGET_LONG_DOUBLE_FORMAT;
>>> /* On i386 the 'long double' type takes 96 bits,
>>> while the real number of used bits is only 80,
>>> both in processor and in memory.
>>> @@ -646,9 +647,13 @@ floatformat_from_length (int len)
>>> else if ((TARGET_LONG_DOUBLE_FORMAT != NULL)
>>> && (len * TARGET_CHAR_BIT ==
>>> TARGET_LONG_DOUBLE_FORMAT->totalsize))
>>> - return TARGET_LONG_DOUBLE_FORMAT;
>>> -
>>> - return NULL;
>>> + format = TARGET_LONG_DOUBLE_FORMAT;
>>> + else
>>> + format = NULL;
>>> + if (format == NULL)
>>> + error ("This GDB does not support %d-bit floating-point values.",
>>> + len & TARGET_CHAR_BIT);
>>> + return format;
>>> }
>
>
> Why do you use a variable? wouldn't have it been simpler to
> add one line at the end like this:
>
> error ("bla bla bla");
> return NULL; /* Will never be reached. */

And:
if (TARGET_FLOAT_FORMAT != NULL && len * TARGET_CHAR_BIT ==
TARGET_FLOAT_BIT)
return TARGET_FLOAT_FORMAT;
...
else
error ("blah, blah");
I don't trust *_FORMAT to be non-NULL.

Andrew