From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.4 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 8D1E71F5AE for ; Sun, 18 Jul 2021 04:56:44 +0000 (UTC) Received: from localhost ([::1]:34700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4yr5-0007Uj-AM for normalperson@yhbt.net; Sun, 18 Jul 2021 00:56:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54336) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4yr2-0007St-F9 for bug-gnulib@gnu.org; Sun, 18 Jul 2021 00:56:40 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:45306) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4yr0-0005nD-NB for bug-gnulib@gnu.org; Sun, 18 Jul 2021 00:56:40 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 77A5616011C for ; Sat, 17 Jul 2021 21:56:35 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 0d1nhDKWRIZi; Sat, 17 Jul 2021 21:56:34 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 4039016011A; Sat, 17 Jul 2021 21:56:34 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id W8_PKjJDFpbi; Sat, 17 Jul 2021 21:56:33 -0700 (PDT) Received: from penguin.cs.ucla.edu (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id BF436160115; Sat, 17 Jul 2021 21:56:33 -0700 (PDT) From: Paul Eggert To: bug-gnulib@gnu.org Subject: [PATCH 1/2] explicit_bzero-tests: pacify GCC Date: Sat, 17 Jul 2021 23:56:20 -0500 Message-Id: <20210718045621.1058412-1-eggert@cs.ucla.edu> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=131.179.128.68; envelope-from=eggert@cs.ucla.edu; helo=zimbra.cs.ucla.edu X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paul Eggert Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" 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. --- ChangeLog | 7 +++++++ tests/test-explicit_bzero.c | 8 +++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6ba44e7df..1caabff62 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2021-07-17 Paul Eggert =20 + 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=E2=80=99m at it. * lib/posixtm.c: Include c-ctype.h, idx.h, intprops.h, verify.h diff --git a/tests/test-explicit_bzero.c b/tests/test-explicit_bzero.c index cdb839245..c42aba93f 100644 --- a/tests/test-explicit_bzero.c +++ b/tests/test-explicit_bzero.c @@ -126,12 +126,12 @@ test_heap (void) /* 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 mem= ory - 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 =3D=3D 1) { memcpy (stackbuf, SECRET, SECRET_SIZE); @@ -147,6 +147,8 @@ do_secret_stuff (volatile int pass) static void test_stack (void) { + char stack_buffer[SECRET_SIZE]; + stackbuf =3D stack_buffer; int count =3D 0; int repeat; =20 --=20 2.31.1