From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) by sourceware.org (Postfix) with ESMTPS id C919238582B2 for ; Wed, 21 Sep 2022 13:51:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C919238582B2 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-oa1-x31.google.com with SMTP id 586e51a60fabf-11e9a7135easo9115973fac.6 for ; Wed, 21 Sep 2022 06:51:22 -0700 (PDT) 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; bh=BgR3rJaxPhfe5gwTkJog0BtyctPMkktmC2RECKAiDjQ=; b=sAxB+yf2C0Qjh1W89LuZiOegchumEWjok74YryWmZJT1JAzlVYjR+3rTSULmp9GXOO oUwrEhMH2An9k7eOc+A8jIFdjaCmzqpAbcJ9uWuvcCQKrm6cxvbe3rE3FmJEtcruZk5J Nbd6wfpa4EfBLpwgi3hkjBLk2MDKlb1RBPFjGWY26E32oDvrNKgyQbssBmNvKin0wgTd ZVr7ka/On12u5GCXOhVGWPRBDCNp9aQDqpxjjify0JgFsDj+8fItwm9Kg04xL2Rj1Uav QvQkCIKtm7Ne/0GuII/PucvuANbqUSiM1HyhCrHYfclhAzH7nKMH9TKAT554Tq1joZkY nfYw== 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; bh=BgR3rJaxPhfe5gwTkJog0BtyctPMkktmC2RECKAiDjQ=; b=t+TYYVHXS1ffPxvLE9m1cE9lmHe6Wl/wDtE+qiKtfmkEFCZCrVWgyqZw9cXbW6cCwU 4b8PiScjEofoQLMzvuZELhUJzUYUZXb/lC7/1Iox5yChGNbbj5IOS2sp0OciGaVUKCP+ fNgdTZyse3AsU+70j1ayih03Xft6FD2FIiOod7e1K/S450AQqNbXtCFG+hPf6z3qQfHB jNDGdx4BCRFpotgx5lXnHF5AjqhHN6bvQiDiD31E/cxNc5upSv3rlI/vgnPQKQNRGDub 7CpwnjVzTYkznsIoB/4khr7Rb7RvPbWCRRbdwsy3WhJ3wfsjMKGRwfzAq7Q4NQKjMNZS nBZA== X-Gm-Message-State: ACrzQf2V7lZHRbVbdnbpndnLC6lPV2AtAw2Yy9JnrQb55ugWtaVrsm/d g23Y26MQ8DffhjJ49H/mskgsVj82FI179A/w X-Google-Smtp-Source: AMsMyM6OPxCClegYTcGUuToYjZOiZOYNGJXZ/0YFmy/+qhyGgg7yG+OaFMUdg+ZdHATrH3rLKCgw2w== X-Received: by 2002:a05:6870:562c:b0:127:bbe4:3f35 with SMTP id m44-20020a056870562c00b00127bbe43f35mr5244087oao.284.1663768281671; Wed, 21 Sep 2022 06:51:21 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:c266:dbbf:9e84:6582:5289]) by smtp.gmail.com with ESMTPSA id a38-20020a05687046a600b0010bf07976c9sm1669476oap.41.2022.09.21.06.51.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 06:51:21 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 2/6] posix: Suppress -Os warnings on fnmatch Date: Wed, 21 Sep 2022 10:51:04 -0300 Message-Id: <20220921135108.3324737-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921135108.3324737-1-adhemerval.zanella@linaro.org> References: <20220921135108.3324737-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.4 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: GCC with -Os issues some may uninitialized warnings on fnmatch code. All of the variables are already set when they are accessed on the loop prior. Checked on x86_64-linux-gnu and i686-linux-gnu. --- posix/fnmatch_loop.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/posix/fnmatch_loop.c b/posix/fnmatch_loop.c index 9445ed9c58..23eeffc79c 100644 --- a/posix/fnmatch_loop.c +++ b/posix/fnmatch_loop.c @@ -530,6 +530,14 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end, { /* Compare the byte sequence but only if this is not part of a range. */ + + /* The compiler might warn that idx may be + used uninitialized, however it will be + reached iff elem < table_size which means + that it was properly set in the loop + above. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_Os_NEEDS_COMMENT (8, "-Wmaybe-uninitialized"); if (! is_range # if WIDE_CHAR_VERSION @@ -542,11 +550,19 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end, n += c1 - 1; goto matched; } + DIAG_POP_NEEDS_COMMENT; /* Get the collation sequence value. */ is_seqval = true; # if WIDE_CHAR_VERSION + /* The compile might warn that wextra may be + used uninitialized and similar to 'idx' + above it will be properly set by the loop. + */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_Os_NEEDS_COMMENT (8, "-Wmaybe-uninitialized"); cold = wextra[1 + wextra[0]]; + DIAG_POP_NEEDS_COMMENT; # else idx += 1 + extra[idx]; /* Adjust for the alignment. */ @@ -723,9 +739,24 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end, /* Get the collation sequence value. */ is_seqval = true; # if WIDE_CHAR_VERSION + /* The compiler might warn that wextra may + be used uninitialized, however it will + be reached iff elem < table_size which + means that it was properly set in the + loop above. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_Os_NEEDS_COMMENT (8, "-Wmaybe-uninitialized"); cend = wextra[1 + wextra[0]]; + DIAG_POP_NEEDS_COMMENT; # else + /* The compile might warn that idx may + be used uninitialized and similar to + wextra above it will be properly set by + the loop. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_Os_NEEDS_COMMENT (8, "-Wmaybe-uninitialized"); idx += 1 + extra[idx]; + DIAG_POP_NEEDS_COMMENT; /* Adjust for the alignment. */ idx = (idx + 3) & ~3; cend = *((int32_t *) &extra[idx]); -- 2.34.1