From e7e20fab1b2b90ea80e118959386017ed1d6f703 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Sat, 19 Nov 2022 22:39:14 -0500 Subject: 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 --- apps/filetypes.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'apps/filetypes.c') diff --git a/apps/filetypes.c b/apps/filetypes.c index 24dc0f2e4d..74607eac1c 100644 --- a/apps/filetypes.c +++ b/apps/filetypes.c @@ -262,9 +262,9 @@ void read_color_theme_file(void) { unknown_file.color = -1; if (!global_settings.colors_file[0] || global_settings.colors_file[0] == '-') return; - snprintf(buffer, MAX_PATH, THEME_DIR "/%s.colours", - global_settings.colors_file); - fd = open(buffer, O_RDONLY); + + fd = open_pathfmt(O_RDONLY, THEME_DIR "/%s.colours", + global_settings.colors_file); if (fd < 0) return; while (read_line(fd, buffer, MAX_PATH) > 0) @@ -303,9 +303,8 @@ void read_viewer_theme_file(void) custom_filetype_icons[i] = filetypes[i].icon; } - snprintf(buffer, MAX_PATH, "%s/%s.icons", ICON_DIR, - global_settings.viewers_icon_file); - fd = open(buffer, O_RDONLY); + fd = open_pathfmt(O_RDONLY, "%s/%s.icons", ICON_DIR, + global_settings.viewers_icon_file); if (fd < 0) return; while (read_line(fd, buffer, MAX_PATH) > 0) -- cgit v1.2.3