From: Jiri Slaby <jirislaby@kernel.org>
To: David Laight <David.Laight@ACULAB.COM>,
Hugo Villeneuve <hugo@hugovil.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jon Ringle <jringle@gridpoint.com>
Cc: "ria.freelander@gmail.com" <ria.freelander@gmail.com>,
Hugo Villeneuve <hvilleneuve@dimonoff.com>,
"stable@vger.kernel.org" <stable@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-serial@vger.kernel.org" <linux-serial@vger.kernel.org>
Subject: Re: [PATCH] serial: sc16is7xx: fix bug in sc16is7xx_set_baud() when using prescaler
Date: Tue, 30 Apr 2024 07:24:52 +0200 [thread overview]
Message-ID: <bf313102-e949-41d9-89f3-bff06a43d647@kernel.org> (raw)
In-Reply-To: <6ea689ace38d47f285efe026772efcae@AcuMS.aculab.com>
On 29. 04. 24, 11:14, David Laight wrote:
> From: Jiri Slaby
>> Sent: 29 April 2024 07:39
> ...
>>> - u8 prescaler = 0;
>>> + int prescaler = 1;
>>
>> Ugh, why do you move to signed arithmetics?
>
> Any arithmetic would always have been signed.
> u8 is promoted to 'signed int' before being used for pretty much anything.
Sorry, what?
C99 §6.3.8.1 states:
If both operands have the same type, then no further conversion is needed.
Otherwise, if both operands have signed integer types or both have
unsigned integer types, the operand with the type of lesser integer
conversion rank is converted to the type of the operand with greater rank.
=====
I.e. u8 is converted according to that to ulong in this case. So
unsigned arithmetic happens.
> 'unsigned int prescaler' might have changed arithmetic to be unsigned.
The same as u8.
> OTOH you probably don't want a u8 - that might require the compiler
> mask an arithmetic result to 8 bits.
Pardon? Not at all.
Am I missing something?
thanks,
--
js
suse labs
next prev parent reply other threads:[~2024-04-30 5:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-26 13:59 [PATCH] serial: sc16is7xx: fix bug in sc16is7xx_set_baud() when using prescaler Hugo Villeneuve
2024-04-26 14:10 ` Konstantin P.
2024-04-29 6:39 ` Jiri Slaby
2024-04-29 9:14 ` David Laight
2024-04-30 5:24 ` Jiri Slaby [this message]
2024-04-29 13:47 ` Hugo Villeneuve
2024-04-30 5:22 ` Jiri Slaby
2024-04-30 12:59 ` Hugo Villeneuve
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=bf313102-e949-41d9-89f3-bff06a43d647@kernel.org \
--to=jirislaby@kernel.org \
--cc=David.Laight@ACULAB.COM \
--cc=gregkh@linuxfoundation.org \
--cc=hugo@hugovil.com \
--cc=hvilleneuve@dimonoff.com \
--cc=jringle@gridpoint.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=ria.freelander@gmail.com \
--cc=stable@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).