2021-06-08 00:35:45

by Zou Wei

[permalink] [raw]
Subject: [PATCH -next] perf tools: Use list_move instead of list_del/list_add

Using list_move() instead of list_del() + list_add().

Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Zou Wei <[email protected]>
---
tools/perf/util/srccode.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/perf/util/srccode.c b/tools/perf/util/srccode.c
index c29edaa..476e998 100644
--- a/tools/perf/util/srccode.c
+++ b/tools/perf/util/srccode.c
@@ -97,8 +97,7 @@ static struct srcfile *find_srcfile(char *fn)
hlist_for_each_entry (h, &srcfile_htab[hval], hash_nd) {
if (!strcmp(fn, h->fn)) {
/* Move to front */
- list_del(&h->nd);
- list_add(&h->nd, &srcfile_list);
+ list_move(&h->nd, &srcfile_list);
return h;
}
}
--
2.6.2


2021-06-08 12:48:27

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH -next] perf tools: Use list_move instead of list_del/list_add

Em Tue, Jun 08, 2021 at 08:52:46AM +0800, Zou Wei escreveu:
> Using list_move() instead of list_del() + list_add().

Thanks, applied.

- Arnaldo


> Reported-by: Hulk Robot <[email protected]>
> Signed-off-by: Zou Wei <[email protected]>
> ---
> tools/perf/util/srccode.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/srccode.c b/tools/perf/util/srccode.c
> index c29edaa..476e998 100644
> --- a/tools/perf/util/srccode.c
> +++ b/tools/perf/util/srccode.c
> @@ -97,8 +97,7 @@ static struct srcfile *find_srcfile(char *fn)
> hlist_for_each_entry (h, &srcfile_htab[hval], hash_nd) {
> if (!strcmp(fn, h->fn)) {
> /* Move to front */
> - list_del(&h->nd);
> - list_add(&h->nd, &srcfile_list);
> + list_move(&h->nd, &srcfile_list);
> return h;
> }
> }
> --
> 2.6.2
>

--

- Arnaldo