[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: RFC: Comments on patches for libdrm are welcomed
From: |
Sergey Bugaev |
Subject: |
Re: RFC: Comments on patches for libdrm are welcomed |
Date: |
Mon, 1 Nov 2021 13:26:14 +0300 |
On Sun, Oct 31, 2021 at 8:44 PM Svante Signell <svante.signell@gmail.com> wrote:
> One alternative to the path_max.diff patch is to simply do:
> #ifndef PATH_MAX
> #define PATH_MAX 4096
> #endif
> in xf86drm.c. This is a patch that upstream would accept more easily than the
> proposed one, but is not very Hurdish.
>
> WDYT?
>
> Thanks!
I see libdrm already uses asprintf and vasprintf in a few places, and
the developers seem to be fine with more usage of it [0], so it should
be possible to avoid the little mess of calling snprintf twice and an
explicit malloc.
[0]: https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/108#note_790401
I.e.,
--- libdrm-2.4.107.orig/xf86drm.c
+++ libdrm-2.4.107/xf86drm.c
@@ -3359,7 +3359,8 @@ static char *drmGetMinorNameForFD(int fd
return strdup(name);
#else
struct stat sbuf;
- char buf[PATH_MAX + 1];
+ char *buf;
const char *dev_name = drmGetDeviceName(type);
unsigned int maj, min;
int n;
@@ -3376,11 +3377,19 @@ static char *drmGetMinorNameForFD(int fd
if (!dev_name)
return NULL;
- n = snprintf(buf, sizeof(buf), dev_name, DRM_DIR_NAME, min);
+ n = asprintf(&buf, dev_name, DRM_DIR_NAME, min);
- if (n == -1 || n >= sizeof(buf))
+ if (n == -1)
return NULL;
- return strdup(buf);
+ return buf;
#endif
}
Sergey
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: RFC: Comments on patches for libdrm are welcomed,
Sergey Bugaev <=