From mboxrd@z Thu Jan 1 00:00:00 1970 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 5EF72C433F5 for ; Mon, 28 Mar 2022 14:29:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243821AbiC1ObV (ORCPT ); Mon, 28 Mar 2022 10:31:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243820AbiC1ObU (ORCPT ); Mon, 28 Mar 2022 10:31:20 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 284C83D1F2; Mon, 28 Mar 2022 07:29:38 -0700 (PDT) Received: (Authenticated sender: clement.leger@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 3FCB9C000B; Mon, 28 Mar 2022 14:29:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1648477777; h=from:from:reply-to:subject:subject: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=p3NiSvA7v2bm7VGGIXeyl2Gyk0azu36w+C8pKD/U2OE=; b=T5nzcd6xh9Mdsyz9hOoK2u4VdMYUBeiCeXm0+J75YdZV1k0PkUOgXkT8giUfobn5vCLEAS OyqmlsHRZMFlHtkefQuOX9iGkoHKupBCR2yfwUcPh6AOs2BGRMpb8jPNt2PFkjsYp1kjC7 SOIsq4QkJcWyh1FNHbi5qiY2b4XJj5WhaNo6ExgbxxPZB97mGyyU5+77dXWWoYfJ0YrxSw JyhqPLRr0rbwv+pznjpVHbLqCSVZCkJshijEutC/0ksr0aCkXlOan7YUqmbcrE2fr84egg gkfbHGHdL1DmLcqmDCYUchm9KeRtg+x+Vdw16bzFqw4kpYE5MYbuork8dQgXRg== Date: Mon, 28 Mar 2022 16:28:12 +0200 From: =?UTF-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= To: Andy Shevchenko Cc: Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J . Wysocki" , Wolfram Sang , Peter Rosin , Rob Herring , Frank Rowand , Len Brown , Hans de Goede , Thomas Petazzoni , Alexandre Belloni , Allan Nielsen , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [PATCH v3 3/9] device property: add index argument to property_read_string_array() callback Message-ID: <20220328162812.16deac92@fixe.home> In-Reply-To: References: <20220325113148.588163-1-clement.leger@bootlin.com> <20220325113148.588163-4-clement.leger@bootlin.com> Organization: Bootlin X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Le Fri, 25 Mar 2022 16:30:45 +0200, Andy Shevchenko a =C3=A9crit : > > pointer =3D property_entry_find(props, propname, length); > > if (IS_ERR(pointer)) > > return PTR_ERR(pointer); =20 >=20 > > + if (index >=3D array_len) > > + return -ENODATA; =20 >=20 > I was about to ask if we can check this before the > property_entry_find() call, but realized that in such case it will > shadow possible errors due to wrong or absent property. I think you are actually right, the check can be done after property_entry_count_elems_of_size() since it already checks for the property to be present. I'll move that check. >=20 > ... >=20 > > - of_property_read_string_array(node, propname, val, > > nval) : > > + of_property_read_string_array_index(node, > > propname, val, nval, > > + index) : =20 >=20 > Dunno about the style there, but I think it can be one line. Seems like the complete file is strictly applying the 80 columns rules so I thought it was better to keep it like this. However, I think the ternary oeprator is not really readable with such split. --=20 Cl=C3=A9ment L=C3=A9ger, Embedded Linux and Kernel engineer at Bootlin https://bootlin.com