Matt Turner <matts...@gmail.com> writes: > On Mon, Sep 30, 2013 at 1:44 PM, Eric Anholt <e...@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) {
pgpzenHsfMqDm.pgp
Description: PGP signature
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev