Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp10681253rwp; Fri, 21 Jul 2023 03:18:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlEQyaj+S8YXOI+3ZJF/6FDAINKyivemDag0pI1QllOUiNQRdQ6c0fw5G168JZz1vN0mP8O4 X-Received: by 2002:a17:90a:2e13:b0:263:70e7:1e17 with SMTP id q19-20020a17090a2e1300b0026370e71e17mr949909pjd.9.1689934691529; Fri, 21 Jul 2023 03:18:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689934691; cv=none; d=google.com; s=arc-20160816; b=J/76Fu3+SyuONxkcRyN7jH6Y0SQAd5bvQPc8RegrTOif6V3+V3Wo2nSO5m1zmcoqMX aoPR7ysT7z6vALhNVRRS8uPwIiULKtWqvP4Ru+36g0XT0KCoXFYzJ/OAV7LYxh8/ZvLZ QpS0j8gCDyNyBzAM+NvNu2e+g3oNdxDX4opEP7epL1GP7DUZV8bEgIFOENL6CYvTDCYv REMceVUho256e0jNh0X6ngs7USJFMIhwf0wPEUq3byxpNRmvcOMBtSBDyPS7teLVNmzB X5sy/Q3+zB1Z2ZmOXiYwNw2t9cnWlPFgQHp/lcBYiAiQ7K0PQkp8H7hrwCEW50z4sfZD xfWw== 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=EsfsfyqHbAtpglE7KQ2bhETRjegS/tn6mJypoZlAUPA=; fh=6gXoV4MbniIa2EReiHdvWpEn2VbC/0XrGJ22mUlqUhg=; b=lp9Q0Z6NKL19HGXir46j7myYFrhe+MQdMQURA99BN4RYAdq7+xJj07u65HZrLXkOwg +sCw8/cPGd5A9rlOy/v4FdH/oVnK1ksmJbLdS8GGC6rb8lJ4lvRUVg0E4DOqyekZsvFY W1VnP6wSUcOZAC7ifqR+yShMBC1eAKvnJLCfsu7ztne2RoTgb835qCHxmBxO29KubDi+ oXUpC6ifdyY5IdcX/mtStyzyMFm87VowbTKUDzJGEuhJP9iJ285kBLNXR/BMtyoiWTy+ hjEDjtTFRrzFF18WRNWSH2eZaa4Idg4LVzTKxk2VrYabTTFcETdQQ1FuGX5Ql3JSVjSk T8mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WskYfaGX; 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 a26-20020a631a5a000000b00542897dcc22si2465566pgm.516.2023.07.21.03.17.58; Fri, 21 Jul 2023 03:18:11 -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=WskYfaGX; 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 S231569AbjGUKOz (ORCPT + 99 others); Fri, 21 Jul 2023 06:14:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230183AbjGUKOX (ORCPT ); Fri, 21 Jul 2023 06:14:23 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 855AB2D51; Fri, 21 Jul 2023 03:14:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689934460; x=1721470460; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=bWTmW8Z1SY90z599UVo5aQdGHN8twxKFeXBEUIYTGM8=; b=WskYfaGXHvty2kGoysqPbODaChPnhXNnWgxOm9QCw5FEErUSg0HVqRmb PDutP+IKvjqb33SDVP7uSnoj3Osj5XfO0XwZgPN+00CAG1JP4GG1ehvGd yOtILCWqMte9c3FcksrMZRf5MfebCYtBCIilPjXm3Z2vXTK+meIpqBa2R FiADN5OdhjyPjKEkRSgo+ob/+Jd5UE/cCfTLQtWx/OUBiBEy8+b2/xyEf Q23VbzFimNF8aB/aLJJHSwWSgAHKcMyL3SLwpzS7208kFowufRvIisos6 plRJEwU+xJeSgWv61vtL6eqy22l/LvNA8YfPOW3YOqvbBjppnEUgc/jc7 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10777"; a="356973658" X-IronPort-AV: E=Sophos;i="6.01,220,1684825200"; d="scan'208";a="356973658" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2023 03:14:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10777"; a="1055512678" X-IronPort-AV: E=Sophos;i="6.01,220,1684825200"; d="scan'208";a="1055512678" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga005.fm.intel.com with ESMTP; 21 Jul 2023 03:14:18 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1qMn9M-00H8nR-2Z; Fri, 21 Jul 2023 13:14:16 +0300 Date: Fri, 21 Jul 2023 13:14:16 +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: <65dbc603062018e1cd968caf983512c2cb2039e5.camel@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 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. > > ????????} ... > > ????????iio_dev_opaque->chan_attr_group.attrs = > > -???????????????kcalloc(attrcount + 1, > > -???????????????????????sizeof(iio_dev_opaque->chan_attr_group.attrs[0]), > > -???????????????????????GFP_KERNEL); > > +???????????????krealloc_array(attrs, attrcount + 1, sizeof(*attrs), > > GFP_KERNEL); > > ????????if (iio_dev_opaque->chan_attr_group.attrs == NULL) { > > since you're here and you also already did some style cleanups above, maybe > change it to 'if (!iio_dev_opaque->chan_attr_group.attrs)'? I don't think it's related (but you can tell that this check related to the allocator, and since we touch it, we may touch this), if Jonathan wants this, I definitely do. ... Thank you for the review! -- With Best Regards, Andy Shevchenko