Re: [PATCH] livetree: simplify condition in get_node_by_path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Tue, Aug 27, 2019 at 11:41:48PM +0300, Denis Efremov wrote:
> 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.
> 
> Signed-off-by: Denis Efremov <efremov@xxxxxxxxx>

Applied, thanks.

> ---
>  livetree.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/livetree.c b/livetree.c
> index 0c03999..032df58 100644
> --- a/livetree.c
> +++ b/livetree.c
> @@ -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;

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux