Message ID | Y7T5MYfANf2xVsEx@qemulion |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4956688wrt; Tue, 3 Jan 2023 20:09:54 -0800 (PST) X-Google-Smtp-Source: AMrXdXt2EUuxjfDhaAIzzvVapHEIaudB8NDP0esr4TqTA8W5RZiI2IgEyDbiRRgZbpHxELwXJzaf X-Received: by 2002:a17:902:74cc:b0:189:dd9b:66c3 with SMTP id f12-20020a17090274cc00b00189dd9b66c3mr36670376plt.11.1672805394597; Tue, 03 Jan 2023 20:09:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672805394; cv=none; d=google.com; s=arc-20160816; b=ibFmL+PDRkIWWEK04tz5PeRCaBQaSsooZLzJbgN9pJQgtjXIut+3+G2fCbRD61Nc+r M03MbQGxV/PvyipFW5kfBnUAfVY0QL6suId9gC2aSgWp4e//1n/+k0ZAU7sukmv7r4vk ZkMSw8Unhx7mfXsZi3fonOY+2PMS+KWFFNSwLwjk66NijX8iaB8U/tuztg3znO6U8+nM 8BoHVfWdEqiwu4bH3yaUx+MYgVHw1FVs3JHeFJQymlIJOJhfDzycKQwF4ss31NLYwl2T RsGV20TbrrRy3i4IYVk8J1rwi9lpIkE1F+soZIrDS1YkRXHZ/6vpW4xuynfxXVK0bsTs qkaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=M1BHEx2GjIbTZVAoegRfa6dB6VgyNCajqTT3OgMjW3s=; b=uPrlbCB4tHUiIMlg7ecwA5s4VLmnWosjpZgSgh4Uj5NV3ix+BMblvsmfhUo/D2+uJb I/zrs8yxmpox2HtWghOs3yXve3O6m5/3M0BThjKxLeMlxoag61fx3iZATzVs3ACFmv0w HIfrP00TWPuxMDLCEtwwlBoTlqbenr1yFqMXnredK5ETIUg/hlSyhJkaqsDnM7XP4nSq ZZiKWXK7tV0vqPniOSzPkc1wL2xsDrGyluzazF4/y4NoMlyAGaQssL5dLx8Oj2u2OQMb wpozlGdiJ81k8om9zmvE2N2ZK9vbzT2SWqM9jQQrcmLFd+C1CBLDf3djeAHmh+bT/zJR RMWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=mhmZWRg7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s12-20020a63ff4c000000b00477b7f8a857si33134180pgk.203.2023.01.03.20.09.36; Tue, 03 Jan 2023 20:09:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=mhmZWRg7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234334AbjADD6C (ORCPT <rfc822;tmhikaru@gmail.com> + 99 others); Tue, 3 Jan 2023 22:58:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229473AbjADD57 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 3 Jan 2023 22:57:59 -0500 Received: from msg-1.mailo.com (msg-1.mailo.com [213.182.54.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79DE415725 for <linux-kernel@vger.kernel.org>; Tue, 3 Jan 2023 19:57:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1672804662; bh=g68WjsKLgm0BGTYxv3eXQb4GtGzcoRHUdOjEJjW3wxY=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:MIME-Version: Content-Type; b=mhmZWRg7q9RRn1gaJqCAY8aA9wv7j52nQH+wxTIS3sijktduushce/wrRS2V2pS8d fDt+TJ2PCt4MRbhjE3a5XsNSTWUPxkvi7xJ/v9vhUF+pCZHEklAiE/+uKf/TNTBaZg Gw5kxjUfHUQdURs8gEz0XTDKWko6/iP1MWGyfnZs= Received: by b-5.in.mailobj.net [192.168.90.15] with ESMTP via ip-206.mailobj.net [213.182.55.206] Wed, 4 Jan 2023 04:57:42 +0100 (CET) X-EA-Auth: X/DPdo8+pBhmvVri8YvZq0puHGhoKFIrcwsvZGLQWmFtOckUnZf5FYyOYxYO9PtuPY2gUj2VwJjiahd9mMMg+B4hq+B0mD0m Date: Wed, 4 Jan 2023 09:27:37 +0530 From: Deepak R Varma <drv@mailo.com> To: Johan Hovold <johan@kernel.org>, Alex Elder <elder@kernel.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Cc: Saurabh Singh Sengar <ssengar@microsoft.com>, Praveen Kumar <kumarpraveen@linux.microsoft.com>, Deepak R Varma <drv@mailo.com> Subject: [PATCH] staging: greybus: Replace zero-length array by DECLARE_FLEX_ARRAY() helper Message-ID: <Y7T5MYfANf2xVsEx@qemulion> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754063589753384108?= X-GMAIL-MSGID: =?utf-8?q?1754063589753384108?= |
Series |
staging: greybus: Replace zero-length array by DECLARE_FLEX_ARRAY() helper
|
|
Commit Message
Deepak R Varma
Jan. 4, 2023, 3:57 a.m. UTC
The code currently uses C90 standard extension based zero length array
struct which is now deprecated and the new C99 standard extension of
flexible array declarations are to be used instead. Also, the macro
DECLARE_FLEX_ARRAY() allows to use single flexible array member in a
structure. Refer to these links [1], [2] for details.
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://lkml.kernel.org/r/YxKY6O2hmdwNh8r8@work
Issue identified using Coccinelle flexible_array.cocci semantic patch.
Signed-off-by: Deepak R Varma <drv@mailo.com>
---
drivers/staging/greybus/usb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--
2.34.1
Comments
On 1/3/23 9:57 PM, Deepak R Varma wrote: > The code currently uses C90 standard extension based zero length array > struct which is now deprecated and the new C99 standard extension of > flexible array declarations are to be used instead. Also, the macro > DECLARE_FLEX_ARRAY() allows to use single flexible array member in a > structure. Refer to these links [1], [2] for details. Thank you for citing some references in your commit, it's a good and helpful practice. This might have been another helpful one: https://lore.kernel.org/lkml/20210827163015.3141722-2-keescook@chromium.org/ > [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html > [2] https://lkml.kernel.org/r/YxKY6O2hmdwNh8r8@work FYI, Linux mailing lists hosted by kernel.org are normally cited using "lore.kernel.org" now, e.g.: https://lore.kernel.org/lkml/YxKY6O2hmdwNh8r8@work Your patch is fine, this is just so you can consider this in the future. > Issue identified using Coccinelle flexible_array.cocci semantic patch. > > Signed-off-by: Deepak R Varma <drv@mailo.com> Looks good to me. Reviewed-by: Alex Elder <elder@linaro.org> > --- > drivers/staging/greybus/usb.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/greybus/usb.c b/drivers/staging/greybus/usb.c > index 8e9d9d59a357..b7badf87a3f0 100644 > --- a/drivers/staging/greybus/usb.c > +++ b/drivers/staging/greybus/usb.c > @@ -27,7 +27,7 @@ struct gb_usb_hub_control_request { > }; > > struct gb_usb_hub_control_response { > - u8 buf[0]; > + DECLARE_FLEX_ARRAY(u8, buf); > }; > > struct gb_usb_device { > -- > 2.34.1 > > >
On Wed, Jan 04, 2023 at 07:33:57AM -0600, Alex Elder wrote: > On 1/3/23 9:57 PM, Deepak R Varma wrote: > > The code currently uses C90 standard extension based zero length array > > struct which is now deprecated and the new C99 standard extension of > > flexible array declarations are to be used instead. Also, the macro > > DECLARE_FLEX_ARRAY() allows to use single flexible array member in a > > structure. Refer to these links [1], [2] for details. > > Thank you for citing some references in your commit, it's > a good and helpful practice. This might have been another > helpful one: > > https://lore.kernel.org/lkml/20210827163015.3141722-2-keescook@chromium.org/ Hello Alex, Thank you so much for the feedback. I will include the additional reference and send in a v2. > > > [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html > > [2] https://lkml.kernel.org/r/YxKY6O2hmdwNh8r8@work > > FYI, Linux mailing lists hosted by kernel.org are normally > cited using "lore.kernel.org" now, e.g.: > https://lore.kernel.org/lkml/YxKY6O2hmdwNh8r8@work > Your patch is fine, this is just so you can consider this > in the future. Sure, I will. This is very helpful to know. > > > Issue identified using Coccinelle flexible_array.cocci semantic patch. > > > > Signed-off-by: Deepak R Varma <drv@mailo.com> > > Looks good to me. Appreciate your time for the review and comments. I will include the reviewed by tag in my v2. Regards, ./drv > > Reviewed-by: Alex Elder <elder@linaro.org> > > > --- > > drivers/staging/greybus/usb.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/staging/greybus/usb.c b/drivers/staging/greybus/usb.c > > index 8e9d9d59a357..b7badf87a3f0 100644 > > --- a/drivers/staging/greybus/usb.c > > +++ b/drivers/staging/greybus/usb.c > > @@ -27,7 +27,7 @@ struct gb_usb_hub_control_request { > > }; > > > > struct gb_usb_hub_control_response { > > - u8 buf[0]; > > + DECLARE_FLEX_ARRAY(u8, buf); > > }; > > > > struct gb_usb_device { > > -- > > 2.34.1 > > > > > > >
diff --git a/drivers/staging/greybus/usb.c b/drivers/staging/greybus/usb.c index 8e9d9d59a357..b7badf87a3f0 100644 --- a/drivers/staging/greybus/usb.c +++ b/drivers/staging/greybus/usb.c @@ -27,7 +27,7 @@ struct gb_usb_hub_control_request { }; struct gb_usb_hub_control_response { - u8 buf[0]; + DECLARE_FLEX_ARRAY(u8, buf); }; struct gb_usb_device {