* [PATCH linux-next] net: ceph: use swap() macro instead of taking tmp variable
@ 2022-04-12 6:46 Guo Zhengkui
2022-04-12 9:11 ` Ilya Dryomov
0 siblings, 1 reply; 2+ messages in thread
From: Guo Zhengkui @ 2022-04-12 6:46 UTC (permalink / raw)
To: Ilya Dryomov, Jeff Layton, Xiubo Li, David S. Miller,
Jakub Kicinski, Paolo Abeni, Guo Zhengkui,
open list:CEPH COMMON CODE (LIBCEPH),
open list:NETWORKING [GENERAL],
open list
Cc: zhengkui_guo
Fix the following coccicheck warning:
net/ceph/crush/mapper.c:1077:8-9: WARNING opportunity for swap()
by using swap() for the swapping of variable values and drop
the tmp variable that is not needed any more.
Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
---
net/ceph/crush/mapper.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/net/ceph/crush/mapper.c b/net/ceph/crush/mapper.c
index 7057f8db4f99..1daf95e17d67 100644
--- a/net/ceph/crush/mapper.c
+++ b/net/ceph/crush/mapper.c
@@ -906,7 +906,6 @@ int crush_do_rule(const struct crush_map *map,
int recurse_to_leaf;
int wsize = 0;
int osize;
- int *tmp;
const struct crush_rule *rule;
__u32 step;
int i, j;
@@ -1073,9 +1072,7 @@ int crush_do_rule(const struct crush_map *map,
memcpy(o, c, osize*sizeof(*o));
/* swap o and w arrays */
- tmp = o;
- o = w;
- w = tmp;
+ swap(o, w);
wsize = osize;
break;
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH linux-next] net: ceph: use swap() macro instead of taking tmp variable
2022-04-12 6:46 [PATCH linux-next] net: ceph: use swap() macro instead of taking tmp variable Guo Zhengkui
@ 2022-04-12 9:11 ` Ilya Dryomov
0 siblings, 0 replies; 2+ messages in thread
From: Ilya Dryomov @ 2022-04-12 9:11 UTC (permalink / raw)
To: Guo Zhengkui
Cc: Jeff Layton, Xiubo Li, David S. Miller, Jakub Kicinski,
Paolo Abeni, open list:CEPH COMMON CODE (LIBCEPH),
open list:NETWORKING [GENERAL],
open list, zhengkui_guo
On Tue, Apr 12, 2022 at 9:01 AM Guo Zhengkui <guozhengkui@vivo.com> wrote:
>
> Fix the following coccicheck warning:
> net/ceph/crush/mapper.c:1077:8-9: WARNING opportunity for swap()
>
> by using swap() for the swapping of variable values and drop
> the tmp variable that is not needed any more.
>
> Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
> ---
> net/ceph/crush/mapper.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/net/ceph/crush/mapper.c b/net/ceph/crush/mapper.c
> index 7057f8db4f99..1daf95e17d67 100644
> --- a/net/ceph/crush/mapper.c
> +++ b/net/ceph/crush/mapper.c
> @@ -906,7 +906,6 @@ int crush_do_rule(const struct crush_map *map,
> int recurse_to_leaf;
> int wsize = 0;
> int osize;
> - int *tmp;
> const struct crush_rule *rule;
> __u32 step;
> int i, j;
> @@ -1073,9 +1072,7 @@ int crush_do_rule(const struct crush_map *map,
> memcpy(o, c, osize*sizeof(*o));
>
> /* swap o and w arrays */
> - tmp = o;
> - o = w;
> - w = tmp;
> + swap(o, w);
> wsize = osize;
> break;
>
> --
> 2.20.1
>
Applied.
Thanks,
Ilya
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-12 10:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-12 6:46 [PATCH linux-next] net: ceph: use swap() macro instead of taking tmp variable Guo Zhengkui
2022-04-12 9:11 ` Ilya Dryomov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).