Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp10776377rwp; Fri, 21 Jul 2023 05:01:14 -0700 (PDT) X-Google-Smtp-Source: APBJJlFptUkh1OeL21j+G8KI1pwbQ89GRld5Mppvep7akMvnMOg3Ykd9R1Mu/OoRKqeNQ+wDRYrJ X-Received: by 2002:a17:906:51da:b0:982:7505:fafa with SMTP id v26-20020a17090651da00b009827505fafamr1447534ejk.47.1689940874705; Fri, 21 Jul 2023 05:01:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689940874; cv=none; d=google.com; s=arc-20160816; b=WoAnmSNWhQlmG/21+QMm//yK0ZxeM+fQEkKZnSFzHQhRqDHDxWbh+YxzGpPhDmyYWT h3bJI26v/ds3raUdAEWSeo5YiWhnLWCfrmoOYkDOP+1d6ZMj0QhCnTqLcpvVdbyunoBq nqloTJ+8km89S9DRq2Fs3g046tbcZfVBR4og9JwyOFQUt0k9/f0UKehkgFXj35iqvV8m y+FL8N/7GbTGVsVIBan/ic+BDw1ydepMuTFORPjDmkw7CfCE9AaDJlzK64uaGHqCdujc cJksuNHSP85sm8goiyf4/i0zSBt4EmENY+DerhRTnbjZNF0DYXjyW0b+tkstZMINDN5U pcNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=3ToV4AhM7a10JABTx0K0avd4lKX5WrJHijwXiV++zv0=; fh=6gXoV4MbniIa2EReiHdvWpEn2VbC/0XrGJ22mUlqUhg=; b=B9L+80BDKjzx1v1MhalINfhndIpKW4pZe4irOStz2aT/XytCG0zbr6EYDDc+JyrBej EXPjL24PwcRafFGxnxXQSAuLpbbsUfh4+MV+hZ33nEUzVDbmGUzIaKC42/nRTNJhK3gP SKg00cVB110nImoWlr24kLaHb2exdG1Pl1FwE6v46ZhnBE2O2Y4ZHEG0wzqL/CjF20TU fzxuh3arEYhQkcqXJ0JYAA+t/8BtEOtxTEiL/w4ie+aRd6Jmjfng8gcw2+ihN8QyPaun xHIvottdA0dSEQn9AitMGFSmTa/OhpiebFf0yDb7d2BcuFK+Sm9n0JAbtN4LLP3KsMMS V1cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Jaz3kR8K; 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=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rv16-20020a17090710d000b00992acf124b3si1930419ejb.926.2023.07.21.05.00.38; Fri, 21 Jul 2023 05:01:14 -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=@intel.com header.s=Intel header.b=Jaz3kR8K; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230338AbjGULba (ORCPT + 99 others); Fri, 21 Jul 2023 07:31:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229730AbjGULb2 (ORCPT ); Fri, 21 Jul 2023 07:31:28 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52E1CE0; Fri, 21 Jul 2023 04:31:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689939087; x=1721475087; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=9/ut5UjQKUswKVul7iirnPDvZhjc6d3idO3CXe5FhlI=; b=Jaz3kR8KLez68W2bwvTWaixZQyviLl/N747RJfXh1N/iYK3mKJgnnvJm m3HMTanwlxE6MtsPiC8DYTqrVEm+oyKYllFVrXbMrWt+7nOa0E57hfFZp Zdi85doAtzTSD7x5KNHp/ideh9J/CuHx6o0V4DURo+nShYqkxJmpjDgGR nBj2wPo+gplpPgGCP3Fsbheud78QWE6fzn2cLAOj6Cp19d5bKcBEYwwUq /mH9+f9n4rUiCwVQ6l1pkw1jVaPXersUCKlJI35V4u5sdbQqD4DzCsk1n GMTwNseIsD3ayh69Pba8ynaPjku+Z0evHvenOhbgQedRQ4eDfxAmTTqAZ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10777"; a="433230705" X-IronPort-AV: E=Sophos;i="6.01,220,1684825200"; d="scan'208";a="433230705" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2023 04:31:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10777"; a="838521376" X-IronPort-AV: E=Sophos;i="6.01,220,1684825200"; d="scan'208";a="838521376" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga002.fm.intel.com with ESMTP; 21 Jul 2023 04:31:25 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1qMoM0-002DKi-02; Fri, 21 Jul 2023 14:31:24 +0300 Date: Fri, 21 Jul 2023 14:31:23 +0300 From: Andy Shevchenko To: Nuno =?iso-8859-1?Q?S=E1?= Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron , Lars-Peter Clausen Subject: Re: [PATCH v1 3/8] iio: core: Switch to krealloc_array() Message-ID: References: <20230720205324.58702-1-andriy.shevchenko@linux.intel.com> <20230720205324.58702-4-andriy.shevchenko@linux.intel.com> <65dbc603062018e1cd968caf983512c2cb2039e5.camel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Fri, Jul 21, 2023 at 02:28:36PM +0300, Andy Shevchenko wrote: > On Fri, Jul 21, 2023 at 12:53:53PM +0200, Nuno S? wrote: > > On Fri, 2023-07-21 at 13:14 +0300, Andy Shevchenko wrote: > > > On Fri, Jul 21, 2023 at 09:59:37AM +0200, Nuno S? wrote: > > > > On Thu, 2023-07-20 at 23:53 +0300, Andy Shevchenko wrote: ... > > > > > +???????struct attribute **attrs, **attr, *clk = NULL; > > > > > ????????struct iio_dev_attr *p; > > > > > -???????struct attribute **attr, *clk = NULL; > > > > > ? > > > > > ????????/* First count elements in any existing group */ > > > > > -???????if (indio_dev->info->attrs) { > > > > > -???????????????attr = indio_dev->info->attrs->attrs; > > > > > -???????????????while (*attr++ != NULL) > > > > > +???????attrs = indio_dev->info->attrs ? indio_dev->info->attrs->attrs : > > > > > NULL; > > > > > +???????if (attrs) { > > > > > +???????????????for (attr = attrs; *attr; attr++) > > > > > ????????????????????????attrcount_orig++; > > > > > > > not really related with the change... maybe just mention it in the commit? > > > > > > Hmm... It's related to make krealloc_array() to work as expected. > > > > > > > Hmm, I think it's arguable :). while() -> for() it's not really needed unless > > I'm missing something. You could even initialize 'attrs' to NULL at declaration > > and keep the above diff minimum. > > I'm not a fan of the assignments in the declarations when it potentially can be > disrupted by a chunk of code and reading the code itself may be harder due to > an interruption for checking the initial value. Hence, having > > + attr = attrs; > while (... != NULL) > > seems enough to be replaced with one liner for-loop. Note that attrs is reused later, so the above assignment makes it cleaner that some value is assigned to it. With the original code it's not so obvious. > > That said, I actually prefer this style (even though some people don't like much > > the ternary operator). > > Thanks! > > > > > > ????????} -- With Best Regards, Andy Shevchenko