[PATCH 08/11] Convert hw/xfree86/parser code to use Xasprintf() calls
Alan Coopersmith
alan.coopersmith at oracle.com
Tue Nov 30 15:23:30 PST 2010
Matt Turner wrote:
>> @@ -426,13 +425,9 @@ char *
>> xf86uLongToString(unsigned long i)
>> {
>> char *s;
>> - int l;
>>
>> - l = ceil(log10((double)i) + 2.5);
>> - s = malloc(l);
>> - if (!s)
>> + if (Xasprintf(&s, "%lu", i) == -1)
>> return NULL;
>> - sprintf(s, "%lu", i);
>> return s;
>> }
>
> xf86uLongToString kind of looks useless. It's only used in
> hw/xfree86/parser/Pointer.c (seven times). It's part of the ABI, but
> can't we kill it off? I quick glance at drivers didn't show any users.
It certainly seems like it was more useful in a world before Xprintf,
and could easily be replaced by Xasprintf() going forward.
(The length calculation in the original code still hurts my head.
I understand it, but I am very happy to hide that below the
abstraction level of asprintf().)
--
-Alan Coopersmith- alan.coopersmith at oracle.com
Oracle Solaris Platform Engineering: X Window System
More information about the xorg-devel
mailing list