Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3502423pxb; Mon, 18 Oct 2021 17:03:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwc1huO0NRZFlpv5AW1EdshGmzAG+Gd3GFgY0jiMW6da4CKOrj9UbMvsXqdYFJj5WCjDY9O X-Received: by 2002:a05:6402:2808:: with SMTP id h8mr49372114ede.394.1634601834491; Mon, 18 Oct 2021 17:03:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634601834; cv=none; d=google.com; s=arc-20160816; b=m7+MhgkXeKYRseK1yYVmiygy74pT2rgv8uhwnlBmTccz7GQiDS8hFRXOE9i9o94bXl HmemrJ8dfQj2kJzTKWQdychpWpj2MOdskgEnsyvadm88hnnjAgFDq/2g9fmXPkI2Wrvw u/0hVMMmJ56Tf4FHJQ3SGejQMgyAfbFagkM1RME1mrLMLgxAkaoezpudLI2CbaeBN71C MZN4dfuZ1bwfCHLqrxPsbuk03Q8xq6T3XzatOqUMLkvG7xriSaYCxQrn4Y0nZ4Iztbgm RLFWSqzUAErHKzU/K/jjfHLxOGv96gZ55vwWbjAMeqtuR1EUIp1rBU1m9xqCTg9OHQDm djwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Pe0cpSR5O9k1o+3b/EEf1r0m8lT3CjFiaaD74FTI4eM=; b=Hv2AgqbbhtfYBXoVdweDzQ5z8mwzyl2bjGcTrW28Bmbo+Y4IobX75DWJ+W1plnQrKc PZZFI74MScWDth2ImGX6Vby8EuvzA1FRqwV9ZgEQlepsogyFnL5nJyHb4j9lzhTy3zJ/ mJuJpw1giNJ0cqk1kLq2ME4/wZVZBMdeKqhqQynpkRwywAfWB04Y0orurPoFoiVWDpHh 449IphVs8zp8I92HYYMGcQEVhA3i2/gVQJKKeL7IUhF1tYf9kYt9ZLu1Sf5BYgKCz5yp Nd4w3YMWRu5kbSysmQ8z2VsfDovxvde4b6r+TwBJdGEugFsjiiPpSo+gr1GnUGxS1qUw r8Iw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gb21si6350118ejc.395.2021.10.18.17.03.30; Mon, 18 Oct 2021 17:03:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233746AbhJSAFk (ORCPT + 99 others); Mon, 18 Oct 2021 20:05:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233786AbhJSAFk (ORCPT ); Mon, 18 Oct 2021 20:05:40 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DFA8C06161C; Mon, 18 Oct 2021 17:03:28 -0700 (PDT) Received: from localhost (unknown [IPv6:2804:14c:124:8a08::1007]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: krisman) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id B53AC1F4344D; Tue, 19 Oct 2021 01:03:26 +0100 (BST) From: Gabriel Krisman Bertazi To: jack@suse.com, amir73il@gmail.com Cc: djwong@kernel.org, tytso@mit.edu, david@fromorbit.com, dhowells@redhat.com, khazhy@google.com, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-api@vger.kernel.org, Gabriel Krisman Bertazi , kernel@collabora.com, Jan Kara Subject: [PATCH v8 23/32] fanotify: Wrap object_fh inline space in a creator macro Date: Mon, 18 Oct 2021 21:00:06 -0300 Message-Id: <20211019000015.1666608-24-krisman@collabora.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211019000015.1666608-1-krisman@collabora.com> References: <20211019000015.1666608-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org fanotify_error_event would duplicate this sequence of declarations that already exist elsewhere with a slight different size. Create a helper macro to avoid code duplication. Suggested-by: Jan Kara Signed-off-by: Gabriel Krisman Bertazi --- Among the suggestions, I think this is simpler because it avoids deep nesting the variable-sized attribute, which would have been hidden inside fee->ffe->object_fh.buf. It also avoids touching the allocators, which are nicely hidden inside helper KMEM_CACHE() macros that hides several parameters. --- fs/notify/fanotify/fanotify.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/fs/notify/fanotify/fanotify.h b/fs/notify/fanotify/fanotify.h index 2b032b79d5b0..a5e81d759f65 100644 --- a/fs/notify/fanotify/fanotify.h +++ b/fs/notify/fanotify/fanotify.h @@ -171,12 +171,19 @@ static inline void fanotify_init_event(struct fanotify_event *event, event->pid = NULL; } +#define FANOTIFY_INLINE_FH(size) \ +struct { \ + struct fanotify_fh object_fh; \ + /* Space for object_fh.buf[] - access with fanotify_fh_buf() */ \ + unsigned char _inline_fh_buf[(size)]; \ +} + struct fanotify_fid_event { struct fanotify_event fae; __kernel_fsid_t fsid; - struct fanotify_fh object_fh; - /* Reserve space in object_fh.buf[] - access with fanotify_fh_buf() */ - unsigned char _inline_fh_buf[FANOTIFY_INLINE_FH_LEN]; + + /* This must be the last element of the structure. */ + FANOTIFY_INLINE_FH(FANOTIFY_INLINE_FH_LEN); }; static inline struct fanotify_fid_event * -- 2.33.0