Message ID | 20230503120210.564966-1-iii@linux.ibm.com |
---|---|
State | Unresolved |
Headers |
Return-Path: <binutils-bounces+ouuuleilei=gmail.com@sourceware.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1271275vqo; Wed, 3 May 2023 05:03:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4LujPacja7FcUJUJV9fa2ue4SKVkaAb6h/ewAtV1TeeDeKIRMTM0O4f4HRbiM63Tqs34ZA X-Received: by 2002:a17:907:9717:b0:94a:44ef:853d with SMTP id jg23-20020a170907971700b0094a44ef853dmr3088153ejc.68.1683115423331; Wed, 03 May 2023 05:03:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683115423; cv=none; d=google.com; s=arc-20160816; b=Y6TiJy5+hbkRb+j9xSUqWjE69Y2M00WbHenLv+EhflgmuDCUltT62hPAyl0NYm0ggE tq1GG8Osv+S9WwBIAzKwFTrhT7DKvfd6Nq+LaXpCyDVi7QUzG+OnOyWVHym/d44Lw+MJ jxgs1kotP7IYDubMG/Wg2DZBxH1ArkytORXldjg7LLU5sqUB1EiUzrwQIBsdsHLIj+j5 YyOV8Fw3R4o5jLGDNoFwfrL/+uVTtbUjRcfj1gCRPrQNc9kwsIV3PEFJbNAxlTUX7XBd O7dPD9sL44Bmzw4rwvf7e6L/F296b5D/u+Ggkj63o3/+n9/rVvWEw84ogROS1cOVBqEn atbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :content-transfer-encoding:message-id:date:subject:cc:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=MKvMtTsQbZhkcRcoBlCd5SoG8OQyVbSivEpZQExVgPk=; b=jcGh8eSVFEy0wCcNgYgyoFJbuvCC9mu//wJu/uqOgwJUdMV+QnlWutLZw6nqWQaqtz 3J7eSW0YL/jJFR+Iej+kZ8n/m8JryKb0o7sH5zHoLqK4mwXj7W0OONoBaynToTogb+Av tMX9KmtNeeCkIPXlHNFtXx7Bld8VryJih14u3dav6lk9zAvLOYDclPgZRtSEQdU6zTXG XrOoLpvaDmkCwVJVu0dcMCw8Ze668uKXPptAP5rCQtyu4zTIo0jYL2LnQ3ZrxJATNkvT LrxV6SY5BsUAePFaO5NzOIG0CLYCtLAN3PUffzAeqDIAAB5oHmgBA/eTSCTuIp5cowoH ZlQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=kt4KN5sP; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id h10-20020a17090619ca00b009655a78bf06si987184ejd.494.2023.05.03.05.03.43 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 May 2023 05:03:43 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=kt4KN5sP; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F2AE13857736 for <ouuuleilei@gmail.com>; Wed, 3 May 2023 12:03:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F2AE13857736 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1683115422; bh=MKvMtTsQbZhkcRcoBlCd5SoG8OQyVbSivEpZQExVgPk=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=kt4KN5sPEiU9+se7+X7dEcggZQWu2eYVkGU0zufTB3TZbLZNLfZJIyJcnGILUX+Ot SsX+LuqVBl7LdnwzALL3wscPrlTebet+xskLh9agS/8Ndnqx1tavlch8aLKxJuO3hW JEIs1uXBJjUyd1XRqnb74Aa1UkP0clv6DdEh3iI0= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id D7A8E3858D28 for <binutils@sourceware.org>; Wed, 3 May 2023 12:03:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D7A8E3858D28 Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 343C15oL008794; Wed, 3 May 2023 12:03:21 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qbq14gjg5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 03 May 2023 12:03:21 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 343Aa435007730; Wed, 3 May 2023 12:02:16 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma03fra.de.ibm.com (PPS) with ESMTPS id 3q8tv6st1r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 03 May 2023 12:02:16 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 343C2Drn4850240 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 3 May 2023 12:02:13 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B457B20043; Wed, 3 May 2023 12:02:13 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 52A3120040; Wed, 3 May 2023 12:02:13 +0000 (GMT) Received: from heavy.boeblingen.de.ibm.com (unknown [9.171.14.251]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 3 May 2023 12:02:13 +0000 (GMT) To: binutils@sourceware.org, "Jose E . Marchesi" <jose.marchesi@oracle.com>, Jan Beulich <jbeulich@suse.com> Cc: Ilya Leoshkevich <iii@linux.ibm.com> Subject: [PATCH v2] gas: fix building tc-bpf.c on s390x Date: Wed, 3 May 2023 14:02:10 +0200 Message-Id: <20230503120210.564966-1-iii@linux.ibm.com> X-Mailer: git-send-email 2.40.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: lwFvvXrPvxpkW3kGsQiHTqlhUivTs_1c X-Proofpoint-ORIG-GUID: lwFvvXrPvxpkW3kGsQiHTqlhUivTs_1c Content-Transfer-Encoding: 8bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-03_07,2023-05-03_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 mlxlogscore=999 bulkscore=0 priorityscore=1501 spamscore=0 malwarescore=0 mlxscore=0 adultscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2305030097 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list <binutils.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/binutils>, <mailto:binutils-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/binutils/> List-Post: <mailto:binutils@sourceware.org> List-Help: <mailto:binutils-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/binutils>, <mailto:binutils-request@sourceware.org?subject=subscribe> From: Ilya Leoshkevich via Binutils <binutils@sourceware.org> Reply-To: Ilya Leoshkevich <iii@linux.ibm.com> Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" <binutils-bounces+ouuuleilei=gmail.com@sourceware.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764874438465310336?= X-GMAIL-MSGID: =?utf-8?q?1764874438465310336?= |
Series |
[v2] gas: fix building tc-bpf.c on s390x
|
|
Checks
Context | Check | Description |
---|---|---|
snail/binutils-gdb-check | warning | Git am fail log |
Commit Message
Ilya Leoshkevich
May 3, 2023, 12:02 p.m. UTC
char is unsigned on s390x, so there are a lot of warnings like: gas/config/tc-bpf.c: In function 'get_token': gas/config/tc-bpf.c:900:14: error: comparison is always false due to limited range of data type [-Werror=type-limits] 900 | if (ch == EOF || len > MAX_TOKEN_SZ) | ^~ Change its type to int, like in the other similar code. There is also: gas/config/tc-bpf.c:735:30: error: 'bpf_endianness' may be used uninitialized in this function [-Werror=maybe-uninitialized] 735 | dst, be ? size[endianness - BPF_BE16] : size[endianness - BPF_LE16]); | ~~~~~~~~~~~^~~~~~~~~~ -Wmaybe-uninitialized doesn't seem to understand the FSM; just initialize bpf_endianness to silence it. Add an assertion to build_bpf_endianness() in order to catch potential bugs. --- v1: https://sourceware.org/pipermail/binutils/2023-April/127235.html v1 -> v2: Change signed char to int (Jan). Add an assertion. gas/config/tc-bpf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Comments
On 03.05.2023 14:02, Ilya Leoshkevich wrote: > char is unsigned on s390x, so there are a lot of warnings like: > > gas/config/tc-bpf.c: In function 'get_token': > gas/config/tc-bpf.c:900:14: error: comparison is always false due to limited range of data type [-Werror=type-limits] > 900 | if (ch == EOF || len > MAX_TOKEN_SZ) > | ^~ > > Change its type to int, like in the other similar code. > > There is also: > > gas/config/tc-bpf.c:735:30: error: 'bpf_endianness' may be used uninitialized in this function [-Werror=maybe-uninitialized] > 735 | dst, be ? size[endianness - BPF_BE16] : size[endianness - BPF_LE16]); > | ~~~~~~~~~~~^~~~~~~~~~ > > -Wmaybe-uninitialized doesn't seem to understand the FSM; just > initialize bpf_endianness to silence it. Add an assertion to > build_bpf_endianness() in order to catch potential bugs. > --- > > v1: https://sourceware.org/pipermail/binutils/2023-April/127235.html > v1 -> v2: Change signed char to int (Jan). > Add an assertion. Looks okay to me now, but will want Jose's approval. I'm a little puzzled, btw, why e.g. bpf_atomic_insn doesn't also expose a "maybe uninitialized" warning. Jan > --- a/gas/config/tc-bpf.c > +++ b/gas/config/tc-bpf.c > @@ -730,6 +730,8 @@ build_bpf_endianness (char *dst, enum bpf_token_type endianness) > || endianness == BPF_LE32 > || endianness == BPF_LE64) > be = 0; > + else > + gas_assert (endianness == BPF_BE16 || endianness == BPF_BE32 || endianness == BPF_BE64); > > bpf_insn = xasprintf ("%s %%%s,%s", be ? "endbe" : "endle", > dst, be ? size[endianness - BPF_BE16] : size[endianness - BPF_LE16]); > @@ -885,7 +887,7 @@ get_token (const char **insn, char *token, size_t *tlen) > } while (0) > > const char *str = *insn; > - char ch, ch2 = 0; > + int ch, ch2 = 0; > enum bpf_token_type ttype = BPF_UNKNOWN; > size_t len = 0; > const char *expr = NULL; > @@ -1362,7 +1364,7 @@ bpf_pseudoc_to_normal_syntax (const char *str, char **errmsg) > } while (0) > > enum bpf_token_type ttype; > - enum bpf_token_type bpf_endianness, > + enum bpf_token_type bpf_endianness = BPF_UNKNOWN, > bpf_atomic_insn; > enum bpf_token_type bpf_jmp_op = BPF_JEQ; /* Arbitrary. */ > enum bpf_token_type bpf_cast = BPF_CAST_U8; /* Arbitrary. */
> On 03.05.2023 14:02, Ilya Leoshkevich wrote: >> char is unsigned on s390x, so there are a lot of warnings like: >> >> gas/config/tc-bpf.c: In function 'get_token': >> gas/config/tc-bpf.c:900:14: error: comparison is always false due to limited range of data type [-Werror=type-limits] >> 900 | if (ch == EOF || len > MAX_TOKEN_SZ) >> | ^~ >> >> Change its type to int, like in the other similar code. >> >> There is also: >> >> gas/config/tc-bpf.c:735:30: error: 'bpf_endianness' may be used uninitialized in this function [-Werror=maybe-uninitialized] >> 735 | dst, be ? size[endianness - BPF_BE16] : size[endianness - BPF_LE16]); >> | ~~~~~~~~~~~^~~~~~~~~~ >> >> -Wmaybe-uninitialized doesn't seem to understand the FSM; just >> initialize bpf_endianness to silence it. Add an assertion to >> build_bpf_endianness() in order to catch potential bugs. >> --- >> >> v1: https://sourceware.org/pipermail/binutils/2023-April/127235.html >> v1 -> v2: Change signed char to int (Jan). >> Add an assertion. > > Looks okay to me now, but will want Jose's approval. I'm OK with the patch. Thanks Ilya for looking into this. I'm currently in a whirpool of work, but I plan to revisit both lexer and parser soon to simplify the implementation. > I'm a little puzzled, btw, why e.g. bpf_atomic_insn doesn't also expose > a "maybe uninitialized" warning. > > Jan > >> --- a/gas/config/tc-bpf.c >> +++ b/gas/config/tc-bpf.c >> @@ -730,6 +730,8 @@ build_bpf_endianness (char *dst, enum bpf_token_type endianness) >> || endianness == BPF_LE32 >> || endianness == BPF_LE64) >> be = 0; >> + else >> + gas_assert (endianness == BPF_BE16 || endianness == BPF_BE32 || endianness == BPF_BE64); >> >> bpf_insn = xasprintf ("%s %%%s,%s", be ? "endbe" : "endle", >> dst, be ? size[endianness - BPF_BE16] : size[endianness - BPF_LE16]); >> @@ -885,7 +887,7 @@ get_token (const char **insn, char *token, size_t *tlen) >> } while (0) >> >> const char *str = *insn; >> - char ch, ch2 = 0; >> + int ch, ch2 = 0; >> enum bpf_token_type ttype = BPF_UNKNOWN; >> size_t len = 0; >> const char *expr = NULL; >> @@ -1362,7 +1364,7 @@ bpf_pseudoc_to_normal_syntax (const char *str, char **errmsg) >> } while (0) >> >> enum bpf_token_type ttype; >> - enum bpf_token_type bpf_endianness, >> + enum bpf_token_type bpf_endianness = BPF_UNKNOWN, >> bpf_atomic_insn; >> enum bpf_token_type bpf_jmp_op = BPF_JEQ; /* Arbitrary. */ >> enum bpf_token_type bpf_cast = BPF_CAST_U8; /* Arbitrary. */
diff --git a/gas/config/tc-bpf.c b/gas/config/tc-bpf.c index 171fc682806..3b86f9c89cb 100644 --- a/gas/config/tc-bpf.c +++ b/gas/config/tc-bpf.c @@ -730,6 +730,8 @@ build_bpf_endianness (char *dst, enum bpf_token_type endianness) || endianness == BPF_LE32 || endianness == BPF_LE64) be = 0; + else + gas_assert (endianness == BPF_BE16 || endianness == BPF_BE32 || endianness == BPF_BE64); bpf_insn = xasprintf ("%s %%%s,%s", be ? "endbe" : "endle", dst, be ? size[endianness - BPF_BE16] : size[endianness - BPF_LE16]); @@ -885,7 +887,7 @@ get_token (const char **insn, char *token, size_t *tlen) } while (0) const char *str = *insn; - char ch, ch2 = 0; + int ch, ch2 = 0; enum bpf_token_type ttype = BPF_UNKNOWN; size_t len = 0; const char *expr = NULL; @@ -1362,7 +1364,7 @@ bpf_pseudoc_to_normal_syntax (const char *str, char **errmsg) } while (0) enum bpf_token_type ttype; - enum bpf_token_type bpf_endianness, + enum bpf_token_type bpf_endianness = BPF_UNKNOWN, bpf_atomic_insn; enum bpf_token_type bpf_jmp_op = BPF_JEQ; /* Arbitrary. */ enum bpf_token_type bpf_cast = BPF_CAST_U8; /* Arbitrary. */