[Bf-blender-cvs] [23d09b954e2] tmp-flock: BLI_fileops flock: More attemps to fix windows build.

Bastien Montagne noreply at git.blender.org
Tue Jan 17 18:10:13 CET 2023


Commit: 23d09b954e2602fb8d7c79dabffb551f4dd298e7
Author: Bastien Montagne
Date:   Tue Jan 17 18:09:21 2023 +0100
Branches: tmp-flock
https://developer.blender.org/rB23d09b954e2602fb8d7c79dabffb551f4dd298e7

BLI_fileops flock: More attemps to fix windows build.

===================================================================

M	source/blender/blenlib/intern/fileops.c
M	source/blender/blenlib/tests/BLI_fileops_test.cc

===================================================================

diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c
index a56503ba5cb..c18b214affa 100644
--- a/source/blender/blenlib/intern/fileops.c
+++ b/source/blender/blenlib/intern/fileops.c
@@ -320,7 +320,6 @@ bool BLI_flock_exclusive(const int file_descriptor, const bool is_blocking)
 }
 bool BLI_flock_release(const int file_descriptor)
 {
-  OVERLAPPED overlapp_info = {0};
   return UnlockFile(_get_osfhandle(file_descriptor), 0, 0, INT_MAX, INT_MAX);
 }
 
diff --git a/source/blender/blenlib/tests/BLI_fileops_test.cc b/source/blender/blenlib/tests/BLI_fileops_test.cc
index 568fff5a52b..da324bdcc6f 100644
--- a/source/blender/blenlib/tests/BLI_fileops_test.cc
+++ b/source/blender/blenlib/tests/BLI_fileops_test.cc
@@ -1,16 +1,14 @@
 /* SPDX-License-Identifier: Apache-2.0 */
 
-#include <fcntl.h>
+#include "BLI_fileops.hh"
 
+#include <fcntl.h>
 #ifdef WIN32
-#  include "BLI_winstuff.h"
 #  include <io.h>
 #else
 #  include <unistd.h> /* FreeBSD, for write() and close(). */
 #endif
 
-#include "BLI_fileops.hh"
-
 #include "testing/testing.h"
 
 namespace blender::tests {
@@ -56,39 +54,39 @@ TEST(fileops, flock_file)
   const std::string filepath_str = test_files_dir + "/asset_library/новый/blender_assets.cats.txt";
   const char *filepath = filepath_str.c_str();
 
-  const int fhandle_1 = BLI_open(filepath, O_BINARY | O_RDONLY, 0);
-  const int fhandle_2 = BLI_open(filepath, O_BINARY | O_RDONLY, 0);
+  const int fdescriptor_1 = BLI_open(filepath, O_BINARY | O_RDONLY, 0);
+  const int fdescriptor_2 = BLI_open(filepath, O_BINARY | O_RDONLY, 0);
 
-  bool flock_result = BLI_flock_shared(fhandle_1, false);
+  bool flock_result = BLI_flock_shared(fdescriptor_1, false);
   ASSERT_TRUE(flock_result);
 
-  flock_result = BLI_flock_shared(fhandle_2, false);
+  flock_result = BLI_flock_shared(fdescriptor_2, false);
   ASSERT_TRUE(flock_result);
 
-  flock_result = BLI_flock_release(fhandle_2);
+  flock_result = BLI_flock_release(fdescriptor_2);
   ASSERT_TRUE(flock_result);
 
   /* Acquiring an exclusive lock on a file  which already has another handle locked should not be
    * possible. */
-  flock_result = BLI_flock_exclusive(fhandle_2, false);
+  flock_result = BLI_flock_exclusive(fdescriptor_2, false);
   ASSERT_FALSE(flock_result);
 
-  flock_result = BLI_flock_release(fhandle_1);
+  flock_result = BLI_flock_release(fdescriptor_1);
   ASSERT_TRUE(flock_result);
 
-  flock_result = BLI_flock_exclusive(fhandle_2, false);
+  flock_result = BLI_flock_exclusive(fdescriptor_2, false);
   ASSERT_TRUE(flock_result);
 
-  flock_result = BLI_flock_release(fhandle_2);
+  flock_result = BLI_flock_release(fdescriptor_2);
   ASSERT_TRUE(flock_result);
 
-  close(fhandle_1);
-  close(fhandle_2);
+  close(fdescriptor_1);
+  close(fdescriptor_2);
 
   /* Acquiring lock on closed/non-existent file handles should not be possible. */
-  flock_result = BLI_flock_shared(fhandle_1, false);
+  flock_result = BLI_flock_shared(fdescriptor_1, false);
   ASSERT_FALSE(flock_result);
-  flock_result = BLI_flock_shared(fhandle_2, false);
+  flock_result = BLI_flock_shared(fdescriptor_2, false);
   ASSERT_FALSE(flock_result);
   flock_result = BLI_flock_shared(-1, false);
   ASSERT_FALSE(flock_result);



More information about the Bf-blender-cvs mailing list