* [PATCH] mm: avoid implicit type conversion
@ 2025-01-07 3:51 Kenny Cheng
2025-01-07 4:06 ` Al Viro
0 siblings, 1 reply; 3+ messages in thread
From: Kenny Cheng @ 2025-01-07 3:51 UTC (permalink / raw)
To: hannes, muchun.song
Cc: cgroups, linux-mm, linux-kernel, c.s.cheng, Kenny Cheng
The function 'task_in_memcg_oom' returns a 'struct mem_cgroup *' type.
If the compiler does not inline this function, a compile error occurs,
as shown below:
./include/linux/memcontrol.h:961:9: error: incompatible pointer to
integer conversion returning 'struct mem_cgroup *' from a function with
result type 'unsigned char' [-Wint-conversion]
This patch avoids the implicit type conversion by ensuring the return
type is correct.
Signed-off-by: Kenny Cheng <chao.shun.cheng.tw@gmail.com>
---
include/linux/memcontrol.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 5502aa8e138e..47acf1e4f5a7 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -1826,7 +1826,7 @@ bool mem_cgroup_oom_synchronize(bool wait);
static inline bool task_in_memcg_oom(struct task_struct *p)
{
- return p->memcg_in_oom;
+ return !!p->memcg_in_oom;
}
static inline void mem_cgroup_enter_user_fault(void)
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] mm: avoid implicit type conversion
2025-01-07 3:51 [PATCH] mm: avoid implicit type conversion Kenny Cheng
@ 2025-01-07 4:06 ` Al Viro
2025-01-07 5:48 ` Kenny Cheng
0 siblings, 1 reply; 3+ messages in thread
From: Al Viro @ 2025-01-07 4:06 UTC (permalink / raw)
To: Kenny Cheng
Cc: hannes, muchun.song, cgroups, linux-mm, linux-kernel, c.s.cheng
On Tue, Jan 07, 2025 at 11:51:41AM +0800, Kenny Cheng wrote:
> The function 'task_in_memcg_oom' returns a 'struct mem_cgroup *' type.
> If the compiler does not inline this function, a compile error occurs,
> as shown below:
>
> ./include/linux/memcontrol.h:961:9: error: incompatible pointer to
> integer conversion returning 'struct mem_cgroup *' from a function with
> result type 'unsigned char' [-Wint-conversion]
What does inlining have to do with anything? And where has unsigned
char come from in that?
> This patch avoids the implicit type conversion by ensuring the return
> type is correct.
>
> Signed-off-by: Kenny Cheng <chao.shun.cheng.tw@gmail.com>
> ---
> include/linux/memcontrol.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> index 5502aa8e138e..47acf1e4f5a7 100644
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -1826,7 +1826,7 @@ bool mem_cgroup_oom_synchronize(bool wait);
>
> static inline bool task_in_memcg_oom(struct task_struct *p)
> {
> - return p->memcg_in_oom;
> + return !!p->memcg_in_oom;
> }
That makes no sense. Do you have bool (or _Bool) defined or typedefed
to unsigned char somewhere? If so, that's the bug that needs to be
fixed.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] mm: avoid implicit type conversion
2025-01-07 4:06 ` Al Viro
@ 2025-01-07 5:48 ` Kenny Cheng
0 siblings, 0 replies; 3+ messages in thread
From: Kenny Cheng @ 2025-01-07 5:48 UTC (permalink / raw)
To: viro
Cc: c.s.cheng, cgroups, chao.shun.cheng.tw, hannes, linux-kernel,
linux-mm, muchun.song
> That makes no sense. Do you have bool (or _Bool) defined or typedefed
> to unsigned char somewhere? If so, that's the bug that needs to be
> fixed.
Yes, you're right!
It has defined in the other header file which is the root cause of
compiled error.
This patch can be ignored, thank you.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-01-07 5:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-07 3:51 [PATCH] mm: avoid implicit type conversion Kenny Cheng
2025-01-07 4:06 ` Al Viro
2025-01-07 5:48 ` Kenny Cheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox