From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id A693C3857C7D; Wed, 5 Oct 2022 21:43:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A693C3857C7D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665006214; bh=jwjgrxPgTpNAXnXPTl72iIr5iRwqARLItt95gNph1Vg=; h=From:To:Subject:Date:From; b=N4+wj1JJnnQ7IanYCA3J91fIR1OEqWDPr8Gu6ZnB9092LRxpdgZoHdUAKqFQ4Q4uJ hEPX5glY36xX3U6eQVvps4m1LtQ1+j0oCvseVz/YgQx73Gn/HeCFC4VsQIoDsglxnw 4MbozwjdNH3FMKapG24tx6IGtVXvFzJC3qShdxmA= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc] posix: Suppress -Os warnings on fnmatch X-Act-Checkin: glibc X-Git-Author: Adhemerval Zanella Netto X-Git-Refname: refs/heads/master X-Git-Oldrev: c651f9da530320e9939e6cbad57b87695eeba41c X-Git-Newrev: 9ec1c8cd243e9d7d63e188620a7e70a3b69777e6 Message-Id: <20221005214334.A693C3857C7D@sourceware.org> Date: Wed, 5 Oct 2022 21:43:34 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=9ec1c8cd243e9d7d63e188620a7e70a3b69777e6 commit 9ec1c8cd243e9d7d63e188620a7e70a3b69777e6 Author: Adhemerval Zanella Netto Date: Wed Sep 21 10:51:04 2022 -0300 posix: Suppress -Os warnings on fnmatch 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 Diff: --- 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]);