summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell King <rmk@arm.linux.org.uk>2012-10-18 12:57:22 +0100
committerRussell King <rmk@arm.linux.org.uk>2012-10-20 22:04:30 +0100
commitd098e39e50a0764326133efb8b32197670f318aa (patch)
tree0dd099aea44a5eb1003c0102f62d3fceed2855e9
parent601016a5bed80fd1213138fad7c2c2a5265fba82 (diff)
Update get_file_unsg32() to take a format string
-rw-r--r--vmeta_lib.c16
1 files 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;
}