Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2887867pxb; Mon, 4 Apr 2022 01:35:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzD8xUshICWjy6f6K0Pg5u2L20JvkaUHnhgdrVHfaV4r/22Ey9lRNOrGncAehufMSf+1a2D X-Received: by 2002:a63:2214:0:b0:398:ee6c:e5f7 with SMTP id i20-20020a632214000000b00398ee6ce5f7mr9944535pgi.625.1649061346921; Mon, 04 Apr 2022 01:35:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649061346; cv=none; d=google.com; s=arc-20160816; b=D8TpoX5md0wQ2G4y3pJtggL27seZqEhA8QEjpiMDzep5P0x1wNySeFiRX8zzUcXmIS Ti0aqFbugYpsrbH04W53n2+DyF8C47+PgkCdnxyiAhpn7jJPzh+5E7/IueAD1cFZouZa TlnP2vEmW0N+boK7qzTX2mGjLcLVaU5tngae0aMD8Qubyl6I96SsmmNi06Llx/Pv4umC CKMNh0m1fK3QW9fw4IZPO9F+g9q+bz3M9vr0cpQhA+k1cgBkFRiFbw34sjZidNer4gCB wePv4w4RVMyBT5S22vlCwn69LxVk54u5sVH4yZ9btJ0Hxe9jLB4TdeqACBd8vYqlpfH1 WYMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YxLyiVAe1fZmParic2Rf8qrKN3jJ4OFw0+uxZzajL5E=; b=IPZY0gX0KDX+1AM/szKaeoQlNI/dKQWhYdfhM1s3rpoyBM86zWc9a4MQQ2g1jDiWZR 1IZXRQuMlXHCHoSHqNfRIhcY0Bkc2CJOGVDCus7Gj+RxmtQPIvFA3lqK4vx7X57c7VWg WK+i1UMWGrDDGgxD+b8m78dhySVc/CJ2GxBAzCEIHB1gTg0PVQEp0BCXrDISrg5e6qqe fzUKudAlIeujzH6VWSSGsYAd4bSumf0qd0XWLIlj4qm8cd+sPasmf3AosEarRfE1E/9+ iLedjt1P2YN1NbYoO0cafLqqp0hMHw0Xm2x6QGrSr+S/IQ6XMvIQJdlwOW3u4RDEm9Bf GrwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=F3gaNDG3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 125-20020a630983000000b003982527bdefsi9368245pgj.72.2022.04.04.01.35.34; Mon, 04 Apr 2022 01:35:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=F3gaNDG3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354366AbiDBKbn (ORCPT + 99 others); Sat, 2 Apr 2022 06:31:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354352AbiDBKba (ORCPT ); Sat, 2 Apr 2022 06:31:30 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0619660DA9 for ; Sat, 2 Apr 2022 03:29:37 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id dr20so10600893ejc.6 for ; Sat, 02 Apr 2022 03:29:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YxLyiVAe1fZmParic2Rf8qrKN3jJ4OFw0+uxZzajL5E=; b=F3gaNDG3p1fd02LhXBjLrg4xUhaFuZhyF11ZEjOjhxEIEAtv9JivmOsHbeb1z8yNmF YvZZfO+IiqdPzcPtbO39gZaO82AurmLSoqS5MWePMI6T1xZyUTtDGeq1Fk1Z97jYhUMZ duY88IdGSoZuoi5lpvd1092EhpR8jbuB2YOgSJ+PI0NH4lfrrrFjxee9Hi+A79GLQMZJ IImggEoDmGq3DOPGDbaWoLCl6ZyC/R0pcgyn59Pk5Kt8ApzihSTY3ISbahM2Mpsh0SWr FUp15NUeawuokyTkKwP0vMsQaubPCPHOC7MjU1jSTz9SmYKU2CANqRIl3dpk/jM5Qhxf oseg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YxLyiVAe1fZmParic2Rf8qrKN3jJ4OFw0+uxZzajL5E=; b=j0scsSiWZBVS44/4jRAOaE5LjwsWqi99vUUV+XvnHIG0othS1Ykmuqtk3KEDx2DS3G hmaT8smme3+Pj08JpSpxEl5diTjrBgKJXo2m+7nPBp5a0n5ZENIEyii/i2IjFjSUlJMP eJGd/fxYRyNiEgB+33eXgSHmKKAUuGB6dFn1pFhKA6zSJ8nE7WmWO+98HLR8LHFRptez /WP1XOtwJG79nL05QEaemYXnWEqbEX/qSjX2YzBI+gqwyBIyc57rpHlKv7qAhBQn8jH6 4CReoKQ/B/MTTq3ZEIZIjQ0mSKPmWm4XimKyUc/+HXljeLZmxJkJ6WhDbRH2sPGBYyZQ /54g== X-Gm-Message-State: AOAM5313LqtZzsqxHlguve3i0s7K2GegVxDLEWUUnZB5s0QVIRwlj/E1 Pv9kxyjgfTob0AonMzA1NsY= X-Received: by 2002:a17:906:314b:b0:6d6:da31:e545 with SMTP id e11-20020a170906314b00b006d6da31e545mr3466008eje.125.1648895375439; Sat, 02 Apr 2022 03:29:35 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id qk32-20020a1709077fa000b006df6bb30b28sm1952187ejc.171.2022.04.02.03.29.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Apr 2022 03:29:35 -0700 (PDT) From: Jakob Koschel To: Steven Rostedt Cc: Ingo Molnar , linux-kernel@vger.kernel.org, Mike Rapoport , "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." , Jakob Koschel Subject: [PATCH v2 3/4] tracing: Replace usage of found with dedicated list iterator variable Date: Sat, 2 Apr 2022 12:28:47 +0200 Message-Id: <20220402102848.1759172-4-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220402102848.1759172-1-jakobkoschel@gmail.com> References: <20220402102848.1759172-1-jakobkoschel@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To move the list iterator variable into the list_for_each_entry_*() macro in the future it should be avoided to use the list iterator variable after the loop body. To *never* use the list iterator variable after the loop it was concluded to use a separate iterator variable instead of a found boolean [1]. This removes the need to use a found variable and simply checking if the variable was set, can determine if the break/goto was hit. Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1] Signed-off-by: Jakob Koschel --- kernel/trace/trace_events_hist.c | 17 ++++++++--------- kernel/trace/trace_events_trigger.c | 28 +++++++++++++--------------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index 44db5ba9cabb..7f60d04d5b6e 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -6089,32 +6089,31 @@ static void hist_unregister_trigger(char *glob, struct event_trigger_data *data, struct trace_event_file *file) { + struct event_trigger_data *test = NULL, *iter, *named_data = NULL; struct hist_trigger_data *hist_data = data->private_data; - struct event_trigger_data *test, *named_data = NULL; - bool unregistered = false; lockdep_assert_held(&event_mutex); if (hist_data->attrs->name) named_data = find_named_trigger(hist_data->attrs->name); - list_for_each_entry(test, &file->triggers, list) { - if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) { - if (!hist_trigger_match(data, test, named_data, false)) + list_for_each_entry(iter, &file->triggers, list) { + if (iter->cmd_ops->trigger_type == ETT_EVENT_HIST) { + if (!hist_trigger_match(data, iter, named_data, false)) continue; - unregistered = true; - list_del_rcu(&test->list); + test = iter; + list_del_rcu(&iter->list); trace_event_trigger_enable_disable(file, 0); update_cond_flag(file); break; } } - if (unregistered && test->ops->free) + if (test && test->ops->free) test->ops->free(test->ops, test); if (hist_data->enable_timestamps) { - if (!hist_data->remove || unregistered) + if (!hist_data->remove || test) tracing_set_filter_buffering(file->tr, false); } } diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c index 7eb9d04f1c2e..1ba54a489416 100644 --- a/kernel/trace/trace_events_trigger.c +++ b/kernel/trace/trace_events_trigger.c @@ -614,22 +614,21 @@ static void unregister_trigger(char *glob, struct event_trigger_data *test, struct trace_event_file *file) { - struct event_trigger_data *data; - bool unregistered = false; + struct event_trigger_data *data = NULL, *iter; lockdep_assert_held(&event_mutex); - list_for_each_entry(data, &file->triggers, list) { - if (data->cmd_ops->trigger_type == test->cmd_ops->trigger_type) { - unregistered = true; - list_del_rcu(&data->list); + list_for_each_entry(iter, &file->triggers, list) { + if (iter->cmd_ops->trigger_type == test->cmd_ops->trigger_type) { + data = iter; + list_del_rcu(&iter->list); trace_event_trigger_enable_disable(file, 0); update_cond_flag(file); break; } } - if (unregistered && data->ops->free) + if (data && data->ops->free) data->ops->free(data->ops, data); } @@ -1976,27 +1975,26 @@ void event_enable_unregister_trigger(char *glob, struct trace_event_file *file) { struct enable_trigger_data *test_enable_data = test->private_data; + struct event_trigger_data *data = NULL, *iter; struct enable_trigger_data *enable_data; - struct event_trigger_data *data; - bool unregistered = false; lockdep_assert_held(&event_mutex); - list_for_each_entry(data, &file->triggers, list) { - enable_data = data->private_data; + list_for_each_entry(iter, &file->triggers, list) { + enable_data = iter->private_data; if (enable_data && - (data->cmd_ops->trigger_type == + (iter->cmd_ops->trigger_type == test->cmd_ops->trigger_type) && (enable_data->file == test_enable_data->file)) { - unregistered = true; - list_del_rcu(&data->list); + data = iter; + list_del_rcu(&iter->list); trace_event_trigger_enable_disable(file, 0); update_cond_flag(file); break; } } - if (unregistered && data->ops->free) + if (data && data->ops->free) data->ops->free(data->ops, data); } -- 2.25.1