[PATCH xserver 11/19] xfree86: Remove DriverRec1 compat struct

Aaron Plattner aplattner at nvidia.com
Wed Jan 25 16:28:03 UTC 2017


On 01/24/2017 04:36 PM, Emil Velikov wrote:
> On 23 January 2017 at 19:32, Adam Jackson <ajax at redhat.com> wrote:
>> The idea here is that the driver might have once been old enough to not
>> have the driverFunc slot in DriverRec, with the module ABI not having
>> changed when it was added. That was ages ago, and drivers always declare
>> themselves with DriverRec not DriverRec1, so uninitialized slots will
>> simply be zero.
>>
>> Signed-off-by: Adam Jackson <ajax at redhat.com>
>> ---
>>  hw/xfree86/common/xf86Helper.c |  9 +--------
>>  hw/xfree86/common/xf86str.h    | 10 ----------
>>  2 files changed, 1 insertion(+), 18 deletions(-)
>>
>> diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
>> index f48af75..b464864 100644
>> --- a/hw/xfree86/common/xf86Helper.c
>> +++ b/hw/xfree86/common/xf86Helper.c
>> @@ -79,14 +79,7 @@ xf86AddDriver(DriverPtr driver, void *module, int flags)
>>      xf86DriverList = xnfreallocarray(xf86DriverList,
>>                                       xf86NumDrivers, sizeof(DriverPtr));
> Unrelated question:
> This is a rather common pattern - foo++; reallocarray(.. foo...)
> Wondering if starting with a base (say 8 ?) and doubling as the limit
> is reached isn't a more common/practical solution. Or there's (has
> been?) memory constrained environments where that was a bad idea ?

Then you need code to count and conditionally realloc. This is not a 
performance-critical path, so just reallocing every time seems simpler 
to me, especially when you can paper over error handling with the xnf* 
functions.

>>      xf86DriverList[xf86NumDrivers - 1] = xnfalloc(sizeof(DriverRec));
>> -    if (flags & HaveDriverFuncs)
> I was purging through this as well (as mentioned in the original
> series) and noticed that some drivers do not use/set the
> HaveDriverFuncs flag.
> Although looking at it now, we should be safe.
>
> Reviewed-by: Emil Velikov <emil.l.velikov at gmail.com>
>
> -Emil


More information about the xorg-devel mailing list