From patchwork Wed Sep 21 13:51:04 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: 57849 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 877163857B95 for ; Wed, 21 Sep 2022 13:53:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 877163857B95 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663768384; bh=BgR3rJaxPhfe5gwTkJog0BtyctPMkktmC2RECKAiDjQ=; 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=lUg0RQ3f8WgB2ovgkyLIVcnGuxqOHSOAiAWcu12n+Yn37Ai8A2vZZAGjoEXSIdRvZ CVmffqSCJ2Mqs6vNDhfyh426XOD/hvEex28GvqnmQGlHtVuOXL7RwsZdlwHftmfR6N nzIHPpY3wwhKjGJzoIVxtCEUBksKPWHF03/SCrZk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org 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 Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-11e9a7135easo9115973fac.6 for ; Wed, 21 Sep 2022 06:51:22 -0700 (PDT) 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) 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 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 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" 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. Reviewed-by: Carlos O'Donell Tested-by: Carlos O'Donell --- 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]);