static int file_overrides_count;
extern bool drm_shim_driver_prefers_first_render_node;
+#define nfasprintf(...) \
+ { \
+ UNUSED int __ret = asprintf(__VA_ARGS__); \
+ assert(__ret >= 0); \
+ }
+#define nfvasprintf(...) \
+ { \
+ UNUSED int __ret = vasprintf(__VA_ARGS__); \
+ assert(__ret >= 0); \
+ }
+
/* Pick the minor and filename for our shimmed render node. This can be
* either a new one that didn't exist on the system, or if the driver wants,
* it can replace the first render node.
get_dri_render_node_minor(void)
{
for (int i = 0; i < 10; i++) {
- int minor = 128 + i;
- asprintf(&render_node_dirent_name, "renderD%d", minor);
- asprintf(&render_node_path, "/dev/dri/%s",
- render_node_dirent_name);
+ UNUSED int minor = 128 + i;
+ nfasprintf(&render_node_dirent_name, "renderD%d", minor);
+ nfasprintf(&render_node_path, "/dev/dri/%s",
+ render_node_dirent_name);
struct stat st;
if (drm_shim_driver_prefers_first_render_node ||
stat(render_node_path, &st) == -1) {
char *path;
va_list ap;
va_start(ap, path_format);
- vasprintf(&path, path_format, ap);
+ nfvasprintf(&path, path_format, ap);
va_end(ap);
struct file_override *override = &file_overrides[file_overrides_count++];
render_node_path);
}
- asprintf(&device_path,
- "/sys/dev/char/%d:%d/device",
- DRM_MAJOR, render_node_minor);
+ nfasprintf(&device_path,
+ "/sys/dev/char/%d:%d/device",
+ DRM_MAJOR, render_node_minor);
- asprintf(&subsystem_path,
- "/sys/dev/char/%d:%d/device/subsystem",
- DRM_MAJOR, render_node_minor);
+ nfasprintf(&subsystem_path,
+ "/sys/dev/char/%d:%d/device/subsystem",
+ DRM_MAJOR, render_node_minor);
drm_shim_device_init();
* there.
*/
char *sys_dev_drm_dir;
- asprintf(&sys_dev_drm_dir, "/sys/dev/char/%d:%d/device/drm",
- DRM_MAJOR, render_node_minor);
+ nfasprintf(&sys_dev_drm_dir,
+ "/sys/dev/char/%d:%d/device/drm",
+ DRM_MAJOR, render_node_minor);
if (strcmp(path, sys_dev_drm_dir) == 0) {
free(sys_dev_drm_dir);
return 0;
* there.
*/
char *sys_dev_drm_dir;
- asprintf(&sys_dev_drm_dir, "/sys/dev/char/%d:%d/device/drm",
- DRM_MAJOR, render_node_minor);
+ nfasprintf(&sys_dev_drm_dir,
+ "/sys/dev/char/%d:%d/device/drm",
+ DRM_MAJOR, render_node_minor);
if (strcmp(path, sys_dev_drm_dir) == 0) {
free(sys_dev_drm_dir);
return 0;