2021-07-17 Paul Eggert <eggert@cs.ucla.edu>
+ explicit_bzero-tests: pacify GCC
+ Redo to pacify -Wmaybe-uninitialized with
+ GCC 11.1.1 20210531 (Red Hat 11.1.1-3) x86-64.
+ * tests/test-explicit_bzero.c (stackbuf): New static pointer.
+ (do_secret_stuff): Use it.
+ (test_stack): Set it to a local buffer.
+
posixtm: pacify latest GCC
Also, modernize while I’m at it.
* lib/posixtm.c: Include c-ctype.h, idx.h, intprops.h, verify.h
/* There are two passes:
1. Put a secret in memory and invoke explicit_bzero on it.
2. Verify that the memory has been erased.
- Implement them in the same function, so that they access the same memory
- range on the stack. */
+ Access the memory via a volatile pointer, so the compiler
+ does not assume the pointer's value and optimize away accesses. */
+static char *volatile stackbuf;
static int _GL_ATTRIBUTE_NOINLINE
do_secret_stuff (volatile int pass)
{
- char stackbuf[SECRET_SIZE];
if (pass == 1)
{
memcpy (stackbuf, SECRET, SECRET_SIZE);
static void
test_stack (void)
{
+ char stack_buffer[SECRET_SIZE];
+ stackbuf = stack_buffer;
int count = 0;
int repeat;