path: root/firmware/general.c
diff options
authorMichael Sevakis <>2017-09-18 06:00:05 -0400
committerMichael Sevakis <>2017-11-21 05:01:14 -0500
commitaced667f48c29a160aa4e5c0a8df037092b28189 (patch)
tree66e48e4a27daaf36f01d7ff1ed6876a7de38b0c0 /firmware/general.c
parent5c9688961ef9166cec5225db50d5f73691d8292d (diff)
Undo hacks to meant to get around string formatting limitations
The new vuprintf makes unnecessary workarounds due to formatting limitations. I checked grep output for whatever appeared to fit but it's possible I missed some instances because they weren't so obvious. Also, this means sound settings can dynamically work with any number of decimals rather than the current assumption of one or two. Add an ipow() function to help and take advantage of dynamic field width and precision. Consolidate string formatting of sound settings. Change-Id: I46caf534859dfd1916cd440cd25e5206b192fcd8
Diffstat (limited to 'firmware/general.c')
1 files changed, 2 insertions, 4 deletions
diff --git a/firmware/general.c b/firmware/general.c
index c70d21c4a0..a4e7fba0f6 100644
--- a/firmware/general.c
+++ b/firmware/general.c
@@ -107,7 +107,6 @@ char *create_numbered_filename(char *buffer, const char *path,
int pathlen;
int prefixlen = strlen(prefix);
int suffixlen = strlen(suffix);
- char fmtstring[12];
if (buffer != path)
strlcpy(buffer, path, MAX_PATH);
@@ -152,9 +151,8 @@ char *create_numbered_filename(char *buffer, const char *path,
- snprintf(fmtstring, sizeof(fmtstring), "/%%s%%0%dd%%s", numberlen);
- snprintf(buffer + pathlen, MAX_PATH - pathlen, fmtstring, prefix,
- max_num, suffix);
+ snprintf(buffer + pathlen, MAX_PATH - pathlen, "/%s%0*d%s", prefix,
+ numberlen, max_num, suffix);
#ifdef IF_CNFN_NUM
if (num)