From: Sui Jingfeng <15330273260@189.cn>
To: David Laight <David.Laight@ACULAB.COM>,
Jani Nikula <jani.nikula@linux.intel.com>,
Sui Jingfeng <suijingfeng@loongson.cn>, Li Yi <liyi@loongson.cn>
Cc: Thomas Zimmermann <tzimmermann@suse.de>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"loongson-kernel@lists.loongnix.cn"
<loongson-kernel@lists.loongnix.cn>
Subject: Re: [PATCH] drm/drm_vblank.c: avoid unsigned int to signed int cast
Date: Tue, 23 May 2023 17:55:39 +0800 [thread overview]
Message-ID: <ed008264-e72e-7548-d93e-f7f4130ef2c2@189.cn> (raw)
In-Reply-To: <e5effc4568034489acf2f4d4dad6eba9@AcuMS.aculab.com>
Hi,
On 2023/5/23 16:50, David Laight wrote:
> From: 15330273260@189.cn <15330273260@189.cn>
>> Sent: 23 May 2023 05:27
>>
>> On 2023/5/22 19:29, Jani Nikula wrote:
>>> In general, do not use unsigned types in arithmethic to avoid negative
>>> values, because most people will be tripped over by integer promotion
>>> rules, and you'll get negative values anyway.
>>
>> Here I'm not sure about this,
>>
>> but there are plenty unsigned types arithmetic in the kernel.
> The real problem is (attempted) arithmetic on types smaller than int.
> Regardless of whether they are signed or unsigned.
It is about sign extend.
Yes, you may be right. I might create a wrong patch.
But this will not happen in practice, because in general case:
mode->crtc_htotal < 0x8fff;
mode->crtc_vtotal < 0x8fff;
u16 gets promoted to 'signed int' not 'unsigned int'.
Sorry :/
> David
>
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2023-05-23 9:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-16 17:30 Sui Jingfeng
2023-05-17 10:59 ` David Laight
2023-05-17 18:08 ` Sui Jingfeng
2023-05-22 11:29 ` Jani Nikula
2023-05-22 11:55 ` Sui Jingfeng
2023-05-22 12:07 ` David Laight
2023-05-22 12:13 ` Jani Nikula
2023-05-22 12:53 ` Sui Jingfeng
2023-05-22 15:01 ` Jani Nikula
2023-05-23 3:55 ` Sui Jingfeng
2023-05-23 4:26 ` Sui Jingfeng
2023-05-23 8:12 ` Sui Jingfeng
2023-05-23 8:50 ` David Laight
2023-05-23 9:55 ` Sui Jingfeng [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-05-16 16:59 Sui Jingfeng
2023-05-16 17:06 ` Thomas Zimmermann
2023-05-16 17:13 ` Sui Jingfeng
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=ed008264-e72e-7548-d93e-f7f4130ef2c2@189.cn \
--to=15330273260@189.cn \
--cc=David.Laight@ACULAB.COM \
--cc=dri-devel@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=liyi@loongson.cn \
--cc=loongson-kernel@lists.loongnix.cn \
--cc=suijingfeng@loongson.cn \
--cc=tzimmermann@suse.de \
/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®