[PATCH v4 6/7] Replace alloc+strcpy+strcat with asprintf() & XNFasprintf() calls
walter harms
wharms at bfs.de
Sun Dec 5 12:43:59 PST 2010
Am 05.12.2010 18:51, schrieb Alan Coopersmith:
>
>>> diff --git a/hw/xfree86/common/xf86ShowOpts.c b/hw/xfree86/common/xf86ShowOpts.c
>>> index ce86090..c0fa80a 100644
>>> --- a/hw/xfree86/common/xf86ShowOpts.c
>>> +++ b/hw/xfree86/common/xf86ShowOpts.c
>>> @@ -97,11 +97,8 @@ void DoShowOptions (void) {
>>> );
>>> continue;
>>> }
>>> - pSymbol = malloc(
>>> - strlen(xf86DriverList[i]->driverName) + strlen("ModuleData") + 1
>>> - );
>>> - strcpy (pSymbol, xf86DriverList[i]->driverName);
>>> - strcat (pSymbol, "ModuleData");
>>> + XNFasprintf(&pSymbol, "%sModuleData",
>>> + xf86DriverList[i]->driverName);
>>
>>
>> every code before checks the return value of asprintf but not here ?
>
> We don't need to know the length, and error is not an option from the XNF*
> variants - they either succeed or cause the server to abort. I used the
> XNF* here since if the malloc failed, previously the server exited, just
> going through the sigsegv handler instead of a cleaner AbortServer().
> (NF is "No Fail")
>
mmh, so XNFasprintf() could be void instead of int ?
re,
wh
More information about the xorg-devel
mailing list