From patchwork Thu Dec 29 12:58:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 62479 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 859D23858C30 for ; Thu, 29 Dec 2022 12:58:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 859D23858C30 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1672318715; bh=j4GBWikrGhQajlpbg4R8r/HgOK4nzXa6a5mL6P+mTOI=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=b7pQ5h2638/E7KUqf1QcdCL7y7uIllBVYiYarLm9Z2TsYyMWQXN6ZlmIcp7gxPNT1 fR7X0qaqKPdBc4n5uPmabHRirG9Q4JWXxffeYQ42bUtKDbH3v8kK5LUGEcQ2vy4YiR SEaQ/W7JJa+7rqp8ql3H4GzC6O40uuwLx5vbAdVM= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [IPv6:2607:f8b0:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id 56C26385842B for ; Thu, 29 Dec 2022 12:58:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 56C26385842B Received: by mail-ot1-x32a.google.com with SMTP id v15-20020a9d69cf000000b006709b5a534aso11418576oto.11 for ; Thu, 29 Dec 2022 04:58:13 -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:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=j4GBWikrGhQajlpbg4R8r/HgOK4nzXa6a5mL6P+mTOI=; b=UGGOMjZipfMU9+Q+IsALb3q8lxBtbMuV/PUuCg+h5mrnVr2sd+rp+G27YIbC/fqxMU jSWQvWEOvV3hN186yHr+uptuGGpau47y5ZiuByXkn5DwOiPy8HohWwNXOPTIe7VWHozS zyGo0DAiTeHp2Q7ovEQOMc7clAsGm6nOiPo76ASyFfj0ntQkOhPeqlKLuh3PzSFa658F Uw+hRnZNAIhEbHNmUNFrMRdT8vA9Wc1tehyVFDiR2POwUxgynLEv3o4RvSJuaBDC9RkQ EgPRdZlwJYQAHkWHrVtnMdRooPUQbOtE/XQFq8p86AjAHUKhHTGjLmGdfIZJg7eTPdm9 suNA== X-Gm-Message-State: AFqh2krGQKE9ptkoabSyl6C1BtutIJPOkAhHCTb2t0Q0vLmAtI/lHKUO /FLBIgdPpWTyYuG5PFFT1H32xxaoEfHuqA0k+Vg= X-Google-Smtp-Source: AMrXdXsGg+/K1ZaWLhsxT/fWQhhub2N07aS4g2x1pV+nmbOZaDsrR2esnf/9oHe8JXyW0PxiICK/hQ== X-Received: by 2002:a05:6830:124d:b0:66e:9510:1da5 with SMTP id s13-20020a056830124d00b0066e95101da5mr15784013otp.8.1672318691965; Thu, 29 Dec 2022 04:58:11 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c3:dd36:4794:7acd:a716:7b01]) by smtp.gmail.com with ESMTPSA id j2-20020a9d7d82000000b0066c34486aa7sm8977378otn.73.2022.12.29.04.58.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 04:58:11 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 3/4] string: Suppress -Wmaybe-unitialized for wordcopy [BZ #19444] Date: Thu, 29 Dec 2022 09:58:01 -0300 Message-Id: <20221229125802.2715435-4-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229125802.2715435-1-adhemerval.zanella@linaro.org> References: <20221229125802.2715435-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 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" With GCC 6+ when compiling with -O1 warns that some MERGE macro usage might be used uninitialized. The issue is calling the function with len equal to 0 is undefined since the first 'switch' will not trigger any case and then subsequent loop will potentially use uninitialized variables. However all usages on mem routines always called the function for sizes larger than OP_T_THRES. --- string/wordcopy.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/string/wordcopy.c b/string/wordcopy.c index d05718322c..3b6344115d 100644 --- a/string/wordcopy.c +++ b/string/wordcopy.c @@ -18,8 +18,19 @@ /* BE VERY CAREFUL IF YOU CHANGE THIS CODE...! */ +#include #include +#include +/* With GCC 6 when compiling with -O1 warns that some MERGE macro usage might + be used uninitialized. The issue is calling the function with len equal to + 0 is undefined since the first 'switch' will not trigger any case and then + subsequent loop will potentially use uninitialized variables. However all + usages on mem routines always called the function for sizes larger than + OP_T_THRES. */ +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 +105,11 @@ WORDCOPY_FWD_ALIGNED (long int dstp, long int srcp, size_t len) { do8: a0 = ((op_t *) srcp)[0]; + /* Check the comment on memcopy.h inclusion. */ + 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 +306,11 @@ WORDCOPY_BWD_ALIGNED (long int dstp, long int srcp, size_t len) { do8: a0 = ((op_t *) srcp)[7]; + /* Check the comment on memcopy.h inclusion. */ + 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;