scripts/coccinelle/iterators/for_each_child.cocci
Source file repositories/reference/linux-study-clean/scripts/coccinelle/iterators/for_each_child.cocci
File Facts
- System
- Linux kernel
- Corpus path
scripts/coccinelle/iterators/for_each_child.cocci- Extension
.cocci- Size
- 6261 bytes
- Lines
- 359
- Domain
- Support Tooling And Documentation
- Bucket
- scripts
- Inferred role
- Support Tooling And Documentation: scripts
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
function ifunction ifunction i
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
// Adds missing of_node_put() before return/break/goto statement within a for_each iterator for child nodes.
//# False positives can be due to function calls within the for_each
//# loop that may encapsulate an of_node_put.
///
// Confidence: High
// Copyright: (C) 2020 Sumera Priyadarsini
// URL: https://coccinelle.gitlabpages.inria.fr/website
// Options: --no-includes --include-headers
virtual patch
virtual context
virtual org
virtual report
@r@
local idexpression n;
expression e1,e2;
iterator name for_each_node_by_name, for_each_node_by_type,
for_each_compatible_node, for_each_matching_node,
for_each_matching_node_and_match, for_each_child_of_node,
for_each_available_child_of_node, for_each_node_with_property;
iterator i;
statement S;
expression list [n1] es;
@@
(
(
for_each_node_by_name(n,e1) S
|
for_each_node_by_type(n,e1) S
|
for_each_compatible_node(n,e1,e2) S
|
for_each_matching_node(n,e1) S
|
for_each_matching_node_and_match(n,e1,e2) S
|
for_each_child_of_node(e1,n) S
|
for_each_available_child_of_node(e1,n) S
|
for_each_node_with_property(n,e1) S
)
&
i(es,n,...) S
)
@ruleone depends on patch && !context && !org && !report@
local idexpression r.n;
iterator r.i,i1;
expression e;
expression list [r.n1] es;
statement S;
@@
i(es,n,...) {
...
(
of_node_put(n);
|
e = n
|
return n;
|
i1(...,n,...) S
|
- return of_node_get(n);
Annotation
- Detected declarations: `function i`, `function i`, `function i`.
- Atlas domain: Support Tooling And Documentation / scripts.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.