[3/5] linux: Replace zero-length array with flexible-array member on inotify struct
Message ID | 20230621213444.2017-2-cristian@rodriguez.im (mailing list archive) |
---|---|
State | New |
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 7659F3858023 for <patchwork@sourceware.org>; Wed, 21 Jun 2023 21:35:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7659F3858023 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1687383323; bh=WtzHLDj9eKPf+1+gnM7UwerxdYBE47/OVu8hBjXKccY=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=w4OAmLmcCeAkUkUdKT74LNRihkGP9a2moUmzc5tyWl7gBeFkLPbSDMy1xpgClZmyu qpscYmyAYZtP9hUVYXDaCUYCCmI0vzLQUXKoHKqYls7t6OjHLE+Q+HSeyFakLS1gNY kAwbW7BohcCFFvcz/J8+Z+Q4bC7JNMF0eXg6JcKU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by sourceware.org (Postfix) with ESMTPS id A6F2A3858D35 for <libc-alpha@sourceware.org>; Wed, 21 Jun 2023 21:35:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A6F2A3858D35 Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-39ea3943c07so474541b6e.1 for <libc-alpha@sourceware.org>; Wed, 21 Jun 2023 14:35:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687383300; x=1689975300; 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:message-id:reply-to; bh=WtzHLDj9eKPf+1+gnM7UwerxdYBE47/OVu8hBjXKccY=; b=GopiLquoyVezhy4quqcrOPE8N3I+wrpioMpK+RywBlBxsBQQWlGe1UAvvj52hVPLcW wLqyexwLiUe2oW6mS/lL96af3sk7WZlWQ6U8c2quokOdzezqC767hpELotPOV18HR7pf W3Obv3yMb4aco9haJs4ph+4MNozSK367iQSzry+RKXaTbgFNdrajIY1yJ4gjXwFcLiOZ NxKX20hv77laZnWmtpiZ+NMV3fLItEAQF/VkAim/i8zX8QwHbanzczK0MkopuIKH6kGC ElmwBWhIErzbjQKYBvmHz8QiWK/D6Xi4IIXlMvvdzk2cEQQm2n3xCvZzjuMgv4CTAufk k5Tw== X-Gm-Message-State: AC+VfDyeGPtOnTco4zfbMsVb/BwGxzYJ26QxJA0/UjOvyf2F5F+bVdd0 A1hd5wag+qsjVMDQnyHH9eZOD6dSmnTT4eIYQfc= X-Google-Smtp-Source: ACHHUZ5FUjbekIST3oap02x6W8DZ5TMmJ+qaSMZfM+fHrCJ6MntixXQu47FXc2OCN7zvwXuzJpR95Q== X-Received: by 2002:aca:dec6:0:b0:39c:8498:8159 with SMTP id v189-20020acadec6000000b0039c84988159mr12094624oig.1.1687383300648; Wed, 21 Jun 2023 14:35:00 -0700 (PDT) Received: from tumbleweedvm.. (181-162-15-197.baf.movistar.cl. [181.162.15.197]) by smtp.gmail.com with ESMTPSA id a8-20020a056808128800b0039ed142bf3asm2533825oiw.53.2023.06.21.14.34.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jun 2023 14:35:00 -0700 (PDT) To: libc-alpha@sourceware.org Cc: =?utf-8?q?Cristian_Rodr=C3=ADguez?= <cristian@rodriguez.im> Subject: [PATCH 3/5] linux: Replace zero-length array with flexible-array member on inotify struct Date: Wed, 21 Jun 2023 21:34:31 +0000 Message-ID: <20230621213444.2017-2-cristian@rodriguez.im> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230621213444.2017-1-cristian@rodriguez.im> References: <20230621213444.2017-1-cristian@rodriguez.im> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_WEB, SPF_HELO_NONE, SPF_NONE, 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: 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: =?utf-8?q?Cristian_Rodr=C3=ADguez_via_Libc-alpha?= <libc-alpha@sourceware.org> Reply-To: =?utf-8?q?Cristian_Rodr=C3=ADguez?= <cristian@rodriguez.im> Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" <libc-alpha-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
None
|
|
Commit Message
Cristian Rodríguez
June 21, 2023, 9:34 p.m. UTC
Current kernel versions require a compiler supporting -std=gnu11
and therefore supporting C99 flexible arrays. old versions require
a c89 compiler supporting this feature as an extension.
Signed-off-by: Cristian Rodríguez <cristian@rodriguez.im>
---
sysdeps/unix/sysv/linux/sys/inotify.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
This patch only syncs with the current kernel headers. On Wed, Jun 21, 2023 at 5:35 PM Cristian Rodríguez <cristian@rodriguez.im> wrote: > Current kernel versions require a compiler supporting -std=gnu11 > and therefore supporting C99 flexible arrays. old versions require > a c89 compiler supporting this feature as an extension. > > Signed-off-by: Cristian Rodríguez <cristian@rodriguez.im> > --- > sysdeps/unix/sysv/linux/sys/inotify.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/sysdeps/unix/sysv/linux/sys/inotify.h > b/sysdeps/unix/sysv/linux/sys/inotify.h > index 1e8e68cd97..535f57e27b 100644 > --- a/sysdeps/unix/sysv/linux/sys/inotify.h > +++ b/sysdeps/unix/sysv/linux/sys/inotify.h > @@ -31,7 +31,7 @@ struct inotify_event > uint32_t mask; /* Watch mask. */ > uint32_t cookie; /* Cookie to synchronize two events. */ > uint32_t len; /* Length (including NULs) of name. */ > - char name __flexarr; /* Name. */ > + char name[]; /* Name. */ > }; > > > -- > 2.41.0 > >
* Cristian Rodríguez via Libc-alpha: > Current kernel versions require a compiler supporting -std=gnu11 > and therefore supporting C99 flexible arrays. old versions require > a c89 compiler supporting this feature as an extension. Ugh, you are right: commit 94dfc73e7cf4a31da66b8843f0b9283ddd6b8381 Author: Gustavo A. R. Silva <gustavoars@kernel.org> Date: Wed Apr 6 19:36:51 2022 -0500 treewide: uapi: Replace zero-length arrays with flexible-array members It's specifically targeting UAPI headers, so it's not a (harmless) kernel-internal change. Do you know if anyone has looked at the compatibility impact of this change on C parsers? I'm not sure if we can do the same thing. In particular, if kernel headers are not C89-compatible, we may have to add kludges to our own headers that avoid including them in C89 mode. Thanks, Florian
On Thu, Jun 22, 2023 at 1:23 AM Florian Weimer <fweimer@redhat.com> wrote: > > Do you know if anyone has looked at the compatibility impact of this > change on C parsers? I'm not sure if we can do the same thing. In > particular, if kernel headers are not C89-compatible, we may have to add > kludges to our own headers that avoid including them in C89 mode. > > > On this case it is a linux feature, which has required this as an extension, probably since forever. I have only checked kernel 3.2 as the minimum and that version indeed uses c99 flex arrays at least *internally* (I have not checked all headers though)
diff --git a/sysdeps/unix/sysv/linux/sys/inotify.h b/sysdeps/unix/sysv/linux/sys/inotify.h index 1e8e68cd97..535f57e27b 100644 --- a/sysdeps/unix/sysv/linux/sys/inotify.h +++ b/sysdeps/unix/sysv/linux/sys/inotify.h @@ -31,7 +31,7 @@ struct inotify_event uint32_t mask; /* Watch mask. */ uint32_t cookie; /* Cookie to synchronize two events. */ uint32_t len; /* Length (including NULs) of name. */ - char name __flexarr; /* Name. */ + char name[]; /* Name. */ };