From: Celeste Liu <coelacanthushex@gmail.com>
To: "Björn Töpel" <bjorn@kernel.org>, "Andreas Schwab" <schwab@suse.de>
Cc: "Palmer Dabbelt" <palmer@rivosinc.com>,
"Paul Walmsley" <paul.walmsley@sifive.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Guo Ren" <guoren@kernel.org>, "Björn Töpel" <bjorn@rivosinc.com>,
"Conor Dooley" <conor.dooley@microchip.com>,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
"Felix Yan" <felixonmars@archlinux.org>,
"Ruizhe Pan" <c141028@gmail.com>,
"Shiqi Zhang" <shiqi@isrc.iscas.ac.cn>
Subject: Re: [PATCH v3] riscv: entry: set a0 = -ENOSYS only when syscall != -1
Date: Fri, 21 Jul 2023 03:24:08 +0800 [thread overview]
Message-ID: <A6169D45-D291-40DF-BC78-42AE4F7A5924@gmail.com> (raw)
In-Reply-To: <87wmyvq7ai.fsf@all.your.base.are.belong.to.us>
On July 20, 2023 5:08:37 PM GMT+08:00, "Björn Töpel" <bjorn@kernel.org> wrote:
>Celeste Liu <coelacanthushex@gmail.com> writes:
>
>> On July 20, 2023 12:28:47 AM GMT+08:00, "Björn Töpel" <bjorn@kernel.org> wrote:
>>>Andreas Schwab <schwab@suse.de> writes:
>>>
>>>> On Jul 19 2023, Celeste Liu wrote:
>>>>
>>>>> @@ -308,7 +312,7 @@ asmlinkage __visible __trap_section void do_trap_ecall_u(struct pt_regs *regs)
>>>>>
>>>>> if (syscall < NR_syscalls)
>>>>> syscall_handler(regs, syscall);
>>>>> - else
>>>>> + else if ((long)syscall != -1L)
>>>>
>>>> You can also use syscall != -1UL or even syscall != -1.
>>>
>>>The former is indeed better for the eyes! :-) The latter will get a
>>>-Wsign-compare warning, no?
>>>
>>>
>>>Björn
>>
>> Well, that's true. And I just found out that by C standards, converting
>> ulong to long is implementation-defined behavior, unlike long to ulong
>> which is well-defined. So it is really better than (long)syscall != -1L.
>
>If you're respinning, I suggest you use David's suggestion:
> * Remove the comment I suggest you to add
> * Use (signed) long
> * Add syscall >= 0 &&
> * else if (syscall != -1)
>
>Which is the least amount of surprises IMO.
v4 has sent
prev parent reply other threads:[~2023-07-20 19:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-18 20:57 Celeste Liu
2023-07-18 21:20 ` Björn Töpel
2023-07-18 23:40 ` Guo Ren
2023-07-19 13:13 ` David Laight
2023-07-19 7:21 ` Andreas Schwab
2023-07-19 16:28 ` Björn Töpel
2023-07-20 6:46 ` Celeste Liu
2023-07-20 9:08 ` Björn Töpel
2023-07-20 19:24 ` Celeste Liu [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=A6169D45-D291-40DF-BC78-42AE4F7A5924@gmail.com \
--to=coelacanthushex@gmail.com \
--cc=aou@eecs.berkeley.edu \
--cc=bjorn@kernel.org \
--cc=bjorn@rivosinc.com \
--cc=c141028@gmail.com \
--cc=conor.dooley@microchip.com \
--cc=felixonmars@archlinux.org \
--cc=guoren@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@rivosinc.com \
--cc=paul.walmsley@sifive.com \
--cc=schwab@suse.de \
--cc=shiqi@isrc.iscas.ac.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
all inboxes | Powered by JetHome®