[vlc-devel] [PATCH] modules: use 16-bit ints for option counts

Rémi Denis-Courmont remi at remlab.net
Sun Sep 27 20:56:25 CEST 2020


Le sunnuntaina 27. syyskuuta 2020, 21.38.08 EEST Lyndon Brown a écrit :
> On Sun, 2020-09-27 at 09:27 +0300, Rémi Denis-Courmont wrote:
> > No. size_t is the specified type for byte and array size in C.
> 
> Sorry? Where does the C standard define that size_t is the one and only
> correct type to use whenever handling/storing array sizes?

It's the result type of the sizeof(), and thus of our own ARRAY_SIZE() macro.

> But I don't see any reason for holding us back from using only the
> storage space that we actually require here.

VLC is not kernel code where very last byte matters. Readability and 
maintainability is more important. And compared to the bytes wasted in, say, 
picture buffer padding, this is negligible.

> We don't need more than two bytes per count here, ever.

In reasonable cases. But in pathological cases, this patch is broken as it 
lacks error handling. Meanwhile, with size_t, we know overflow is impossible.

-- 
レミ・デニ-クールモン
http://www.remlab.net/





More information about the vlc-devel mailing list