From d7ed05d1ba3ab86b9ebc3e5f82e11f31d7a81dd7 Mon Sep 17 00:00:00 2001 From: Jordan Justen Date: Mon, 24 Oct 2022 11:56:58 -0700 Subject: [PATCH] drm-shim: Convert nfasprintf and nfvasprintf to functions Signed-off-by: Jordan Justen Reviewed-by: Lionel Landwerlin Reviewed-by: Eric Engestrom Part-of: --- src/drm-shim/drm_shim.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/drm-shim/drm_shim.c b/src/drm-shim/drm_shim.c index 4dcb963122f..5b613eb286e 100644 --- a/src/drm-shim/drm_shim.c +++ b/src/drm-shim/drm_shim.c @@ -110,16 +110,23 @@ 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); \ - } +static int +nfvasprintf(char **restrict strp, const char *restrict fmt, va_list ap) +{ + int ret = vasprintf(strp, fmt, ap); + assert(ret >= 0); + return ret; +} + +static int +nfasprintf(char **restrict strp, const char *restrict fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + int ret = nfvasprintf(strp, fmt, ap); + va_end(ap); + return ret; +} /* 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,