Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3523444pxb; Mon, 4 Apr 2022 19:50:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiHs+b2VGHMadXb6piLUXHmIQ9maya2OISg4Ot2QZAZ9EE+ixcX2Dt7iptr/EdAk8yjlu1 X-Received: by 2002:a05:6a00:14c6:b0:4fb:3978:1020 with SMTP id w6-20020a056a0014c600b004fb39781020mr1196286pfu.36.1649127045835; Mon, 04 Apr 2022 19:50:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649127045; cv=none; d=google.com; s=arc-20160816; b=pS8u8O6Ind/yu/i4DkBXrp+EhRj7nUDSn8rLHBZHfVNzRdt0f4aY4qDngu1h77Xz+E XD/W70MiOaiwgTx9dYc2fp2TdjKnaNJnfNIgc0yIpzXy952TPFwLSwQjsk/58Nb2CP6e kXikLhCzZxTM8t9XHVh8ZUFWB6lzJu4Cg6Sz9iiEnRqeVWJw+g72m6Cx0VOxMTwisk5E ZQOT3kVpIM1TD2d6L7e9mH/Djoat0cPLTdtXVeqpvqIsXA56NXKywzmVyLLDoxnvX16x 86wmiCQedv91QBs/e0sUmg6G8+OsNlKudFyLBH8DdvriYhDvxewqjqqZIwVMywtKfJjc IsVA== 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=GSFi2Vbaam24zbQ2UHEtgn0YLJt9Gjcf9TUTQdEKRhk=; b=tMR/2xolox1iHgRBNgURhrhxuBUUnOmpA/YMSarwxPVDB/GWSbrrRExET7i5ejvkdq fP2SPDjetwNUb71U1FIfuEbwI/HfKJr5Ueq9HCmnkeEq2QFeOEFGquT8sV+ZwLA682r9 FBNqc25UwzaVA6wJ8SnJibUOsdvA0LIVO/lFRFs/hKezzPqz3JY3JDkoFZDSigcyW23G bSk4wgkjMPG/BpR51iXsYqTxxlpDY7RGGxEC8owM5F+upg50PL6QdV6ffDL1fY22d3TP WSanhWf/Em6nasRmamPDP9NiCrFcuxMuBajiAVVkTVN9B/f2bu5+jv4IbDWbzA9ixq4c UNEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="ANo/ZBjz"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id r70-20020a632b49000000b003816043ef1fsi12241425pgr.276.2022.04.04.19.50.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 19:50:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="ANo/ZBjz"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 68033408AA9; Mon, 4 Apr 2022 18:14:13 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354423AbiDBKf7 (ORCPT + 99 others); Sat, 2 Apr 2022 06:35:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353429AbiDBKfu (ORCPT ); Sat, 2 Apr 2022 06:35:50 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F3BAFFB58 for ; Sat, 2 Apr 2022 03:33:59 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id g22so5685315edz.2 for ; Sat, 02 Apr 2022 03:33:59 -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=GSFi2Vbaam24zbQ2UHEtgn0YLJt9Gjcf9TUTQdEKRhk=; b=ANo/ZBjzbJxD1fwLzVN2KY63i4HMkcnGpsETHRyILMum/mnT6bI7w7rQSLm+j/jV5h mUUI85lGIAF+muhNt0EFB1H1SvFpwPqgWN6MxROdPqctbENACn7gql4ZGuYxSGUJ7Ke0 HoVWf6dS6pughzdsThZDx4RH9+xEXNeObqYHuzeyo0M1yrW8i7FZMV9/5klIgYH2KlN8 DV841lG3axZZHoVHBMyxatjYTz9Dy/i8QobsUwqm/CRqLLrl2sJ3ntWiDmPDImRsSOd3 js3BrqsZJ1YJ9m3E32qBe4FbNHFkgEynskq1mDln3T7ia8OadbVW45OWOPewB5DhAEq2 VvfQ== 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=GSFi2Vbaam24zbQ2UHEtgn0YLJt9Gjcf9TUTQdEKRhk=; b=l79rA53gURhF0q1eBr359WFx4ZM/CoVEdnAq84t7U0hPnGIQ2jA3Munusegy1qbkeD PabMZfOXco7DEzJpEuLwGt0QBsCI0M+6ZIjsLBNw7RDuroG7dOfnZZ6ZXRz+VWkTf6gV /9e0F3K9S8XSVNSbYiQKB9vUw/8JpM1KTShsjDmgRTKjmdbrhHsuXWTTvSCRIPNbQA7t IVfpREmuxcuScKiios9SEXjv0GyYKdWIaEJ3T4PgZdpIPO1y6u/ObOZod+HBaDgil0jZ 2HaFBDq1t2+sv5jpZU9SK+ZpidYxvy4CGgSlNVDfBp/GC7Zucj2hhpIa2xFmEPdJCIO6 EUhQ== X-Gm-Message-State: AOAM532JX7eyg06f4+dZpZWqdEoQjvHehJsq9kH5KGkbHdbYuTHjS3Uj PDyk0Wb9HG8f7MsoULsUt/8pepYsZktFZA== X-Received: by 2002:a05:6402:40c9:b0:419:4b81:162e with SMTP id z9-20020a05640240c900b004194b81162emr25135170edb.380.1648895637722; Sat, 02 Apr 2022 03:33:57 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id ka22-20020a170907921600b006e4c1ab0bbdsm1886965ejb.207.2022.04.02.03.33.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Apr 2022 03:33:57 -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 2/4] tracing: Remove usage of list iterator variable after the loop Date: Sat, 2 Apr 2022 12:33:39 +0200 Message-Id: <20220402103341.1763932-3-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220402103341.1763932-1-jakobkoschel@gmail.com> References: <20220402103341.1763932-1-jakobkoschel@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 In preparation to limit the scope of a list iterator to the list traversal loop, use a dedicated pointer to point to the found element [1]. 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.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index e11e167b7809..97c7eb2f55e5 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -1723,9 +1723,9 @@ static LIST_HEAD(event_subsystems); static int subsystem_open(struct inode *inode, struct file *filp) { + struct trace_subsystem_dir *dir = NULL, *iter_dir; + struct trace_array *tr = NULL, *iter_tr; struct event_subsystem *system = NULL; - struct trace_subsystem_dir *dir = NULL; /* Initialize for gcc */ - struct trace_array *tr; int ret; if (tracing_is_disabled()) @@ -1734,14 +1734,16 @@ static int subsystem_open(struct inode *inode, struct file *filp) /* Make sure the system still exists */ mutex_lock(&event_mutex); mutex_lock(&trace_types_lock); - list_for_each_entry(tr, &ftrace_trace_arrays, list) { - list_for_each_entry(dir, &tr->systems, list) { - if (dir == inode->i_private) { + list_for_each_entry(iter_tr, &ftrace_trace_arrays, list) { + list_for_each_entry(iter_dir, &iter_tr->systems, list) { + if (iter_dir == inode->i_private) { /* Don't open systems with no events */ - if (dir->nr_events) { + if (iter_dir->nr_events) { __get_system_dir(dir); system = dir->subsystem; } + tr = iter_tr; + dir = iter_dir; goto exit_loop; } } @@ -1753,9 +1755,6 @@ static int subsystem_open(struct inode *inode, struct file *filp) if (!system) return -ENODEV; - /* Some versions of gcc think dir can be uninitialized here */ - WARN_ON(!dir); - /* Still need to increment the ref count of the system */ if (trace_array_get(tr) < 0) { put_system(dir); -- 2.25.1