From patchwork Mon Sep 26 21:43:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 12989442 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F8CBC07E9D for ; Mon, 26 Sep 2022 21:43:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229700AbiIZVnW (ORCPT ); Mon, 26 Sep 2022 17:43:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229585AbiIZVnV (ORCPT ); Mon, 26 Sep 2022 17:43:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA9EEA50E8; Mon, 26 Sep 2022 14:43:20 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 716A261470; Mon, 26 Sep 2022 21:43:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C117C433D6; Mon, 26 Sep 2022 21:43:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664228599; bh=yDsLJI6CYGz3X6/q58qiIO0l/wci+HoSYbTYvzlJ7BA=; h=Date:From:To:Cc:Subject:From; b=Wo4hh7jWXqgL9EBmMTYJ5FEhmLTj/hY41/Xu70oR7+DDRB0zDnfwgxYkOV5BXW19p 5Sj1sZwjjgbGx7peQ9WEr47yHEaTi7TRyG5qP7eyd2lojpxc1FpLi+QfyhWuJvh+or tutGhqFaMK6brnJYvXb5Yn1xmawieRLFlKag8CVeRdn9j+mulcIr6Cas+klbNJrlts XaQ38ABFoI+1gENdJ1OmHqPad7Mli6V1thW13RRK+Dn1K9Suzwq7p6y9ZWUiXbe92T auM7skXSdwTLUfmW7yM9lYqqb/t9GcFA2d5wtU0cpZfGgrqN58K9w1wBpekjeNLkWb 8inCKolEP48qw== Date: Mon, 26 Sep 2022 16:43:15 -0500 From: "Gustavo A. R. Silva" To: Coly Li , Kent Overstreet Cc: linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH][next] bcache: Replace zero-length arrays with DECLARE_FLEX_ARRAY() helper Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org Zero-length arrays are deprecated and we are moving towards adopting C99 flexible-array members, instead. So, replace zero-length arrays declarations in anonymous union with the new DECLARE_FLEX_ARRAY() helper macro. This helper allows for flexible-array members in unions. Link: https://github.com/KSPP/linux/issues/193 Link: https://github.com/KSPP/linux/issues/213 Link: https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html Signed-off-by: Gustavo A. R. Silva Reviewed-by: Kees Cook --- drivers/md/bcache/bcache_ondisk.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/md/bcache/bcache_ondisk.h b/drivers/md/bcache/bcache_ondisk.h index 97413586195b..d086a0ce4bc2 100644 --- a/drivers/md/bcache/bcache_ondisk.h +++ b/drivers/md/bcache/bcache_ondisk.h @@ -359,8 +359,8 @@ struct jset { __u64 prio_bucket[MAX_CACHES_PER_SET]; union { - struct bkey start[0]; - __u64 d[0]; + DECLARE_FLEX_ARRAY(struct bkey, start); + DECLARE_FLEX_ARRAY(__u64, d); }; }; @@ -424,8 +424,8 @@ struct bset { __u32 keys; union { - struct bkey start[0]; - __u64 d[0]; + DECLARE_FLEX_ARRAY(struct bkey, start); + DECLARE_FLEX_ARRAY(__u64, d); }; };