Rob Shearman : ole32: Move the logic in StgCreateDocfile for " if no share mode given then DENY_NONE is the default" to before the validateSTGM check.

Alexandre Julliard julliard at wine.codeweavers.com
Thu May 10 07:49:53 CDT 2007


Module: wine
Branch: master
Commit: b005e9ed0dfe9c4398c8ea609bc7083768bd0d45
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b005e9ed0dfe9c4398c8ea609bc7083768bd0d45

Author: Rob Shearman <rob at codeweavers.com>
Date:   Wed May  9 23:31:08 2007 +0100

ole32: Move the logic in StgCreateDocfile for "if no share mode given then DENY_NONE is the default" to before the validateSTGM check.

Add a test that shows this behaviour is correct.

Remove a test on the access mode that is redundant because it is already 
done in validateSTGM.

---

 dlls/ole32/storage32.c       |   12 ++++--------
 dlls/ole32/tests/storage32.c |    6 ++++++
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index 5b4314f..623516e 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -5680,6 +5680,10 @@ HRESULT WINAPI StgCreateDocfile(
   if (reserved != 0)
     return STG_E_INVALIDPARAMETER;
 
+  /* if no share mode given then DENY_NONE is the default */
+  if (STGM_SHARE_MODE(grfMode) == 0)
+      grfMode |= STGM_SHARE_DENY_NONE;
+
   /*
    * Validate the STGM flags
    */
@@ -5696,14 +5700,6 @@ HRESULT WINAPI StgCreateDocfile(
     goto end;
   }
 
-  /* if no share mode given then DENY_NONE is the default */     
-  if (STGM_SHARE_MODE(grfMode) == 0)
-    grfMode |= STGM_SHARE_DENY_NONE;
-
-  /* must have at least one access mode */
-  if (STGM_ACCESS_MODE(grfMode) == 0)
-    goto end;
-  
   /* in direct mode, can only use SHARE_EXCLUSIVE */
   if (!(grfMode & STGM_TRANSACTED) && (STGM_SHARE_MODE(grfMode) != STGM_SHARE_EXCLUSIVE))
     goto end;
diff --git a/dlls/ole32/tests/storage32.c b/dlls/ole32/tests/storage32.c
index d96a7ed..e6c3542 100644
--- a/dlls/ole32/tests/storage32.c
+++ b/dlls/ole32/tests/storage32.c
@@ -163,6 +163,12 @@ static void test_create_storage_modes(void)
    ok(r == 0, "storage not released\n");
    ok(DeleteFileW(filename), "failed to delete file\n");
 
+   r = StgCreateDocfile( filename, STGM_CREATE | STGM_READWRITE |STGM_TRANSACTED, 0, &stg);
+   ok(r==S_OK, "StgCreateDocfile failed\n");
+   r = IStorage_Release(stg);
+   ok(r == 0, "storage not released\n");
+   ok(DeleteFileW(filename), "failed to delete file\n");
+
    /* test the way excel uses StgCreateDocFile */
    r = StgCreateDocfile( filename, STGM_TRANSACTED|STGM_CREATE|STGM_SHARE_DENY_WRITE|STGM_READWRITE, 0, &stg);
    ok(r==S_OK, "StgCreateDocfile the excel way failed\n");




More information about the wine-cvs mailing list