[PATCH] msvcrt:msvcrt_get_flags: Fix bug 51846 - fopen(..., "wx")

Piotr Caban piotr.caban at gmail.com
Thu Oct 7 14:29:49 CDT 2021


On 10/7/21 9:21 PM, Ted Lyngmo wrote:
> Oh, ok, so something like this would make it available for the correct 
> Windows version?
> 
>       case 't':
>         *open_flags |=  _O_TEXT;
>         *open_flags &= ~_O_BINARY;
>         break;
> + #if _MSVCR_VER>=140
> +    case 'x':
> +      *open_flags |= _O_EXCL;
> +      break;
> + #endif
>       case 'D':
>         *open_flags |= _O_TEMPORARY;
>         break;
Yes, this will add support for 'x' mode only to ucrtbase.
>  > In order to test the changes with ucrtbase.dll the tests needs to
>  > go into dlls/ucrtbase/tests.
> 
> Ok, so should I move or copy this test case into 
> "dlls/ucrtbase/tests/printf.c" (which is the only test suite using fopen 
> in ucrtbase)?
dlls/ucrtbase/tests/misc.c looks like a better place for the test.

> static void test_fopen_exclusive( void )
> {
>      static const char * const testfile = "fileexcl.tst";
>      FILE *fp;
> 
>      fp = fopen(testfile, "wx");
>      ok(fp != NULL, "creating file with mode wx failed\n");
>      if(fp) fclose(fp);
There's no need for if(fp) check. You can just call fclose.
> 
>      fp = fopen(testfile, "wx");
>      ok(fp == NULL, "overwrote existing file with mode wx\n");
>      if(fp) fclose(fp);
There's no need to close fp (you have just tested that it's NULL).

> Should I guard that test case with #if _MSVCR_VER>=140 too?
No.

Please also change the commit message to something like:
ucrtbase: Add support for x mode in fopen.

Thanks,
Piotr



More information about the wine-devel mailing list