scripts/dtc: Simplify condition in get_node_by_path
PATCH 1/1 scripts/dtc: Simplify condition in get_node_by_path
The strlen && strprefixeq check in get_node_by_path is excessive, since strlen is checked in strprefixeq macro internally. Thus, 'strlen(child->name) == p-path' conjunct duplicates after macro expansion and could be removed.
--- scripts/dtc/livetree.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
scripts/dtc/livetree.c +1 -2
@@ -526,8 +526,7 @@ struct node *get_node_by_path(struct node *tree, const char *path) p =strchr (path,'/' );for_each_child (tree, child) { -if (p && (strlen (child->name) == p-path) && -strprefixeq (path, p - path, child->name)) +if (p &&strprefixeq (path, p - path, child->name))return get_node_by_path (child, p+1 );else if (!p &&streq (path, child->name))return child;
Signature · 1 line
2.21.0
Hi Denis,
Quoted 17 lines · Denis Efremov
The strlen && strprefixeq check in
get_node_by_pathis excessive, since strlen is checked in strprefixeq macro internally. Thus, 'strlen(child->name)== p-path' conjunct duplicates after macro expansion and could be removed.Signed-off-by Denis Efremov <[email protected]>--- scripts/dtc/livetree.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)scripts/dtc/livetree.c +0
-0
scripts/dtc/livetree.c struct node *get_node_by_path(struct node *tree, const char *path) · line 532
Quoted 9 lines
scripts/dtc/livetree.c +1
-2@@ -526,8 +526,7 @@ struct node *get_node_by_path(struct node *tree, const char *path) p =strchr (path,'/' );for_each_child (tree, child) { -if (p && (strlen (child->name) == p-path) && -strprefixeq (path, p - path, child->name)) +if (p &&strprefixeq (path, p - path, child->name))return get_node_by_path (child, p+1 );else if (!p &&streq (path, child->name))return child;
livetree.c is maintained in the upstream dtc project. We pull changes from that project into the Linux kernel source tree.
Info on submitting patches is in the upstream file "Documentation/manual.txt":
1) Sources
Source code for the Device Tree Compiler can be found at git.kernel.org.
The upstream repository is here:
git://git.kernel.org/pub/scm/utils/dtc/dtc.git
https://git.kernel.org/pub/scm/utils/dtc/dtc.git
The gitweb interface for the upstream respository is:
https://git.kernel.org/cgit/utils/dtc/dtc.git/
1.1) Submitting Patches
Patches should be sent to the maintainers:
David Gibson <[email protected]> Jon Loeliger <[email protected]>
and CCed to <[email protected]>.