Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4765551ioa; Wed, 27 Apr 2022 10:35:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXynuRcv+790lP9Q5FSXK2a7QvZw8mYUKTrIHBS1sz4hDoSibAgfIxypfkCpeTE5ztNxzB X-Received: by 2002:a17:90b:1803:b0:1d9:a268:56f4 with SMTP id lw3-20020a17090b180300b001d9a26856f4mr13239919pjb.91.1651080916760; Wed, 27 Apr 2022 10:35:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651080916; cv=none; d=google.com; s=arc-20160816; b=kCtq93EWPoMakYcPwSbyDtyU5p+Q4cwaVemIz3n3uDb8gqtI0FZD9XmW64mfKnNrWo h3VtpG9W8vB+abK428uHFJh6A5Pp7ivktRhj76YBRjo9a0Gb3qJ1L7NXz+35/nRakp+o nbLiF1F7ljHfJdD1rmPfDgshBNCMSswGUWk0Cakh6DSrEjEAu4hwOuv9cdTAXnlaEMjZ /fYlS/hmEWRW34M+4RTRlc2yeLW7FLWz3NPqyU28umf1Ax7sXLxO9WiL+3GAloZqskYX aBbpzIiOzfPKoSxUWO0w5v8vjr/o2njCMvp0Zya4UVRwNk4hoPaqYpp/oZp/y8hCdV/Q 4oNw== 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=LastlIlp3ExuBmWFIzRxFtrilFT5BPcN0d/npk5blEA=; b=0aUL4vRbPtGW3jSjISJl7D5jYkbc8nYeuL/XYaJa5q8qzjzOq/XaDRgwyH1EnKm4Vu MH6FabfAgKPO5bWQ8aAqyXfkZlGkdJLcullq4BtD5Jqa4EBIXMYBSFrGam7yFqwT7X5R onS0vKCX4x1usOFpfEuqpLRDipGw833ceTSzQr5GupFb0a5Y+REsV7P+H5hsMAPR6UZ1 WbZQ6PCdIbJpsnR67XrWmEGOnIWLuYL3lrf8vKo3xKp4RIqktXDk3U54sEZv3UMH8kQ1 /HvvNghI2OwNXe9+1uBN1SsrzIc0BEGvInLiq7VCUSjGQPPKICRq4vm6Ol+kxz7RJ/IB O/VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XGeqeNiN; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id i6-20020a62c106000000b004fa831f601csi1918844pfg.231.2022.04.27.10.35.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 10:35:16 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XGeqeNiN; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 2C3D32F392; Wed, 27 Apr 2022 10:08:26 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243848AbiD0RLc (ORCPT + 99 others); Wed, 27 Apr 2022 13:11:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237739AbiD0RL3 (ORCPT ); Wed, 27 Apr 2022 13:11:29 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04B742F025 for ; Wed, 27 Apr 2022 10:08:17 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id e23so2684566eda.11 for ; Wed, 27 Apr 2022 10:08:16 -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=LastlIlp3ExuBmWFIzRxFtrilFT5BPcN0d/npk5blEA=; b=XGeqeNiNAy40QSZ1b7uWemHlUQTomh9n3vBdeswdMk7F8xK4atJkgASs1nBCeHPNUw fj8iTanx9ugZj3bYgk9vhDkdFmimSA+Ox7ft2lXxcRs+ZGc6c0mtGiVK+h5ScWc4FIY5 dcamIDhMHE9pUJuSp7BpDQb5m60O/BlhLQmfTbkelRK5zVEBRPCjm+Wq5dTt5OvXVPqz rU377ZbRobZ4ExSpPpmcGzgcgUopsAyKmjb008X3fCmsVe6wcZxGAWpGezC2timZ9pYk HV4vab1JohblVN5dOIrPkK27Ke2oaCN1EGfDPuqjX4vXYZ+obHM/vIWrub8sDA6UzfVr 3EmA== 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=LastlIlp3ExuBmWFIzRxFtrilFT5BPcN0d/npk5blEA=; b=A8wPJbMUWuzQl07Wqs+1bYFnP2GJ7syrJO/v1nwpWEUuDzU3cdYNPwGz0HmZ/H0WB3 wlisU83pCUt4NaHYMziJdNzefwAl4dBZgGgRkatKNkm8/kolRw4Daq3Fu/REkWSpSGBt gAt/oh7PdO3Gy1SRiOIkwNFC2/4mo2ybSGOlokJEgfhSCynx6te+U7+O9Z/xNIF5Uwo0 K/+WO96VFqhzm5QsAPyGOgFnAGW+/H/cErepgh5+eCXCsCEqKxRZLEp3tZydtrQn2mGm E05VgiTvN6oPHJzo+uQKn0VvkFF+9PS3IzqoMPAtnaj6xRX+3Cps9MH8czavJfszsyEc viFg== X-Gm-Message-State: AOAM530mw6wX6KHUNeWZkMx/aznyxwipIm4LisN3fRrQVHZpSqteIUGh KWtC7JpicDWmjlMwLtYjWrM= X-Received: by 2002:a05:6402:1912:b0:423:7fe8:6b2c with SMTP id e18-20020a056402191200b004237fe86b2cmr30777467edz.253.1651079295541; Wed, 27 Apr 2022 10:08:15 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id z3-20020a50cd03000000b00425d72fd0besm6694359edi.97.2022.04.27.10.08.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 10:08:15 -0700 (PDT) From: Jakob Koschel To: Steven Rostedt Cc: Ingo Molnar , linux-kernel@vger.kernel.org, Jakob Koschel Subject: [PATCH v2 1/4] tracing: Remove usage of list iterator after the loop body Date: Wed, 27 Apr 2022 19:07:31 +0200 Message-Id: <20220427170734.819891-2-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220427170734.819891-1-jakobkoschel@gmail.com> References: <20220427170734.819891-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 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 the list iterator variable to the traversal loop, use a dedicated pointer to point to the found element [1]. Before, the code implicitly used the head when no element was found when using &pos->list. Since the new variable is only set if an element was found, the head needs to be used explicitly if the variable is NULL. Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1] Signed-off-by: Jakob Koschel --- kernel/trace/trace_output.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c index 8aa493d25c73..733a4d6c20e2 100644 --- a/kernel/trace/trace_output.c +++ b/kernel/trace/trace_output.c @@ -692,7 +692,7 @@ static LIST_HEAD(ftrace_event_list); static int trace_search_list(struct list_head **list) { - struct trace_event *e; + struct trace_event *e = NULL, *iter; int next = __TRACE_LAST_TYPE; if (list_empty(&ftrace_event_list)) { @@ -704,9 +704,11 @@ static int trace_search_list(struct list_head **list) * We used up all possible max events, * lets see if somebody freed one. */ - list_for_each_entry(e, &ftrace_event_list, list) { - if (e->type != next) + list_for_each_entry(iter, &ftrace_event_list, list) { + if (iter->type != next) { + e = iter; break; + } next++; } @@ -714,7 +716,10 @@ static int trace_search_list(struct list_head **list) if (next > TRACE_EVENT_TYPE_MAX) return 0; - *list = &e->list; + if (e) + *list = &e->list; + else + *list = &ftrace_event_list; return next; } -- 2.25.1