From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: libc-alpha@sourceware.org
Subject: [PATCH 2/6] posix: Suppress -Os warnings on fnmatch
Date: Wed, 21 Sep 2022 10:51:04 -0300 [thread overview]
Message-ID: <20220921135108.3324737-3-adhemerval.zanella@linaro.org> (raw)
In-Reply-To: <20220921135108.3324737-1-adhemerval.zanella@linaro.org>
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
next prev parent reply other threads:[~2022-09-21 13:51 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-21 13:51 [PATCH 0/6] Fix -Os build Adhemerval Zanella
2022-09-21 13:51 ` [PATCH 1/6] locale: prevent maybe-uninitialized errors with -Os [BZ #19444] Adhemerval Zanella
2022-10-05 13:39 ` Carlos O'Donell
2022-09-21 13:51 ` Adhemerval Zanella [this message]
2022-10-05 13:47 ` [PATCH 2/6] posix: Suppress -Os warnings on fnmatch Carlos O'Donell
2022-10-05 20:01 ` Paul Eggert
2022-09-21 13:51 ` [PATCH 3/6] posix: Suppress -Os may be used uninitialized warnings on regexec Adhemerval Zanella
2022-10-05 13:49 ` Carlos O'Donell
2022-09-21 13:51 ` [PATCH 4/6] rt: Initialize mq_send input on tst-mqueue{5,6} Adhemerval Zanella
2022-10-05 13:51 ` Carlos O'Donell
2022-09-21 13:51 ` [PATCH 5/6] sunrpc: Suppress GCC -Os warning on user2netname Adhemerval Zanella
2022-10-05 13:52 ` Carlos O'Donell
2022-09-21 13:51 ` [PATCH 6/6] x86: Fix -Os build (BZ #29576) Adhemerval Zanella
2022-10-05 14:10 ` Carlos O'Donell
2022-10-05 17:21 ` H.J. Lu
2022-10-05 17:38 ` Adhemerval Zanella Netto
2022-10-05 18:06 ` H.J. Lu
2022-10-05 20:43 ` Adhemerval Zanella Netto
2022-10-05 21:27 ` H.J. Lu
2022-10-05 13:40 ` [PATCH 0/6] Fix -Os build Carlos O'Donell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220921135108.3324737-3-adhemerval.zanella@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).