Message ID | 20220921135108.3324737-2-adhemerval.zanella@linaro.org |
---|---|
State | Committed |
Commit | c651f9da530320e9939e6cbad57b87695eeba41c |
Headers |
Return-Path: <libc-alpha-bounces+patchwork=sourceware.org@sourceware.org> 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 792BE3857814 for <patchwork@sourceware.org>; Wed, 21 Sep 2022 13:51:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 792BE3857814 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663768308; bh=mzgatIN4FW972MjjKNR65A0ixgYtxq0aUlH24MTvBss=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=KI+/Uf9MOrw5rim5cxWueZysv90YGdITW/uULEjX9/lvhDVWmtt13uLpk4ruLCz8T NJKHQmDTFmh4DvP4MSu61LdWvieeCtzXO0Pr1eX90Tn3jVwSK2smTUwC+xnZD0+3vW E8Y0Tl3ng7uV8a0XyN1FnYSwDvUVB6+s+b9XqpFY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id 5DAD5385840F for <libc-alpha@sourceware.org>; Wed, 21 Sep 2022 13:51:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5DAD5385840F Received: by mail-ot1-x335.google.com with SMTP id x23-20020a056830409700b00655c6dace73so3960062ott.11 for <libc-alpha@sourceware.org>; Wed, 21 Sep 2022 06:51:21 -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:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=mzgatIN4FW972MjjKNR65A0ixgYtxq0aUlH24MTvBss=; b=ZEfcnPE4NBJayLJr5aCl2Lv81+tm7hHpfRKrRqLOm00FluLdaCAVSs6KkXNdAodMqv fnVW0JetctiZxtHLDm7GS7ezZPR9zOqDXCGfOH9+CPE4jDL1dxaQCVPx0oKJs9HvujEF wppPi4ZPvbXAup7pWe3XxnoQB9WFMWe+dZP/a3Q2HLC+t48AroELgiouyLIMhv93wAwP iQhEWSzR+ewJfXUXgLzGhxuYfFsoQvlDEd4TsT0AH/QvneJd76GgQFxSNdpqEsUTfe0n FBOTi7CwxxnTM9KBl7waxBJ15tVt9u65umKCL9MXTMOSCJFIhi9J38frOfC2isTC/Om3 XAsw== X-Gm-Message-State: ACrzQf0JXz6xUT9vdpu0yhZdlP9T+d1DOAwIgqY7T26PCj7RWrRS2zX2 Gdn4n+mXimlFIqt4kGdpE9VVJ2rGP4/5dTVg X-Google-Smtp-Source: AMsMyM73Zb69jKnh+9DqdwF5RXt4r9tvAo9hnciTUJ9ScjzyvXHmr10jJcnvT6hepDNJLZy88YdyDA== X-Received: by 2002:a9d:71cf:0:b0:655:b919:4f41 with SMTP id z15-20020a9d71cf000000b00655b9194f41mr12399326otj.358.1663768280568; Wed, 21 Sep 2022 06:51:20 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 06:51:20 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 1/6] locale: prevent maybe-uninitialized errors with -Os [BZ #19444] Date: Wed, 21 Sep 2022 10:51:03 -0300 Message-Id: <20220921135108.3324737-2-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.1 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 <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> From: Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org> Reply-To: Adhemerval Zanella <adhemerval.zanella@linaro.org> Cc: Martin Jansa <Martin.Jansa@gmail.com> Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" <libc-alpha-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
Fix -Os build
|
|
Commit Message
Adhemerval Zanella Netto
Sept. 21, 2022, 1:51 p.m. UTC
From: Martin Jansa <Martin.Jansa@gmail.com>
Fixes following error when building with -Os:
| In file included from strcoll_l.c:43:
| strcoll_l.c: In function '__strcoll_l':
| ../locale/weight.h:31:26: error: 'seq2.back_us' may be used
uninitialized in this function [-Werror=maybe-uninitialized]
| int_fast32_t i = table[*(*cpp)++];
| ^~~~~~~~~
| strcoll_l.c:304:18: note: 'seq2.back_us' was declared here
| coll_seq seq1, seq2;
| ^~~~
| In file included from strcoll_l.c:43:
| ../locale/weight.h:31:26: error: 'seq1.back_us' may be used
uninitialized in this function [-Werror=maybe-uninitialized]
| int_fast32_t i = table[*(*cpp)++];
| ^~~~~~~~~
| strcoll_l.c:304:12: note: 'seq1.back_us' was declared here
| coll_seq seq1, seq2;
| ^~~~
---
locale/weight.h | 7 +++++++
1 file changed, 7 insertions(+)
Comments
On Wed, Sep 21, 2022 at 10:51:03AM -0300, Adhemerval Zanella via Libc-alpha wrote: > From: Martin Jansa <Martin.Jansa@gmail.com> > > Fixes following error when building with -Os: > | In file included from strcoll_l.c:43: > | strcoll_l.c: In function '__strcoll_l': > | ../locale/weight.h:31:26: error: 'seq2.back_us' may be used > uninitialized in this function [-Werror=maybe-uninitialized] > | int_fast32_t i = table[*(*cpp)++]; > | ^~~~~~~~~ > | strcoll_l.c:304:18: note: 'seq2.back_us' was declared here > | coll_seq seq1, seq2; > | ^~~~ > | In file included from strcoll_l.c:43: > | ../locale/weight.h:31:26: error: 'seq1.back_us' may be used > uninitialized in this function [-Werror=maybe-uninitialized] > | int_fast32_t i = table[*(*cpp)++]; > | ^~~~~~~~~ > | strcoll_l.c:304:12: note: 'seq1.back_us' was declared here > | coll_seq seq1, seq2; > | ^~~~ LGTM. No regresions on x86_64. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com> > --- > locale/weight.h | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/locale/weight.h b/locale/weight.h > index 8be2d220f8..4a4d5aa6b2 100644 > --- a/locale/weight.h > +++ b/locale/weight.h > @@ -27,7 +27,14 @@ findidx (const int32_t *table, > const unsigned char *extra, > const unsigned char **cpp, size_t len) > { > + /* With GCC 8 when compiling with -Os the compiler warns that > + seq1.back_us and seq2.back_us might be used uninitialized. > + This uninitialized use is impossible for the same reason > + as described in comments in locale/weightwc.h. */ OK. Agreed. > + DIAG_PUSH_NEEDS_COMMENT; > + DIAG_IGNORE_Os_NEEDS_COMMENT (8, "-Wmaybe-uninitialized"); > int32_t i = table[*(*cpp)++]; > + DIAG_POP_NEEDS_COMMENT; > const unsigned char *cp; > const unsigned char *usrc; > > -- > 2.34.1 >
diff --git a/locale/weight.h b/locale/weight.h index 8be2d220f8..4a4d5aa6b2 100644 --- a/locale/weight.h +++ b/locale/weight.h @@ -27,7 +27,14 @@ findidx (const int32_t *table, const unsigned char *extra, const unsigned char **cpp, size_t len) { + /* With GCC 8 when compiling with -Os the compiler warns that + seq1.back_us and seq2.back_us might be used uninitialized. + This uninitialized use is impossible for the same reason + as described in comments in locale/weightwc.h. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_Os_NEEDS_COMMENT (8, "-Wmaybe-uninitialized"); int32_t i = table[*(*cpp)++]; + DIAG_POP_NEEDS_COMMENT; const unsigned char *cp; const unsigned char *usrc;