From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ot1-x32a.google.com with SMTP id v15-20020a9d69cf000000b006709b5a534aso11418576oto.11 for ; Thu, 29 Dec 2022 04:58:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=j4GBWikrGhQajlpbg4R8r/HgOK4nzXa6a5mL6P+mTOI=; b=PfqNqlGVl4ZKBRtEN6OZJGRb78G8mWOl6/tZIij9psd3bfB6jD7JdWQp61MYnZxyFb jYMXlbcP9IkSyWmDSJho/WgqmIIyZGlbzp4pKhVzR50K5e6en0qx6spusue1J1dssvXL wk63LxbjsSO2r+Na7mZvmeeVF18f8w3VrK0/SwfquAfwfBoB1uHirbCjaT3sLiOzc0vw d8jQncgSbIRuboIHYV4QQmLah5/QWg2ENcGUdvh8bQsm98W177f88a5+o3U1COno1/Tb 7PeNbDpqfmai0Pyi6FoSyV7oSYtaPW66UF1W5vc1FipUxRbDupsPGWhlaoWLUZdh6Zns 7kSw== 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) From: Adhemerval Zanella 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 Content-Transfer-Encoding: 8bit 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 List-Id: 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; -- 2.34.1