create function open_pathfmt() to allow printf formatting on open()

save some space by allowing printf formatting directly rather than
having a buffer and using sprintf

Change-Id: I049c8f898fb4a68a26ad0f0646250c242647ba12
This commit is contained in:
William Wilgus 2022-11-19 22:39:14 -05:00 committed by William Wilgus
parent 8fe42c43c6
commit e7e20fab1b
8 changed files with 42 additions and 53 deletions

View file

@ -32,6 +32,7 @@
#include "bmp.h"
#include "filetypes.h"
#include "language.h"
#include "misc.h"
#include "bitmaps/default_icons.h"
#if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1)
@ -181,10 +182,7 @@ static void load_icons(const char* filename, enum Iconset iconset,
ic->handle = 0;
if (filename[0] && filename[0] != '-')
{
char path[MAX_PATH];
snprintf(path, sizeof(path), ICON_DIR "/%s.bmp", filename);
fd = open(path, O_RDONLY);
fd = open_pathfmt(O_RDONLY, ICON_DIR "/%s.bmp", filename);
if (fd < 0)
return;
buf_size = read_bmp_fd(fd, &ic->bmp, 0,