From d098e39e50a0764326133efb8b32197670f318aa Mon Sep 17 00:00:00 2001 From: Russell King Date: Thu, 18 Oct 2012 12:57:22 +0100 Subject: Update get_file_unsg32() to take a format string --- vmeta_lib.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/vmeta_lib.c b/vmeta_lib.c index f1f5a98..cfb4dcf 100644 --- a/vmeta_lib.c +++ b/vmeta_lib.c @@ -356,23 +356,31 @@ static int get_version(const char *filename) return version; } -static UNSG32 get_file_unsg32(const char *filename) +static UNSG32 get_file_unsg32(const char *fmt, ...) { + char buf[80]; + va_list ap; FILE *file; UNSG32 result; int ret; - file = fopen(filename, "r"); + va_start(ap, fmt); + ret = vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + if (ret >= sizeof(buf)) + return -VDEC_OS_DRIVER_OPEN_FAIL; + + file = fopen(buf, "r"); if(!file) { dbg_printf(VDEC_DEBUG_ALL, "Error: %s: fopen %s failed\n", - __FUNCTION__, filename); + __FUNCTION__, buf); return -VDEC_OS_DRIVER_OPEN_FAIL; } ret = fscanf(file, "0x%x", &result); if (ret != 1) { dbg_printf(VDEC_DEBUG_ALL, "Error: %s: fscanf %s failed\n", - __FUNCTION__, filename); + __FUNCTION__, buf); result = 0; } -- cgit