Thank you very much for your work. I shall send patch v3 for it.

Thanks.

On 11/22/2014 05:57 AM, Jakub Jelinek wrote:
> On Sat, Nov 22, 2014 at 05:03:37AM +0800, Chen Gang wrote:
>> According to the next code, 'pretty_name' may need additional bytes more
>> than 16 (may have unlimited length for array type). There is an easy way
>> to fix it: use 'pretty_print' for 'pretty_name'.
>>
>> Let the code meet 2 white spaces alignment coding styles (originally,
>> some of code is 1 white sapce alignment).
>>
>> It passes testsuite under fedora 20 x86_64-unknown-linux-gnu.
>>
>> 2014-11-22  Chen Gang  <gang.chen.5...@gmail.com>
>>
>>         * ubsan.c (ubsan_type_descriptor): Use 'pretty_print' for
>>         'pretty_name' to avoid memory overflow
> 
> Add a . at the end.
> 
>>        while (deref_depth-- > 0)
>> -        pretty_name[pos++] = '*';
>> -      pretty_name[pos++] = '\'';
>> -      pretty_name[pos] = '\0';
>> +    pp_star(&pretty_name);
>> +      pp_quote(&pretty_name);
> 
> Formatting, missing space before (.  Happens many times in the patch.
> 
>>        if (dom && TREE_CODE (TYPE_MAX_VALUE (dom)) == INTEGER_CST)
>> -        pos += sprintf (&pretty_name[pos], HOST_WIDE_INT_PRINT_DEC,
>> -                        tree_to_uhwi (TYPE_MAX_VALUE (dom)) + 1);
>> +        pp_printf (&pretty_name, HOST_WIDE_INT_PRINT_DEC,
>> +                   tree_to_uhwi (TYPE_MAX_VALUE (dom)) + 1);
> 
> You don't know if TYPE_MAX_VALUE (dom) will fit into uhwi, and you are
> using signed printing anyway.
> You said that using pp_wide_int breaks too many tests, so perhaps
> do
>   if (tree_fits_uhwi_p (TYPE_MAX_VALUE (dom))
>       && tree_to_uhwi (TYPE_MAX_VALUE (dom)) + 1 != 0)
>     pp_printf (..., HOST_WIDE_INT_PRINT_UNSIGNED,
>   else
>     pp_wide_int (..., wi::to_widest (TYPE_MAX_VALUE (dom)) + 1);
> ?
> 

Thanks.
-- 
Chen Gang

Open share and attitude like air water and life which God blessed

Reply via email to