From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8088C433E0 for ; Sat, 6 Feb 2021 20:27:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 58CEC64E2F for ; Sat, 6 Feb 2021 20:27:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229554AbhBFU05 (ORCPT ); Sat, 6 Feb 2021 15:26:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:46275 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbhBFU0z (ORCPT ); Sat, 6 Feb 2021 15:26:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612643129; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=y9dYlMV9MA1srgVqoiRfZeY5YUMO5hZpl3iN1t2OsNs=; b=gKqZa2uGjqYjsHyok2LX4UsrWXam2xwld/7nm99sArvRMBSivVIQXePL+sAoj76MkCEhiZ Fj5LyPD4jsCpbOo1UX+ZhOwdlDXO7Z1NuRlfyLwRJRxP+PZVUZTOEJt24WN9TeLxK6fL/w KWe26LbDSrj/tRzaX+aMtSbX7cnbAsw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-170-alxCFLZzNDSTko8WI_5Npg-1; Sat, 06 Feb 2021 15:25:27 -0500 X-MC-Unique: alxCFLZzNDSTko8WI_5Npg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 37B35427C3; Sat, 6 Feb 2021 20:25:25 +0000 (UTC) Received: from krava (unknown [10.40.192.19]) by smtp.corp.redhat.com (Postfix) with SMTP id 3E70360C64; Sat, 6 Feb 2021 20:25:22 +0000 (UTC) Date: Sat, 6 Feb 2021 21:25:21 +0100 From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan , Ian Rogers , Stephane Eranian , Alexei Budankov Subject: Re: [PATCH 06/24] perf daemon: Add config file support Message-ID: References: <20210129134855.195810-1-jolsa@redhat.com> <20210130234856.271282-1-jolsa@kernel.org> <20210130234856.271282-7-jolsa@kernel.org> <20210203211211.GS854763@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 04, 2021 at 04:08:50PM +0100, Jiri Olsa wrote: SNIP > > > + > > > +static void session__free(struct session *session) > > > +{ > > > + free(session->base); > > > + free(session->name); > > > + free(session->run); > > > > zfree() so that if there is some dangling pointer to session, we'll get > > NULL derefs > > and won't be notified by crash about the error ;-) ok oops, actualy it makes no sense to do it here, because we're freeing session just in the next line > > > > > > + free(session); > > > +} > > > + > > > +static void session__remove(struct session *session) > > > +{ > > > + list_del(&session->list); > > > > list_del_init same here > > > > > + session__free(session); > > > +} > > > + > > > +static void daemon__kill(struct daemon *daemon) > > > +{ > > > + daemon__signal(daemon, SIGTERM); > > > +} > > > + > > > static void daemon__free(struct daemon *daemon) > > > { > > > + struct session *session, *h; > > > + > > > + list_for_each_entry_safe(session, h, &daemon->sessions, list) > > > + session__remove(session); > > > > Wouldn't be better to have: > > > > list_for_each_entry_safe(session, h, &daemon->sessions, list) { > > list_del_init(&session->list); > > session__free(session); > > } > > > > Because naming that function "session__remove()" one thinks it is being > > removed from some data structure, but not that it is being as well > > deleted. session__remove is being called also from daemon__reconfig, so it's there not to repeat the code, I'm ok to rename it thanks, jirka