Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp297407pxb; Wed, 13 Apr 2022 00:52:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwW5zdoj/RpIJry54vFXEynYHEDV+S03z8BoCMvsuCzx6E7sURu6cvBOp4G1aaOorMsPlR0 X-Received: by 2002:a17:902:f683:b0:158:62d2:b6fb with SMTP id l3-20020a170902f68300b0015862d2b6fbmr14326040plg.30.1649836337711; Wed, 13 Apr 2022 00:52:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649836337; cv=none; d=google.com; s=arc-20160816; b=rA4+fAg9qij0ngdCzZ5I9Kj0OMY6xz+wY1v1hPk4BfQHE06KF4sr9wdRpOhWIgRsir mGgE3+bcwq/kjRUz+/a5Hge3xp9mH5T573OncjvSFoqafp7OJetJZk4hubyuh40pPHSC RP61A+ObcxuNj5mJQGpS3z8mbcKTPmcA4V1R3OJlOEIZXJq3LNJMMMfwh6yw3yvGDZcX PeSg47HRKJnFsL14YK4KpDmZIExn5yS1OlknuVjiiFHJdIrhPU+AwJwARS/JonXipXYU Vpu+T2Wub3mQXDbYITXJnUbRbWk7EPwKLoUhYeEmEFZvC+8xH485iFiJz8DOIW4gazs+ 80ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=SNrcfRE6HdOzXoCUILYeyPwHz9qMy++4j1/0BHKP8XY=; b=L5kIPGPSLqXkcQADGCKK7Uzg6PZs0najBym8PyawDU5A1ihSAIibMIgeC6KSUMQlai YCifxmErWJ3PcNGTvG95zlrKvt0150BArjcE6t1FYYSl7uWIxObxPWhB3O9/Pbur6ctR /wE3ws0gpu9YlLzvdSqJep8HEdeDPMchozrWcjZiPuW0J854Jei3Y51G0NKUDnfyIvez 7WNio4aIrmghAmqcm3zZcNl0iCsskMeuVt9bRuseyhog+uXv8lQ8m+gjkfTNazDsB1ba XPKeLUFJCTkr039NHm8wgqS+otKaW7ZQT1GaKQ8Gls8SmMta6tCitp7T9XdLZiJxa9GK WLQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=htaaJoxo; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w2-20020a17090ac98200b001bd14e01fb4si16904566pjt.162.2022.04.13.00.52.05; Wed, 13 Apr 2022 00:52:17 -0700 (PDT) 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=pass header.i=@gmail.com header.s=20210112 header.b=htaaJoxo; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232343AbiDMEw5 (ORCPT + 99 others); Wed, 13 Apr 2022 00:52:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbiDMEwz (ORCPT ); Wed, 13 Apr 2022 00:52:55 -0400 Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E8EC25C7A for ; Tue, 12 Apr 2022 21:50:36 -0700 (PDT) Received: by mail-qk1-x72a.google.com with SMTP id c1so548632qkf.13 for ; Tue, 12 Apr 2022 21:50:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=SNrcfRE6HdOzXoCUILYeyPwHz9qMy++4j1/0BHKP8XY=; b=htaaJoxot6ne7hAx0KnKCHkv0Tt49PTBd51CvrGc25fVyx5e+psJvSzVG5wQqAbor/ ozVzCwO0wYk6RXfyoQA/Mt5BFTE3nXmLA5elPH8HZknUI9qImFUSyEbEzV6swo1OZINo USA3K8Cp/U76hy4gG3zPDtKHqLQI9wTznS97kP9NDoaytbAxOg2jCitTSVGk80nVzA4n tik3993mg+mqHes2MLCyPLij0K+TL3XFMcS6o1adn09+HkIuGXeAIaPgwCvQ1UX5PcUo /Pcs9QrDZs+JXYGj/rFMdr95X/nhT+PirYHCajM07guCwC+OE+9oYow8UF7N7f5+6DEh 4diQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=SNrcfRE6HdOzXoCUILYeyPwHz9qMy++4j1/0BHKP8XY=; b=ajiweRgb5L6sUh70NGfKioulJs8vDa4ge4GO1vaMz+CcDUYg8iQVwj5Ky9G5bQpsVu SJK8zA5pJc1MtJLRqApzg22qoNAJ9mvmFKGL22AMYs+oUy/7CtAumMpNa5ji6BIKHOoK fiGs8W58DsfZhdxmL92oIn3qrzVDvH6zuovZahbNPLf/llfFwIb/W822TaMiiY7wsrf+ FKtkCT/VNY7qhRjuv0lSLe9WvkxAprfdQJH862di6V8S36+KZDpEhx+p8j4ZaUQPNpvG BCLZ1zLCd3Qa8H2nHvRp3Sj9dU1RkvgvvG9QmMyid0ZYNj8BeWgEW4Hw49xMEBtbtxPw jdhg== X-Gm-Message-State: AOAM533z99vLEUqIt/KW/hsoc2BBFALkd73pIjMjA+ZwA7MU0fO/4e05 2mqcNIZVFUb2Q0ULSNH+BG5NySlecRNfHD3L X-Received: by 2002:a37:9243:0:b0:699:9012:df43 with SMTP id u64-20020a379243000000b006999012df43mr5528039qkd.424.1649825435188; Tue, 12 Apr 2022 21:50:35 -0700 (PDT) Received: from jaehee-ThinkPad-X1-Extreme ([2607:fb90:50fb:900e:5e57:caff:f44b:33f4]) by smtp.gmail.com with ESMTPSA id p16-20020a05622a13d000b002e227782e9asm28287014qtk.14.2022.04.12.21.50.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 21:50:34 -0700 (PDT) Date: Wed, 13 Apr 2022 00:50:31 -0400 From: Jaehee Park To: Greg Kroah-Hartman Cc: Johan Hovold , Alex Elder , greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, outreachy@lists.linux.dev Subject: Re: [PATCH] staging: greybus: replace zero-element array with flexible-array Message-ID: <20220413045031.GC3357359@jaehee-ThinkPad-X1-Extreme> References: <20220411211411.GA2796005@jaehee-ThinkPad-X1-Extreme> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, 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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 12, 2022 at 06:57:11AM +0200, Greg Kroah-Hartman wrote: > On Tue, Apr 12, 2022 at 06:56:12AM +0200, Greg Kroah-Hartman wrote: > > On Mon, Apr 11, 2022 at 05:14:11PM -0400, Jaehee Park wrote: > > > Zero-length and one-element arrays are deprecated. Flexible-array > > > members should be used instead. Flexible-array members are > > > recommended because this is the way the kernel expects dynamically > > > sized trailing elements to be declared. > > > Refer to Documentation/process/deprecated.rst. > > > > > > Change the zero-length array, buf, in the struct > > > gb_usb_hub_control_response to a flexible array. And add wLength as a > > > member of the struct so that the struct is not a zero-sized struct. > > > > > > Issue found by flexible_array coccinelle script. > > > > > > Signed-off-by: Jaehee Park > > > --- > > > > > > I have a question for the authors: > > > I saw a fixme comment in the hub_control function in usb.c: > > > / FIXME: handle unspecified lengths / > > > > > > I was wondering why this comment was left there? > > > > > > In this patch, I'm using this struct: > > > > > > struct gb_usb_hub_control_response { > > > __le16 wLength; > > > u8 buf[]; > > > }; > > > > > > And instead of using response_size, I'm doing this: > > > > > > struct gb_usb_hub_control_response *response; > > > And using sizeof(*response) as the input to gb_operation_create. > > > > > > Would the flexible array address the handling of unspecified lengths > > > issue (in the fixme comment)? > > > > No, you can not change the format of the data on the bus without also > > changing the firmware in the device and usually the specification as > > well. > > > > > drivers/staging/greybus/usb.c | 7 +++---- > > > 1 file changed, 3 insertions(+), 4 deletions(-) > > > > > > diff --git a/drivers/staging/greybus/usb.c b/drivers/staging/greybus/usb.c > > > index 8e9d9d59a357..d0b2422401df 100644 > > > --- a/drivers/staging/greybus/usb.c > > > +++ b/drivers/staging/greybus/usb.c > > > @@ -27,7 +27,8 @@ struct gb_usb_hub_control_request { > > > }; > > > > > > struct gb_usb_hub_control_response { > > > - u8 buf[0]; > > > + __le16 wLength; > > > + u8 buf[]; > > > > What is wrong with buf[0] here? > > > > You can fix this in other ways if you really understand the difference > > between [0] and [] in C. Please look at many of the other conversions > > if you wish to do this. > > And I would not recommend this as an "outreachy introduction task" > unless you understand this. There are much easier first patch tasks you > can accomplish instead. > Hi Greg, I should've made this into a question for the maintainers instead of a patch. Sorry about that. Dan's and your comments are well noted. Thank you, Jaehee > good luck! > > greg k-h