Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4051216pxb; Mon, 27 Sep 2021 08:23:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGpEB6MUHepqPmCxnWWakn92rNl42QYGH8QnWinvo5p34fu7vff30JThMw8C0QG65S3Mw/ X-Received: by 2002:a17:90a:5583:: with SMTP id c3mr522544pji.133.1632756213089; Mon, 27 Sep 2021 08:23:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632756213; cv=none; d=google.com; s=arc-20160816; b=fV2PVdDaWqs1R8ZsI7lEaV++377WoLiSR3pbuMM83DPka3TdMfMYi/NMnb4zwUP18J JgTL7pJdZQux4iC/iOvsh0LgXPmHcejTg3Ovb9Y6BbYA3MZxu4kjVTNaOAtfzjMOFT2e luGWrLcbRvE4y5Qov29mGRELRXf6VwKtT1IBCjSaNaePukffio6EADw5D01rpUg6vN0H J1DPAEPf0kqBq7006TLJ0IEZXwewikkehq9wKCW+0dKXrBk9vRnpz15QE7rI22/U+QZ6 zXCKYBFQv67PJBFUjvBDqzNcFtKToWGCEV5O4T/bG0YF30448IDdVhonFWQwEv+8QjBJ 8tlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:dkim-signature; bh=a4iblHNSEN6nOTJcv0+SPsKJBZ5FtbT2h5gqOOcNel0=; b=dGgDSeFF/XkCLWG/5o+RetIEOyRVY2FccmATPqWT9UqaBP5EDCW0Q5HWa9oFyfI9KQ mT9A3UHcoSct7vKHgdC1QXS+RJ9f3mYiEtQuxXz0sxnJQaGW8ZtxZejt/AW19oqujv8u PlCBbWbhbE3UlrXy8uthqziDfuYTCLyPQ5NH7S4sN+wAAkDz1KRC8thf50nPDpS7zeB4 iOsm1CYSYjvOE3EtGZJBX6rVtc1uYoQKN8rvS1vLzvihuu4OgR6YWJCnhS3779RK82v6 wnU9dBfXVhcPDuZZZ/lvxP+I/CM6/sPF6WZPP+fnpZrHl6Pg9m8x3dOf11RUUrqT5iuX H00A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=dmykWltv; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f12si21382682pln.456.2021.09.27.08.23.17; Mon, 27 Sep 2021 08:23:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=dmykWltv; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235071AbhI0PYC (ORCPT + 99 others); Mon, 27 Sep 2021 11:24:02 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:58270 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235090AbhI0PYB (ORCPT ); Mon, 27 Sep 2021 11:24:01 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id C92BB20159; Mon, 27 Sep 2021 15:22:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1632756142; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a4iblHNSEN6nOTJcv0+SPsKJBZ5FtbT2h5gqOOcNel0=; b=dmykWltvhIbIbyExkYeFeiUzrmq1DkfzFC0iupBm64pkL4WF8gf3SrAJtKtH7IXqnbztuL ssi2QBMeZ+TsdmeTkLcme4SpEl3kIjyPQxnxzJ8lTadxk73iVDwtXNPu2vl4iVL+twTGuU r+F6IzGnulwYrFLlNyoS9lyr5cRiO7M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1632756142; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a4iblHNSEN6nOTJcv0+SPsKJBZ5FtbT2h5gqOOcNel0=; b=UKxKAEoG4mpXt6YVQcqQLdn403h6omq5cgMj6Ny8SSU0Z6zP9UQHAHJktxrIB4l9RdgkeQ z4v/VFjbv7imbODQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E9FD7132D4; Mon, 27 Sep 2021 15:22:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id GIN6K6zhUWHpWAAAMHmgww (envelope-from ); Mon, 27 Sep 2021 15:22:20 +0000 Subject: Re: [PATCH] [RFC] bcache: hide variable-sized types from uapi headers To: Arnd Bergmann , Kent Overstreet Cc: Arnd Bergmann , Jens Axboe , linux-kernel@vger.kernel.org References: <20210927124331.1487876-1-arnd@kernel.org> From: Coly Li Message-ID: <7d90109f-7e25-ae2d-0dc9-80618593a3e4@suse.de> Date: Mon, 27 Sep 2021 23:22:16 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20210927124331.1487876-1-arnd@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/27/21 8:43 PM, Arnd Bergmann wrote: > From: Arnd Bergmann > > The headers_check helper complains about a GNU extension in > one of the exported headers: > > linux/bcache.h:354:2: warning: field '' with variable sized type 'union jset::(anonymous at ./usr/include/linux/bcache.h:354:2)' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end] > BKEY_PADDED(uuid_bucket); > ^ > linux/bcache.h:134:2: note: expanded from macro 'BKEY_PADDED' > union { struct bkey key; __u64 key ## _pad[BKEY_PAD]; } > ^ > > We could either try to shut up the warning or remove those parts from > the user-visible section of this header. This does the second, > under the assumption that they are not actually used. Hi Arnd, Yes, the variable part is necessary for bcache-tools to understand the on-disk format. If other program wants to understand the bcache on-disk format, IMHO such variable part might be necessary too. BKEY_PADDED() is a special usage of the variable size array. In this case it indicates uuid_bucket is 8 x u64, and 6 x u64 space for ptr[]. And the bcache code make sure no more than 6 pointers are used for uuid_bucket. I know BKEY_PADDED() works, but I don't know how to simply remove the -Wgnu-variable-sized-type-not-at-end warning. Maybe Kent may offer some hint ? Coly Li > > Fixes: 81ab4190ac17 ("bcache: Pull on disk data structures out into a separate header") > Signed-off-by: Arnd Bergmann > --- > Coli, Kent: can you check to see if the hidden parts are used anywhere > from user space, and apply the patch if not? > > Any other ideas for addressing this warning? > --- > include/uapi/linux/bcache.h | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/include/uapi/linux/bcache.h b/include/uapi/linux/bcache.h > index cf7399f03b71..e3e4889aa53e 100644 > --- a/include/uapi/linux/bcache.h > +++ b/include/uapi/linux/bcache.h > @@ -23,9 +23,13 @@ static inline void SET_##name(type *k, __u64 v) \ > struct bkey { > __u64 high; > __u64 low; > +#ifdef __KERNEL__ > + /* gcc extension not meant for user space */ > __u64 ptr[]; > +#endif > }; > > +#ifdef __KERNEL__ > #define KEY_FIELD(name, field, offset, size) \ > BITMASK(name, struct bkey, field, offset, size) > > @@ -127,6 +131,8 @@ static inline struct bkey *bkey_idx(const struct bkey *k, unsigned int nr_keys) > > return (struct bkey *) (d + nr_keys); > } > +#endif > + > /* Enough for a key with 6 pointers */ > #define BKEY_PAD 8 >