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

Robert Shearman rob at codeweavers.com
Wed May 9 17:31:08 CDT 2007


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(-)
-------------- next part --------------
diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index 5b4314f..3929c4b 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(vo
    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-patches mailing list