From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753541AbcEWQLL (ORCPT ); Mon, 23 May 2016 12:11:11 -0400 Received: from mga11.intel.com ([192.55.52.93]:63506 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752182AbcEWQLI (ORCPT ); Mon, 23 May 2016 12:11:08 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,356,1459839600"; d="scan'208";a="960578300" Subject: Re: [PATCH 1/2] iio: generic_buffer: Cleanup when receiving signals To: Jonathan Cameron , Peter Meerwald-Stadler References: <082703f268f7b8b868704006d285d605cce5a784.1463759121.git.leonard.crestez@intel.com> Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Hartmut Knaack , Lars-Peter Clausen , Daniel Baluta From: Crestez Dan Leonard Message-ID: <9de98860-1670-dbc2-b419-8e623deda6ea@intel.com> Date: Mon, 23 May 2016 19:10:52 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/21/2016 07:28 PM, Jonathan Cameron wrote: > On 20/05/16 16:55, Peter Meerwald-Stadler wrote: >> >>> This also drops all the code freeing string buffers at the end of main. >>> Memory is freed when the process exits anyway so there's no point in >>> cluttering the code with all those gotos. >> >> well, it helps to see that all memory has been released when looking for >> leaks :) >> e.g. valgrind becomes much less useful when the program exits with tons of >> memory still allocated > Beyond that we are looking at code here that will get cut and paste into other > peoples applications - they might not pick up that it doesn't clean up properly > after itself. > > I'd much prefer to keep these explicit frees in place. I think this would make more sense for a library (like libiio). But isn't the code in tools/iio merely an a test tool? I submitted v2 which keeps the frees. It still simplifies them by relying on stuff like free(NULL) being allowed. -- Regards, Leonard