[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] memset_explicit: port to older MS-Windows
From: |
Bruno Haible |
Subject: |
Re: [PATCH] memset_explicit: port to older MS-Windows |
Date: |
Mon, 26 Dec 2022 17:50:09 +0100 |
Paul Eggert wrote:
> * lib/memset_explicit.c (memset_explicit):
> Remove special case for C==0 and MS-Windows. The code isn’t
> needed for correctness
> ...
> /* Set S's bytes to C, where S has LEN bytes. The compiler will not
> optimize effects away, even if S is dead after the call. */
> void *
> memset_explicit (void *s, int c, size_t len)
> {
> -#if defined _WIN32 && !defined __CYGWIN__
> - if (!c)
> - return SecureZeroMemory (s, len);
> -#endif
> #if HAVE_EXPLICIT_MEMSET
> return explicit_memset (s, c, len);
> #elif HAVE_MEMSET_S
For compilers other than GCC and clang, we are betting on a trick with
'volatile'. I'm not sure it won't break in the future. But at least for
now, with MSVC, the unit tests still pass.
Bruno