From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 79B3C3858C54 for ; Mon, 6 Feb 2023 22:25:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 79B3C3858C54 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 316MDNNG003347 for ; Mon, 6 Feb 2023 22:25:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=XghC+ICze9Rh/Ps4n2U1LiLuh5D0wEU8AlykMLXyKa8=; b=pFj+POETNWez8j2dwFcAdLP/SzqCQAQDnYKS4qjfPTjDnCOh00pUh/R6QTZMHpv3yM3t NYYwM+oKILtorcM3YtvojmlNWehn8wTboU5RnSKfeKa0+U9i/JiWf3SjZUaMu5OV84ST KhYeFiu5BlZRyg2HQyoKVYCjLl40bk556juVs+Yk5vAW15cUioEHKeTIPkgXOg1uOHcU ZqndTvylSpFaqwS1Eeq035T/mWYeGb+1v3itEFtaH7Go+KLirUnGsT6Lw5i/Rq+28VKj eNVfx/yf/CUC9mSOadfNYPOEuHb74z8dlAXhSwWbs2hzBBk9+RzYh4f2/lEN4Fzat4o5 nA== Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3nka5b88dw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 06 Feb 2023 22:25:28 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 316HRftJ023743 for ; Mon, 6 Feb 2023 22:25:26 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma04ams.nl.ibm.com (PPS) with ESMTPS id 3nhf06tvf2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 06 Feb 2023 22:25:26 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 316MPNdP44040612 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 6 Feb 2023 22:25:23 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 11A1520075; Mon, 6 Feb 2023 22:25:23 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C24BD20074; Mon, 6 Feb 2023 22:25:22 +0000 (GMT) Received: from heavy.lan (unknown [9.179.9.231]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 6 Feb 2023 22:25:22 +0000 (GMT) From: Ilya Leoshkevich To: elfutils-devel@sourceware.org Cc: Ilya Leoshkevich Subject: [PATCH RFC 02/11] libasm: Fix xdefault_pattern initialization Date: Mon, 6 Feb 2023 23:25:04 +0100 Message-Id: <20230206222513.1773039-3-iii@linux.ibm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230206222513.1773039-1-iii@linux.ibm.com> References: <20230206222513.1773039-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: FMJZebUZ9qeuD8m4McTfNXuc4qadr40J X-Proofpoint-ORIG-GUID: FMJZebUZ9qeuD8m4McTfNXuc4qadr40J X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-06_07,2023-02-06_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 phishscore=0 suspectscore=0 mlxscore=0 bulkscore=0 mlxlogscore=930 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302060191 X-Spam-Status: No, score=-11.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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: clang complains: asm_newscn.c:48:22: error: field 'pattern' with variable sized type 'struct FillPattern' not at the end of a struct or class is a GNU extension [-Werror,-Wgnu-variable-sized-type-not-at-end] struct FillPattern pattern; ^ Fix by using a union instead. Define the second union member to be a char array 1 byte larger than struct FillPattern. This should be legal according to 6.7.9: If an object that has static or thread storage duration is not initialized explicitly, then ... if it is a union, the first named member is initialized (recursively) according to these rules, and any padding is initialized to zero bits. Signed-off-by: Ilya Leoshkevich --- libasm/asm_newscn.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libasm/asm_newscn.c b/libasm/asm_newscn.c index d258d969..32a3b598 100644 --- a/libasm/asm_newscn.c +++ b/libasm/asm_newscn.c @@ -43,17 +43,16 @@ /* Memory for the default pattern. The type uses a flexible array which does work well with a static initializer. So we play some dirty tricks here. */ -static const struct +static const union { struct FillPattern pattern; - char zero; + char zeroes[sizeof(struct FillPattern) + 1]; } xdefault_pattern = { .pattern = { .len = 1 }, - .zero = '\0' }; const struct FillPattern *__libasm_default_pattern = &xdefault_pattern.pattern; -- 2.39.1