From: Peter Zijlstra <peterz@infradead.org>
To: cgel.zte@gmail.com
Cc: jpoimboe@redhat.com, jbaron@akamai.com, rostedt@goodmis.org,
ardb@kernel.org, tglx@linutronix.de, mingo@redhat.com,
bp@alien8.de, x86@kernel.org, hpa@zytor.com,
linux-kernel@vger.kernel.org, Yang Guang <yang.guang5@zte.com.cn>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH] Fix the bool convert to int issue
Date: Sat, 18 Sep 2021 10:20:20 +0200 [thread overview]
Message-ID: <20210918082020.GL4323@worktop.programming.kicks-ass.net> (raw)
In-Reply-To: <20210918073037.239634-1-yang.guang5@zte.com.cn>
On Sat, Sep 18, 2021 at 07:30:37AM +0000, cgel.zte@gmail.com wrote:
> From: Yang Guang <yang.guang5@zte.com.cn>
>
> The int value which convert from bool true is 0xFFFFFFFF. Causing the
> __sc_insn return wrong type.
Aaah, this is where the insanity starts...
My copy of the C spec says:
"When any scalar value is converted to _Bool, the result is 0 if the
value compares equal to 0; otherwise, the result is 1."
What does yours say?
Also, did your kernel boot? If what you say is right it would've gone up
in flames a long time ago.
Please, learn C _before_ sending patches.
*plonk*
>
> Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
> ---
> arch/x86/kernel/static_call.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/static_call.c b/arch/x86/kernel/static_call.c
> index ea028e736831..f608e6710300 100644
> --- a/arch/x86/kernel/static_call.c
> +++ b/arch/x86/kernel/static_call.c
> @@ -89,7 +89,7 @@ static inline enum insn_type __sc_insn(bool null, bool tail)
> * 1 | 0 | JMP
> * 1 | 1 | RET
> */
> - return 2*tail + null;
> + return ((tail)?2:0) + ((null)?1:0);
> }
>
> void arch_static_call_transform(void *site, void *tramp, void *func, bool tail)
> --
> 2.25.1
>
prev parent reply other threads:[~2021-09-18 8:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-18 7:30 [PATCH] Fix the bool convert to int issue cgel.zte
2021-09-18 8:20 ` Peter Zijlstra [this message]
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=20210918082020.GL4323@worktop.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=cgel.zte@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=jbaron@akamai.com \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=yang.guang5@zte.com.cn \
/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