* [PATCH -next] mm/memcg: fix a -Wparentheses compilation warning
@ 2019-07-31 13:45 Qian Cai
2019-07-31 13:53 ` Michal Hocko
0 siblings, 1 reply; 2+ messages in thread
From: Qian Cai @ 2019-07-31 13:45 UTC (permalink / raw)
To: akpm
Cc: miles.chen, mhocko, hannes, vdavydov.dev, cgroups, linux-mm,
linux-kernel, Qian Cai
The linux-next commit ("mm/memcontrol.c: fix use after free in
mem_cgroup_iter()") [1] introduced a compilation warning,
mm/memcontrol.c:1160:17: warning: using the result of an assignment as a
condition without parentheses [-Wparentheses]
} while (memcg = parent_mem_cgroup(memcg));
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
mm/memcontrol.c:1160:17: note: place parentheses around the assignment
to silence this warning
} while (memcg = parent_mem_cgroup(memcg));
^
( )
mm/memcontrol.c:1160:17: note: use '==' to turn this assignment into an
equality comparison
} while (memcg = parent_mem_cgroup(memcg));
^
==
Fix it by adding a pair of parentheses.
[1] https://lore.kernel.org/linux-mm/20190730015729.4406-1-miles.chen@mediatek.com/
Signed-off-by: Qian Cai <cai@lca.pw>
---
mm/memcontrol.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 694b6f8776dc..4f66a8305ae0 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1157,7 +1157,7 @@ static void invalidate_reclaim_iterators(struct mem_cgroup *dead_memcg)
do {
__invalidate_reclaim_iterators(memcg, dead_memcg);
last = memcg;
- } while (memcg = parent_mem_cgroup(memcg));
+ } while ((memcg = parent_mem_cgroup(memcg)));
/*
* When cgruop1 non-hierarchy mode is used,
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH -next] mm/memcg: fix a -Wparentheses compilation warning
2019-07-31 13:45 [PATCH -next] mm/memcg: fix a -Wparentheses compilation warning Qian Cai
@ 2019-07-31 13:53 ` Michal Hocko
0 siblings, 0 replies; 2+ messages in thread
From: Michal Hocko @ 2019-07-31 13:53 UTC (permalink / raw)
To: Qian Cai
Cc: akpm, miles.chen, hannes, vdavydov.dev, cgroups, linux-mm, linux-kernel
On Wed 31-07-19 09:45:53, Qian Cai wrote:
> The linux-next commit ("mm/memcontrol.c: fix use after free in
> mem_cgroup_iter()") [1] introduced a compilation warning,
>
> mm/memcontrol.c:1160:17: warning: using the result of an assignment as a
> condition without parentheses [-Wparentheses]
> } while (memcg = parent_mem_cgroup(memcg));
> ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
> mm/memcontrol.c:1160:17: note: place parentheses around the assignment
> to silence this warning
> } while (memcg = parent_mem_cgroup(memcg));
> ^
> ( )
> mm/memcontrol.c:1160:17: note: use '==' to turn this assignment into an
> equality comparison
> } while (memcg = parent_mem_cgroup(memcg));
> ^
> ==
>
> Fix it by adding a pair of parentheses.
>
> [1] https://lore.kernel.org/linux-mm/20190730015729.4406-1-miles.chen@mediatek.com/
>
> Signed-off-by: Qian Cai <cai@lca.pw>
Thanks for the fix. I assume Andrew is going to squash it into the
original patch.
Acked-by: Michal Hocko <mhocko@suse.com>
> ---
> mm/memcontrol.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 694b6f8776dc..4f66a8305ae0 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -1157,7 +1157,7 @@ static void invalidate_reclaim_iterators(struct mem_cgroup *dead_memcg)
> do {
> __invalidate_reclaim_iterators(memcg, dead_memcg);
> last = memcg;
> - } while (memcg = parent_mem_cgroup(memcg));
> + } while ((memcg = parent_mem_cgroup(memcg)));
>
> /*
> * When cgruop1 non-hierarchy mode is used,
> --
> 1.8.3.1
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-07-31 13:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-31 13:45 [PATCH -next] mm/memcg: fix a -Wparentheses compilation warning Qian Cai
2019-07-31 13:53 ` Michal Hocko
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).