diff options
author | Lionel Landwerlin <[email protected]> | 2020-04-25 12:58:58 +0300 |
---|---|---|
committer | Lionel Landwerlin <[email protected]> | 2020-04-30 11:32:54 +0300 |
commit | fd3c0146723043f66bd18e376fa6526126ff18c0 (patch) | |
tree | 37949cded4a3a256757a2313e76fb51ad47f467e /src/drm-shim/drm_shim.c | |
parent | 764ef4bf1a6fe0c256859d275c5f922d46217dbc (diff) |
drm-shim: silence warnings
Matt is seeing a bunch of warnings :
drm_shim.c:312:4: warning: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Wunused-result]
v2: Add nofail variants of *asprintf (Eric)
Signed-off-by: Lionel Landwerlin <[email protected]>
Acked-by: Matt Turner <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4594>
Diffstat (limited to 'src/drm-shim/drm_shim.c')
-rw-r--r-- | src/drm-shim/drm_shim.c | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/src/drm-shim/drm_shim.c b/src/drm-shim/drm_shim.c index 61a1cb2ae50..1243c607582 100644 --- a/src/drm-shim/drm_shim.c +++ b/src/drm-shim/drm_shim.c @@ -99,6 +99,17 @@ static struct file_override file_overrides[10]; 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. @@ -107,10 +118,10 @@ static void 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) { @@ -143,7 +154,7 @@ drm_shim_override_file(const char *contents, const char *path_format, ...) 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++]; @@ -206,13 +217,13 @@ init_shim(void) 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(); @@ -276,8 +287,9 @@ PUBLIC int __xstat(int ver, const char *path, struct stat *st) * 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; @@ -309,8 +321,9 @@ PUBLIC int __xstat64(int ver, const char *path, struct stat64 *st) * 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; |