Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-10-15 02:54:06 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-10-15 02:54:06 +0300
commitaca8640b12b6a17f67560a14c6d97c6b80c7301b (patch)
tree2c79e152a0da53015cb0419a6df17aa14bba627e
parenta509e79a4c772a48dee0e2bf56e2b4df97b170f0 (diff)
Cleanup: use defined sizes when accessing file date/time
Also add static assert for struct size assumption.
-rw-r--r--source/blender/windowmanager/intern/wm_files.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 7c9baa2fc26..6b61535333e 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -50,6 +50,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
+#include "BLI_fileops_types.h"
#include "BLI_linklist.h"
#include "BLI_system.h"
#include "BLI_threads.h"
@@ -2368,11 +2369,6 @@ static int wm_open_mainfile_exec(bContext *C, wmOperator *op)
return wm_open_mainfile__open(C, op);
}
-/* currently fits in a pointer */
-struct FileRuntime {
- bool is_untrusted;
-};
-
static char *wm_open_mainfile_description(struct bContext *UNUSED(C),
struct wmOperatorType *UNUSED(op),
struct PointerRNA *params)
@@ -2391,8 +2387,8 @@ static char *wm_open_mainfile_description(struct bContext *UNUSED(C),
}
/* Date. */
- char date_st[16];
- char time_st[8];
+ char date_st[FILELIST_DIRENTRY_DATE_LEN];
+ char time_st[FILELIST_DIRENTRY_TIME_LEN];
bool is_today, is_yesterday;
BLI_filelist_entry_datetime_to_string(
NULL, (int64_t)stats.st_mtime, false, time_st, date_st, &is_today, &is_yesterday);
@@ -2401,13 +2397,20 @@ static char *wm_open_mainfile_description(struct bContext *UNUSED(C),
}
/* Size. */
- char size_str[16];
+ char size_str[FILELIST_DIRENTRY_SIZE_LEN];
BLI_filelist_entry_size_to_string(NULL, (uint64_t)stats.st_size, false, size_str);
return BLI_sprintfN(
"%s\n\n%s: %s %s\n%s: %s", path, N_("Modified"), date_st, time_st, N_("Size"), size_str);
}
+/* currently fits in a pointer */
+struct FileRuntime {
+ bool is_untrusted;
+};
+BLI_STATIC_ASSERT(sizeof(struct FileRuntime) <= sizeof(void *),
+ "Struct must not exceed pointer size");
+
static bool wm_open_mainfile_check(bContext *UNUSED(C), wmOperator *op)
{
struct FileRuntime *file_info = (struct FileRuntime *)&op->customdata;