From xen-devel Thu May 05 20:08:55 2022 From: Keith Packard Date: Thu, 05 May 2022 20:08:55 +0000 To: xen-devel Subject: Re: [PATCH 02/32] Introduce flexible array struct memcpy() helpers Message-Id: <87pmkrpwrs.fsf () keithp ! com> X-MARC-Message: https://marc.info/?l=xen-devel&m=165181423229494 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--=-=-=" --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Kees Cook writes: > I don't think I can do a declaration and an expression statement at the > same time with different scopes, but that would be kind of cool. We did > just move to c11 to gain the in-loop iterator declarations... Yeah, you'd end up creating a statement-level macro, and I think that would have poor syntax: mem_to_flex_dup(struct something *instance, rc, byte_array, count, GFP_KERNEL); if (rc) return rc; I bet you've already considered the simpler form: struct something *instance =3D mem_to_flex_dup(byte_array, count, G= FP_KERNEL); if (IS_ERR(instance)) return PTR_ERR(instance); This doesn't allow you to require a new name, so you effectively lose the check you're trying to insist upon. Some way to ask the compiler 'is this reference dead?' would be nice -- it knows if a valid pointer was passed to free, or if a variable has not been initialized, after all; we just need that exposed at the source level. =2D-=20 =2Dkeith --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEw4O3eCVWE9/bQJ2R2yIaaQAAABEFAmJ0LtcACgkQ2yIaaQAA ABHC0hAAr3uHP5hrK0TrjV0miTlsckS+Z8SZ2+xvHioDubRTMMdfP79BMu5ndZB4 QaRps+OPUgs6f0p8V2N5qN2jruvrUHrKXQyiIjdsRQmUp+3qyvpjuYrtNDeHHTD2 vfM0b48EgU8kkiVZH9ksTQ/b48dkf2r7GYLnmd3VO/LkFTymGVqvodKSYl/6dZOZ x7yTZYIRcbsjqPumSocldZhrYNuDwDWd3K2voU8pDD202q2xk3BpatYQOCnRYAzk Le8pCTMAkJmy3VcKuORvTyRaq0/AvjfjEVHVP9ucCk68zGEU1/egKnkv3iQ5b7UY RzyQTJSlFZQv2EomuxRRhmKQ/Ubqr//1Y5P8FLqQjJFdocf7x/wCkMdE5X/WZhIN tjA64pkC+b20mi6NQ5XouaUSTBKTnU44rsSCWsabc+fBx96Arj1tMJCrOoqYCWpy yg2mbeB3A55aDXAVSoC9vKoeleOJER70z7sOfycFpLPcO/XAoDOUOlfH46McYIIK 0xMfYCih17SZ/wY5s/NAamDnihpT26Zkm028+XJtQdxgyS3rSIjH+TxqQ3dpl+Tq q78xgiJ/GBR6QVyfdgbWEbXlJUOTIA1gtT+YvkC9NwhJszdT72psVFUXtZraEaRs +XEV7uZeDpyI0x1VGRqSDZgJtavhxjCqeR9SZ21Vch7I0NhT24I= =lS49 -----END PGP SIGNATURE----- --=-=-=--