[PATCH libdrm 1/3] xf86drm: replace sprintf()+strdup() with asprintf()
Emil Velikov
emil.l.velikov at gmail.com
Mon Mar 26 14:00:01 UTC 2018
On 26 March 2018 at 14:57, Jani Nikula <jani.nikula at linux.intel.com> wrote:
> On Mon, 26 Mar 2018, Eric Engestrom <eric.engestrom at imgtec.com> wrote:
>> Signed-off-by: Eric Engestrom <eric.engestrom at imgtec.com>
>> ---
>> xf86drm.c | 28 ++++++++++++++--------------
>> 1 file changed, 14 insertions(+), 14 deletions(-)
>>
>> diff --git a/xf86drm.c b/xf86drm.c
>> index 3a9d0ed2cc9b196ae7d1..b6e5d8cc1bb50ffe75a2 100644
>> --- a/xf86drm.c
>> +++ b/xf86drm.c
>> @@ -2823,7 +2823,7 @@ static char *drmGetMinorNameForFD(int fd, int type)
>> struct stat sbuf;
>> const char *name = drmGetMinorName(type);
>> int len;
>> - char dev_name[64], buf[64];
>> + char *dev_name, buf[64];
>> int maj, min;
>>
>> if (!name)
>> @@ -2848,20 +2848,22 @@ static char *drmGetMinorNameForFD(int fd, int type)
>>
>> while ((ent = readdir(sysdir))) {
>> if (strncmp(ent->d_name, name, len) == 0) {
>> - snprintf(dev_name, sizeof(dev_name), DRM_DIR_NAME "/%s",
>> - ent->d_name);
>> + if (asprintf(&dev_name, DRM_DIR_NAME "/%s",
>
> Just noting in passing that asprintf is a GNU extension, is that okay?
>
Was going to mention the same thing. Also POSIX please add it to the
next version ;-)
It doesn't seem to make the code shorter, so I'd go with let's drop this?
-Emil
More information about the dri-devel
mailing list