Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3627857pxk; Tue, 29 Sep 2020 01:50:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0VcDxNkHy+VPIpkZ8jSXwtJRuEE5ll3USsz9Jeo17edkUjg9j+eeVcdxspYvsSZcdfjP6 X-Received: by 2002:a17:906:364b:: with SMTP id r11mr2754565ejb.48.1601369444402; Tue, 29 Sep 2020 01:50:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601369444; cv=none; d=google.com; s=arc-20160816; b=X8TyJkllrwf2kxv5UysiTi1GkM2T5m2v7Ququq3sYijkXiGPDiUSbvyBHZJjt2rjmQ rhozIh3w58ednVMF/JRobIYVz2RaIoI3ID37fqzub1VsEeBEXeRO1GqXlRtx2h+LbNHn C2v3xOI44hgkKPLGnmhuEsGkQNIR3b0FLDU6u1PcwHxuthNSixdBXKbMV8+QLrKidoNO yPqm7sliPJS61jvuqXe/bxGkopt2au2XePQM7tcalRM86hl+pBHHzko3Stl4FPq1AvXQ 03YAZPU2qNwskiH8aY3lxNrDY20updeEHQcW0KHT4MYW+3xad4w8i3bWLEPWV0FAZHQ9 3GQQ== 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-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=hOZ27+HF/9hLg4bV8V4OCiTevXk67A7RLpj34Icq+yo=; b=pEq/uypAZ50J3PTkEXYVa6WM6p3AJF8SiYaYxb1O+bRKKYJ6XZFAddO2g5zptInvvw opQcoAcKB3ou9nTROLkMJQfFuMxmLJOQYviUGJy6RQUlJNCstAiXTbkAVU4tbKDzhtqh o3c49UDKTpdsZZ9bcv8dJ4am1/HQQULjqgGN1FJhyrND5gP8P2btUyAA9DxWCfFA5IV0 ZM6Zs7RdyCfNKzKYqhn1JeZuj8wUxXk7lmw+v1l0drKUiF1ljRcqI9zO3L95e7m7tWRK FuHwyKvk1zBa3nMhhwf4BZXsC808q+mozjZFhKiFAwrgO09/I9cevSA9Vmpe7c09iMg6 i3Qw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y12si2224066edv.98.2020.09.29.01.50.21; Tue, 29 Sep 2020 01:50:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727790AbgI2ItW (ORCPT + 99 others); Tue, 29 Sep 2020 04:49:22 -0400 Received: from mga18.intel.com ([134.134.136.126]:43003 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725774AbgI2ItV (ORCPT ); Tue, 29 Sep 2020 04:49:21 -0400 IronPort-SDR: GCJylJLB8KVgguHwEc52N22iDLoQ2y5Xl1OrSjqhhWnSmoQF/QyyAX3ysBrXec0/PH2jpavlVj wtPoiTcK8lPQ== X-IronPort-AV: E=McAfee;i="6000,8403,9758"; a="149922095" X-IronPort-AV: E=Sophos;i="5.77,317,1596524400"; d="scan'208";a="149922095" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2020 01:49:20 -0700 IronPort-SDR: OuWf3/4RT4QtyKwW74QYQmXVHxdWamI3BZFe0bYncUkOB2ZTACf9Nfx4JUc8mfxHznWE2VsFuo E+9tjrqrOeLw== X-IronPort-AV: E=Sophos;i="5.77,317,1596524400"; d="scan'208";a="350150422" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2020 01:49:18 -0700 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1kNBJw-002kS2-GC; Tue, 29 Sep 2020 11:49:12 +0300 Date: Tue, 29 Sep 2020 11:49:12 +0300 From: Andy Shevchenko To: David Laight Cc: 'Joe Perches' , Bartosz Golaszewski , Linus Walleij , Jonathan Corbet , Kent Gibson , "open list:GPIO SUBSYSTEM" , linux-doc , Linux Kernel Mailing List , Bartosz Golaszewski Subject: Re: [PATCH v2 1/9] lib: string_helpers: provide kfree_strarray() Message-ID: <20200929084912.GZ3956970@smile.fi.intel.com> References: <20200928104155.7385-1-brgl@bgdev.pl> <20200928104155.7385-2-brgl@bgdev.pl> <2fcfd81f62ec87d9b75cca32468d8b9583faec47.camel@perches.com> <12317bbc7712d96be8f52a3bf574e47628830191.camel@perches.com> <3ba6779e11684ec8bc32638aa67ab952@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3ba6779e11684ec8bc32638aa67ab952@AcuMS.aculab.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 29, 2020 at 08:10:10AM +0000, David Laight wrote: > From: Joe Perches > > Sent: 28 September 2020 17:07 > > > > On Mon, 2020-09-28 at 18:02 +0200, Bartosz Golaszewski wrote: > > > On Mon, Sep 28, 2020 at 5:59 PM Joe Perches wrote: > > > > On Mon, 2020-09-28 at 12:41 +0200, Bartosz Golaszewski wrote: > > > > > From: Bartosz Golaszewski > > > > > > > > > > There's a common pattern of dynamically allocating an array of char > > > > > pointers and then also dynamically allocating each string in this > > > > > array. Provide a helper for freeing such a string array with one call. > > > > > > > > Isn't this also common for things like ring buffers? > > > > Why limit this to char *[]? > > > > > > > > > > I don't want to add APIs nobody is using. What do you suggest? > > > > Change the argument to void** and call it > > > > void kfree_array(void **array, int count); > > Does help, void doesn't work that way. Actually good catch. void * and void ** have a big difference in the implicit casting behaviour. I was stumbled over this while playing with some experimental stuff locally. -- With Best Regards, Andy Shevchenko