Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp507671ybl; Wed, 21 Aug 2019 00:52:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqwYjtgveAnIkCcNxTPmVcNJiBiizLRPLU6h9JFopP82W/CdHYcsKWR5cGhxOIZagyn4Ylvt X-Received: by 2002:a17:90a:77c9:: with SMTP id e9mr3758989pjs.141.1566373921731; Wed, 21 Aug 2019 00:52:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566373921; cv=none; d=google.com; s=arc-20160816; b=xjNoTkEjIko/AgDRbHJDdpohi3VrknAUAFng7EM/j85G0k78oKaUxU6Ojeu/W2xrMX WDvzXImj9rl5bQMfWgScs+D05U0/j8a6F/YWbqWmp4hjzNrhJH3NSYsJB5WXcrJkH1aC xQWBmB22h86NRYM4jWqswLtWcBcDhyWRrQoTmbgm/uOoXe2RLC5VuA/wh8skTU7yrkrn T+rBOD/l2gW3lc2wIzGjtOAlkOdjMojwT5GhR9oxY4Ch/nG79q7NemlJ0X7guPcPQptw LER4L4JB23hm7Hwn72n3dOTkbpEsqguD3lEvIU7moZ2yLoUmjdIbQ7ms5Mc8BWeJ1Ybk b12A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=LCcOSyH+/t6BHPU3+NR4sVyqB31XKUM6aOgb9lw/+Ro=; b=F8cUsieChR8TurqELok7zYQX84YypFupi8AcukYQO9PdD3q28uVhwoDfs6bIcDf6Po BHoqrVL9KCKPyY72KcROWvxRgR6MB7BatYQg5F3hChuS4nSzss+Jn6iuWQT+gOpN6EFp Y4O5S5hCK3rYJQVYypEnilgd6rHEUSufVcLZjRm6P7mEXrC6A1BOMQGZlXZo1TtnQjoh ++pm2/EA21Nrwm2oK4PqZfaPpWdnJ5iDEj3xetxD4qxdlP3Vh0yxquPXd4PzDl3nYBr/ K85U8jOPj0awKpNZZF41Dfdhe4BbjqbB5swATzUs1yd4DabkPUP73O8Iv0sB6iKO9fSm A3xw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u17si13885277pgn.387.2019.08.21.00.51.46; Wed, 21 Aug 2019 00:52:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727373AbfHUHFp (ORCPT + 99 others); Wed, 21 Aug 2019 03:05:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58404 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726224AbfHUHFp (ORCPT ); Wed, 21 Aug 2019 03:05:45 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 50A6610C051B; Wed, 21 Aug 2019 07:05:44 +0000 (UTC) Received: from krava (unknown [10.43.17.33]) by smtp.corp.redhat.com (Postfix) with SMTP id 247345C1D6; Wed, 21 Aug 2019 07:05:40 +0000 (UTC) Date: Wed, 21 Aug 2019 09:05:40 +0200 From: Jiri Olsa To: Mamatha Inamdar Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com, namhyung@kernel.org, kstewart@linuxfoundation.org, gregkh@linuxfoundation.org, jeremie.galarneau@efficios.com, shawn@git.icu, tstoyanov@vmware.com, tglx@linutronix.de, alexey.budankov@linux.intel.com, adrian.hunter@intel.com, songliubraving@fb.com, ravi.bangoria@linux.ibm.com Subject: Re: [PATCH V1]Perf: Return error code for perf_session__new function on failure Message-ID: <20190821070540.GA16609@krava> References: <20190820105645.4920.55590.stgit@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190820105645.4920.55590.stgit@localhost.localdomain> User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.65]); Wed, 21 Aug 2019 07:05:44 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 20, 2019 at 04:51:21PM +0530, Mamatha Inamdar wrote: SNIP > #ifdef HAVE_ZSTD_SUPPORT > static int perf_session__process_compressed_event(struct perf_session *session, > @@ -183,6 +184,7 @@ static int ordered_events__deliver_event(struct ordered_events *oe, > struct perf_session *perf_session__new(struct perf_data *data, > bool repipe, struct perf_tool *tool) > { > + int ret = -ENOMEM; > struct perf_session *session = zalloc(sizeof(*session)); > > if (!session) > @@ -197,13 +199,15 @@ struct perf_session *perf_session__new(struct perf_data *data, > > perf_env__init(&session->header.env); > if (data) { > - if (perf_data__open(data)) > + ret = perf_data__open(data); > + if (ret < 0) > goto out_delete; > > session->data = data; > > if (perf_data__is_read(data)) { > - if (perf_session__open(session) < 0) > + ret = perf_session__open(session); > + if (ret < 0) > goto out_delete; > > /* > @@ -218,7 +222,8 @@ struct perf_session *perf_session__new(struct perf_data *data, > perf_evlist__init_trace_event_sample_raw(session->evlist); > > /* Open the directory data. */ > - if (data->is_dir && perf_data__open_dir(data)) > + ret = data->is_dir && perf_data__open_dir(data); > + if (ret) > goto out_delete; will this return 1 in case of error? jirka > } > } else { > @@ -252,7 +257,7 @@ struct perf_session *perf_session__new(struct perf_data *data, > out_delete: > perf_session__delete(session); > out: > - return NULL; > + return ERR_PTR(ret); > } > > static void perf_session__delete_threads(struct perf_session *session) >