From patchwork Wed Jan 11 21:27:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 62982 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6D3DD3857C51 for ; Wed, 11 Jan 2023 21:27:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6D3DD3857C51 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673472476; bh=uBRIqpWsi78Krkwr9uTrtJqyVft6XsjluL0OopVS3MY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=I2ZnABxJ5+JentzNAuXcWktSbo31gTebMGWmOPo4O75T1AN5vsDCFHLICti3vuzuk GIZGntuaqmuJ4oSBw14TMosWYhKh15JVenZ4T86Xhii+hh0TkRJ1uL29SD43aMGeAD udGNl/GU0YHpgj3Z/tHuMFgXTJ0lLf543eUC+RQk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oo1-xc34.google.com (mail-oo1-xc34.google.com [IPv6:2607:f8b0:4864:20::c34]) by sourceware.org (Postfix) with ESMTPS id 54F9638582A1 for ; Wed, 11 Jan 2023 21:27:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 54F9638582A1 Received: by mail-oo1-xc34.google.com with SMTP id 187-20020a4a09c4000000b004d8f3cb09f5so4365370ooa.6 for ; Wed, 11 Jan 2023 13:27:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uBRIqpWsi78Krkwr9uTrtJqyVft6XsjluL0OopVS3MY=; b=hR7ZO7HTmLwFmmNQGHTBne8boG1PK8IuMkgzFFqMYTf40PcXo4Ho8dD7VB7CCke/y5 vg/Xwy4nBTtwaW3R0OkI34qRJ8icWdfHBpOLyZ2dPyHmitGptKm9LKgI9FnhTsiCjZt6 eAkCW2NOISiQLPo3X6Yzp9GTtuzu8xueCE6VKlZsdX4FsRzC232nl83canxuL9D0UDgY QcbLDT007aREctM/8DXLoHdwsQ6mez9CMlf1SK/eiMcnIzQV6/BUKlWqighMEB7r9yxQ wtiJ2jt67BmBx3HLHdPVC7iVq6RJWY7Q2o7uCYTyKnEI/fn9DcOJwyIsWtVEwx5XsXSP Lwhg== X-Gm-Message-State: AFqh2kqvW8rCXwArgM2epwTQW6g9H8p4yTVpVycK6MQkGWMenekjmUkB 28MtetS3yxswSNkMqIwjO8gq4jQSIFmVfTdOiOw= X-Google-Smtp-Source: AMrXdXuMHPdzAdqshGphCW4g0jfa4RDfnykDTaqqyFf3zIfrI9QfPrX0cyRExtvRNLaDwtZI7M1/ig== X-Received: by 2002:a4a:5892:0:b0:4f2:6881:dbd5 with SMTP id f140-20020a4a5892000000b004f26881dbd5mr25000oob.6.1673472453088; Wed, 11 Jan 2023 13:27:33 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c0:a93a:a504:f3f6:dd7b:801]) by smtp.gmail.com with ESMTPSA id bc31-20020a056820169f00b0049f8b4b2095sm7584550oob.44.2023.01.11.13.27.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 13:27:32 -0800 (PST) To: libc-alpha@sourceware.org, Carlos O'Donell Subject: [PATCH v2] string: Suppress -Wmaybe-unitialized for wordcopy [BZ #19444] Date: Wed, 11 Jan 2023 18:27:29 -0300 Message-Id: <20230111212729.4109942-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" When compiling with GCC 6+ the sparc build warns that some variables might be used uninitialized. However it does not seem the fact, since the variables are really initialized (and also other targets that use the same code, like powerpc, do not warn about it). So suppress the warning for now. Changes from v1: * Update patch description and the explanation for the suppresion. Reviewed-by: Carlos O'Donell --- string/wordcopy.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/string/wordcopy.c b/string/wordcopy.c index ae5ccd793c..a8a40c9f01 100644 --- a/string/wordcopy.c +++ b/string/wordcopy.c @@ -19,7 +19,19 @@ /* BE VERY CAREFUL IF YOU CHANGE THIS CODE...! */ #include +#include +/* Compiling with -O1 might warn that 'a2' and 'a3' may be used + uninitialized. There are only two ways to arrive at labels 'do4', 'do3' + or 'do1', all of which use 'a2' or 'a3' in the MERGE macro: either from + the earlier switch case statement or via a loop iteration. In all cases + the switch statement or previous loop sets both 'a2' and 'a3'. + + Since the usage is within the MERGE macro we disable the + warning in the definition, but only in this file. */ +DIAG_PUSH_NEEDS_COMMENT; +DIAG_IGNORE_NEEDS_COMMENT (6, "-Wmaybe-uninitialized"); #include +DIAG_POP_NEEDS_COMMENT; /* _wordcopy_fwd_aligned -- Copy block beginning at SRCP to block beginning at DSTP with LEN `op_t' words (not LEN bytes!). @@ -94,7 +106,15 @@ WORDCOPY_FWD_ALIGNED (long int dstp, long int srcp, size_t len) { do8: a0 = ((op_t *) srcp)[0]; + /* Compiling with -O1 may warn that 'a1' may be used uninitialized. + There are only two ways to arrive at label 'do8' and they are via a + do-while loop iteration or directly via the earlier switch 'case 1:' + case. The switch case always sets 'a1' and all previous loop + iterations will also have set 'a1' before the use. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_NEEDS_COMMENT (6, "-Wmaybe-uninitialized"); ((op_t *) dstp)[0] = a1; + DIAG_POP_NEEDS_COMMENT; do7: a1 = ((op_t *) srcp)[1]; ((op_t *) dstp)[1] = a0; @@ -291,7 +311,11 @@ WORDCOPY_BWD_ALIGNED (long int dstp, long int srcp, size_t len) { do8: a0 = ((op_t *) srcp)[7]; + /* Check the comment on WORDCOPY_FWD_ALIGNED. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_NEEDS_COMMENT (6, "-Wmaybe-uninitialized"); ((op_t *) dstp)[7] = a1; + DIAG_POP_NEEDS_COMMENT; do7: a1 = ((op_t *) srcp)[6]; ((op_t *) dstp)[6] = a0;