From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 86B8E7803CD for ; Fri, 5 Apr 2024 07:29:36 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=/g2igty7l26PyJBy631Jg/HNmqHbNGryGWrQVK9adck=; c=relaxed/simple; d=groups.io; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding; s=20240206; t=1712302175; v=1; b=HtJz8tVp3E0JJysYKDOY6mP33MJX9mzNcgdOkCNYlEoBVorw8NXwmu9flDdV/xfrKTmEyNYr 9mZwo7ytJZnyMk7YJ/RCg6+iNASzh3HduUzORhCgY9w3EeL+pr3wE5H2W8yJa/of7BINGRaPQql FVMrmv3WzcpiYS9nrlEjhJ1c9uw94r4lYU4TmvZBjrB7Ksgi2my5g1Ezr/PmzgApF90dJ+dya7o HLJLLr9sXbTrvPy49plxUZP5N5c3qIZjSzm2vPbo40u1zC6yJRSMhtWPXfbeZSdN0JSwy5tztZq Q31wU9e0DPa7uyE8ixHgYnFLkaGsuY309tFGgZhuqgqmw== X-Received: by 127.0.0.2 with SMTP id G4PuYY7687511xsOnK5qoihm; Fri, 05 Apr 2024 00:29:35 -0700 X-Received: from mail-vs1-f48.google.com (mail-vs1-f48.google.com [209.85.217.48]) by mx.groups.io with SMTP id smtpd.web10.5728.1712302174266648905 for ; Fri, 05 Apr 2024 00:29:34 -0700 X-Received: by mail-vs1-f48.google.com with SMTP id ada2fe7eead31-479dc603962so141313137.2 for ; Fri, 05 Apr 2024 00:29:34 -0700 (PDT) X-Gm-Message-State: nD6EpKqAzPiGYYVHES8TuyDcx7686176AA= X-Google-Smtp-Source: AGHT+IGO0d2DAFRwuK1BXcok98icYYMexJQaRyJf5VCtYooCculvXOWuAebVl0v/ubdZkMg9Hyk5hiIit8wISHDPuUs= X-Received: by 2002:a05:6102:e0c:b0:476:f862:9a8b with SMTP id o12-20020a0561020e0c00b00476f8629a8bmr799573vst.25.1712302173065; Fri, 05 Apr 2024 00:29:33 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "Pedro Falcato" Date: Fri, 5 Apr 2024 08:29:21 +0100 Message-ID: Subject: Re: [edk2-devel] [Question] using Flexible Array Member in Structure. To: devel@edk2.groups.io, yeoreum.yun@arm.com Cc: "Kinney, Michael D" , nd , Sami Mujawar Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Fri, 05 Apr 2024 00:29:34 -0700 Resent-From: pedro.falcato@gmail.com Reply-To: devel@edk2.groups.io,pedro.falcato@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=HtJz8tVp; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On Fri, Apr 5, 2024 at 7:43=E2=80=AFAM levi.yun wrote= : > > Hi Michael! Thanks for answer. > > > Converting these to a flexible array member would not be > a backwards compatible change. > > That's the point. But at least when I see the compiler used in tool_def.t= xt, > there's no compiler which doesn't support to flexible array member. > > Do we still need to consider the case building edk2 with lower version of= comipler > which isn't manifested in tool_def.txt? That's not in question. What Mike is referring to here is, e.g: typedef struct { BOOLEAN Supported; UINT64 KeyCount; UINT64 CapabilityCount; EFI_BLOCK_IO_CRYPTO_CAPABILITY Capabilities [1]; } EFI_BLOCK_IO_CRYPTO_CAPABILITIES1; typedef struct { BOOLEAN Supported; UINT64 KeyCount; UINT64 CapabilityCount; EFI_BLOCK_IO_CRYPTO_CAPABILITY Capabilities []; } EFI_BLOCK_IO_CRYPTO_CAPABILITIES2; sizeof(EFI_BLOCK_IO_CRYPTO_CAPABILITIES1) !=3D sizeof(EFI_BLOCK_IO_CRYPTO_CAPABILITIES2), so it's an ABI break. And unfortunately many of these structs need to be ABI-stable (I took this one off the spec, you can find many such cases by ctrl+F'ing [1]). Basically, it comes down to the ABI. If it breaks the ABI, you need to figure out *if* it matters (e.g is it part of a protocol, or is it an internal lib struct that does not need to be stable, is it ABI to some external component). Also, worth noting that the "[1]" pattern is UB, and only works because GCC (et al) don't want to break a bunch of code. If you're defining a new struct, there's no reason to use [1] as a flexible array. --=20 Pedro -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117454): https://edk2.groups.io/g/devel/message/117454 Mute This Topic: https://groups.io/mt/105305209/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-