linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: Kenny Cheng <chao.shun.cheng.tw@gmail.com>
Cc: hannes@cmpxchg.org, muchun.song@linux.dev,
	cgroups@vger.kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, c.s.cheng@realtek.com
Subject: Re: [PATCH] mm: avoid implicit type conversion
Date: Tue, 7 Jan 2025 04:06:31 +0000	[thread overview]
Message-ID: <20250107040631.GN1977892@ZenIV> (raw)
In-Reply-To: <20250107035141.2858582-1-chao.shun.cheng.tw@gmail.com>

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.


  reply	other threads:[~2025-01-07  4:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-07  3:51 Kenny Cheng
2025-01-07  4:06 ` Al Viro [this message]
2025-01-07  5:48   ` Kenny Cheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250107040631.GN1977892@ZenIV \
    --to=viro@zeniv.linux.org.uk \
    --cc=c.s.cheng@realtek.com \
    --cc=cgroups@vger.kernel.org \
    --cc=chao.shun.cheng.tw@gmail.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=muchun.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox