Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2054954ybl; Thu, 15 Aug 2019 05:56:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqzSeSleLmjKZJw6P4sIAb6Ojoeb2BkiKrpLzAec8PkJUrjbKPFQLngk1rP+zX5YjqmMmsKf X-Received: by 2002:a17:90a:8403:: with SMTP id j3mr2017024pjn.3.1565873780915; Thu, 15 Aug 2019 05:56:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565873780; cv=none; d=google.com; s=arc-20160816; b=k1pPW9je42NjsbJZvhwCiIaxCief/paBE8Khk8T4PgjxrGhCDU71U/nh19pW7Mt8PZ L1oCwHnxy/2NkpXvvFWrpKU6W3o1jmmuZ1tG1UCCHchDzeOHGxnI2nzsg5O0WE+rUORs /dR6wObw/v5a3PrUjod44Dw/znAO4zWQTS5GvBChK+fwZNK0udOcp+z01A/omF4TV1X5 7PljIIcc1gdXZ3WE7eMArvqueEwKQ4SbfjLgWRY/0AFumNWb0fJvcWppV/5mzWeUCgp3 XUkQcN2sSRWMIeFZJ+/I9eragDhQWwXZO/U24tCkdiuH0lOvuoaBBHM9Su+nrxxqqckc /ZeQ== 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=sY1IN1fgVDKV8V9/Ouy0J9TAOKyvmcV0uwlq/y/m1nU=; b=Zev/lrk8RCr0EVs6F38oXXqjaDO9MKB7uVbHGSNZNqe3y2fO1dkV1XesjsvaXv69EW YjK4av8cXAdXt97t7TewDHY/Mkg35KY+sAVRGX1RjocAaknGbSuRDvgjBy6f4DMgz8Od 7f0/Y9/HjgCRKIRKiFM3Od+Tc8muOJBiYWJ5C2znnOGcLZib55GKq8q9QvxgFTNQEA1Z Lhg0x53Z5tuPdi5/Vybn/ON3R+P0kj7x4QgbNo1DGVFch7wosUuZkPPjiGpiRroPTt7+ 8l7M9NihlBdJy8qLyO/wnZZ4OmIk/YYExOPCEPgK6xGgY08UvKDL+SLSAk77Old2EkXF fNbQ== 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 fr17si939114pjb.36.2019.08.15.05.56.05; Thu, 15 Aug 2019 05:56:20 -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 S1731455AbfHOMvG (ORCPT + 99 others); Thu, 15 Aug 2019 08:51:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37338 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730451AbfHOMvG (ORCPT ); Thu, 15 Aug 2019 08:51:06 -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 6CEA23001596; Thu, 15 Aug 2019 12:51:05 +0000 (UTC) Received: from krava (unknown [10.43.17.33]) by smtp.corp.redhat.com (Postfix) with SMTP id 5D1567D3E8; Thu, 15 Aug 2019 12:51:02 +0000 (UTC) Date: Thu, 15 Aug 2019 14:51:01 +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]Perf: Return error code for perf_session__new function on failure Message-ID: <20190815125101.GE30356@krava> References: <20190814092654.7781.81601.stgit@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190814092654.7781.81601.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.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 15 Aug 2019 12:51:05 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 14, 2019 at 03:02:18PM +0530, Mamatha Inamdar wrote: SNIP > #ifdef HAVE_ZSTD_SUPPORT > static int perf_session__process_compressed_event(struct perf_session *session, > @@ -181,6 +182,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 = 0; hum, should ret be initialized to -ENOMEM instead? jirka > struct perf_session *session = zalloc(sizeof(*session)); > > if (!session) > @@ -195,13 +197,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; > > /* > @@ -216,7 +220,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; > } > } else { > @@ -250,7 +255,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) >