mirror of
https://github.com/torvalds/linux.git
synced 2024-11-28 15:11:31 +00:00
tracing: Remove usage of list iterator variable after the loop
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] Link: https://lkml.kernel.org/r/20220427170734.819891-3-jakobkoschel@gmail.com Cc: Ingo Molnar <mingo@redhat.com> Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
This commit is contained in:
parent
1da27a2505
commit
99d8ae4ec8
@ -1723,9 +1723,9 @@ static LIST_HEAD(event_subsystems);
|
|||||||
|
|
||||||
static int subsystem_open(struct inode *inode, struct file *filp)
|
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 event_subsystem *system = NULL;
|
||||||
struct trace_subsystem_dir *dir = NULL; /* Initialize for gcc */
|
|
||||||
struct trace_array *tr;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (tracing_is_disabled())
|
if (tracing_is_disabled())
|
||||||
@ -1734,10 +1734,12 @@ static int subsystem_open(struct inode *inode, struct file *filp)
|
|||||||
/* Make sure the system still exists */
|
/* Make sure the system still exists */
|
||||||
mutex_lock(&event_mutex);
|
mutex_lock(&event_mutex);
|
||||||
mutex_lock(&trace_types_lock);
|
mutex_lock(&trace_types_lock);
|
||||||
list_for_each_entry(tr, &ftrace_trace_arrays, list) {
|
list_for_each_entry(iter_tr, &ftrace_trace_arrays, list) {
|
||||||
list_for_each_entry(dir, &tr->systems, list) {
|
list_for_each_entry(iter_dir, &iter_tr->systems, list) {
|
||||||
if (dir == inode->i_private) {
|
if (iter_dir == inode->i_private) {
|
||||||
/* Don't open systems with no events */
|
/* Don't open systems with no events */
|
||||||
|
tr = iter_tr;
|
||||||
|
dir = iter_dir;
|
||||||
if (dir->nr_events) {
|
if (dir->nr_events) {
|
||||||
__get_system_dir(dir);
|
__get_system_dir(dir);
|
||||||
system = dir->subsystem;
|
system = dir->subsystem;
|
||||||
@ -1753,9 +1755,6 @@ static int subsystem_open(struct inode *inode, struct file *filp)
|
|||||||
if (!system)
|
if (!system)
|
||||||
return -ENODEV;
|
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 */
|
/* Still need to increment the ref count of the system */
|
||||||
if (trace_array_get(tr) < 0) {
|
if (trace_array_get(tr) < 0) {
|
||||||
put_system(dir);
|
put_system(dir);
|
||||||
|
Loading…
Reference in New Issue
Block a user