From a9dbaf3755ac1abad109970e0fff190bb7418ac2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 18 Feb 2015 07:26:10 +1100 Subject: Ensure BLI_stat() return value is checked. also add function attrs on BLI_fileops to ensure they're used correctly. --- source/blender/blenkernel/intern/bpath.c | 2 +- source/blender/blenkernel/intern/packedFile.c | 2 +- source/blender/blenkernel/intern/text.c | 16 ++++++++++++---- 3 files changed, 14 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c index fc3c1a20700..3488cff7315 100644 --- a/source/blender/blenkernel/intern/bpath.c +++ b/source/blender/blenkernel/intern/bpath.c @@ -233,7 +233,7 @@ static int findFileRecursive(char *filename_new, BLI_join_dirfile(path, sizeof(path), dirname, de->d_name); - if (BLI_stat(path, &status) != 0) + if (BLI_stat(path, &status) == -1) continue; /* cant stat, don't bother with this file, could print debug info here */ if (S_ISREG(status.st_mode)) { /* is file */ diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index d186b4299a5..b989bb2760f 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -376,7 +376,7 @@ int checkPackedFile(const char *filename, PackedFile *pf) BLI_strncpy(name, filename, sizeof(name)); BLI_path_abs(name, G.main->name); - if (BLI_stat(name, &st)) { + if (BLI_stat(name, &st) == -1) { ret_val = PF_NOFILE; } else if (st.st_size != pf->size) { diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index c5a8cbe68b2..9f441b45db9 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -375,8 +375,12 @@ int BKE_text_reload(Text *text) fclose(fp); - BLI_stat(str, &st); - text->mtime = st.st_mtime; + if (BLI_stat(str, &st) != -1) { + text->mtime = st.st_mtime; + } + else { + text->mtime = 0; + } text_from_buf(text, buffer, len); @@ -431,8 +435,12 @@ Text *BKE_text_load_ex(Main *bmain, const char *file, const char *relpath, const fclose(fp); - BLI_stat(str, &st); - ta->mtime = st.st_mtime; + if (BLI_stat(str, &st) != -1) { + ta->mtime = st.st_mtime; + } + else { + ta->mtime = 0; + } text_from_buf(ta, buffer, len); -- cgit v1.2.3