Re: [PATCH] drm/drm_vblank.c: avoid unsigned int to signed int cast

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

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 sure about this,

but there are plenty unsigned types arithmetic in the kernel.

take kmalloc_array() function as an example in /tools/virto/linux/kernel.h


static inline void *kmalloc_array(unsigned n, size_t s, gfp_t gfp)
{
    return kmalloc(n * s, gfp);
}


NOTE that *size_t* is an unsigned integral data type.




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux