[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 4/6] Support clang for explicit_bzero
From: |
Bruno Haible |
Subject: |
Re: [PATCH 4/6] Support clang for explicit_bzero |
Date: |
Tue, 14 Apr 2020 00:44:14 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-174-generic; KDE/5.18.0; x86_64; ; ) |
> diff --git a/lib/explicit_bzero.c b/lib/explicit_bzero.c
> index 489732791..bb52d11de 100644
> --- a/lib/explicit_bzero.c
> +++ b/lib/explicit_bzero.c
> @@ -56,9 +56,13 @@ explicit_bzero (void *s, size_t len)
> (void) memset_s (s, len, '\0', len);
> #else
> memset (s, '\0', len);
> -# if defined __GNUC__ && !defined __clang__
> +#if defined __GNUC__
> +# if !defined __clang__
> /* Compiler barrier. */
> asm volatile ("" ::: "memory");
> +# else
> + /* https://bugs.llvm.org/show_bug.cgi?id=15495#c11 */
> + __asm__ volatile("" : : "g"(s) : "memory");
> # endif
> #endif
> }
It produces a compilation error:
gcc -DHAVE_CONFIG_H -I. -I../../gllib -I.. -DGNULIB_STRICT_CHECKING=1 -Wall
-g -O2 -MT explicit_bzero.o -MD -MP -MF .deps/explicit_bzero.Tpo -c -o
explicit_bzero.o ../../gllib/explicit_bzero.c
../../gllib/explicit_bzero.c:51:0: error: unterminated #else
#if defined _WIN32 && !defined __CYGWIN__
^
This is precisely why we use spaces between '#' and 'if'/'else', to
highlight the indentation level.
Also, the comment '/* Compiler barrier. */' applies also to the #else
branch, right? Then it should be place one line above.
Also, when you reference a web page, please add a short summary of what
is contained in it, or what you use from it. Our source code will still
be used and maintained 10 or 20 years from now, and web pages often
disappear or move after 1 or 5 years.
Bruno
- [V3][0/6] explicit_bzero, roucaries . bastien, 2020/04/12
- [PATCH 1/6] Fix test in case of canaries on heap buffer after free, roucaries . bastien, 2020/04/12
- [PATCH 2/6] Use memset_s if possible for explicit_bzero, roucaries . bastien, 2020/04/12
- [PATCH 3/6] Use SecureZeroMemory on windows for explicit_bzero, roucaries . bastien, 2020/04/12
- [PATCH 4/6] Support clang for explicit_bzero, roucaries . bastien, 2020/04/12
- Re: [PATCH 4/6] Support clang for explicit_bzero,
Bruno Haible <=
- [PATCH 5/6] Implement fallback for explicit_bzero using jump to volatile pointer, roucaries . bastien, 2020/04/12
- [PATCH 6/6] Improve styling in explicit_bzero, roucaries . bastien, 2020/04/12