[Mesa-dev] [PATCH 04/14] glx: Add an optional function call for getting the DRI driver interface.

Eric Anholt eric at anholt.net
Fri Oct 11 22:16:14 CEST 2013


Matt Turner <mattst88 at gmail.com> writes:

> On Mon, Sep 30, 2013 at 1:44 PM, Eric Anholt <eric at anholt.net> wrote:
>> The previous interface relied on a static struct, which meant tha the
>> driver didn't get a chance to edit the struct before the struct got used.
>> For megadrivers, I want to return a variable struct based on what driver
>> is getting loaded.

>> diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c
>> index f1d1164..16f820f 100644
>> --- a/src/glx/dri_common.c
>> +++ b/src/glx/dri_common.c
>> @@ -188,9 +188,25 @@ driOpenDriver(const char *driverName)
>>  }
>>
>>  _X_HIDDEN const __DRIextension **
>> -driGetDriverExtensions(void *handle)
>> +driGetDriverExtensions(void *handle, const char *driver_name)
>>  {
>>     const __DRIextension **extensions = NULL;
>> +   const __DRIextension **(*get_extensions)(void);
>> +   char *get_extensions_name;
>> +
>> +   asprintf(&get_extensions_name, "%s_%s",
>> +            __DRI_DRIVER_GET_EXTENSIONS, driver_name);
>
> My gcc complains about this:
>
> dri_common.c: In function 'driGetDriverExtensions':
> dri_common.c:197:12: warning: ignoring return value of 'asprintf',
> declared with attribute warn_unused_result [-Wunused-result]
>     asprintf(&get_extensions_name, "%s_%s",
>             ^
>
> Kind of silly, but whatever.

Silly as far as any malloc checking is silly.  Wow, what a bad API:

       ... If memory allocation wasn't  possible,  or  some
       other error occurs, these functions will return -1, and the contents of
       strp is undefined.

Seriously, not setting it to NULL on failure?

Applied this diff in v3:

-   asprintf(&get_extensions_name, "%s_%s",
-            __DRI_DRIVER_GET_EXTENSIONS, driver_name);
-   if (get_extensions_name) {
+   if (asprintf(&get_extensions_name, "%s_%s",
+                __DRI_DRIVER_GET_EXTENSIONS, driver_name) != -1) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20131011/f2acd033/attachment.pgp>


More information about the mesa-dev mailing list