nasa / bplib

Apache License 2.0
27 stars 13 forks source link

The bare "int" type has implementation-defined range #38

Open jphickey opened 4 years ago

jphickey commented 4 years ago

In struct definitions like:

https://github.com/nasa/bplib/blob/17d228c27ed93e1f3bf8b93091afa0319e3a6e28/inc/bplib.h#L184-L204

These use bare int types for many fields but this type has an implementation-defined range. There are still plenty of systems around where this might be only 16 bits. Consider using at least the int32_t (C99) type here, which should always be 32 bits and therefore have the expected range.

Furthermore, anywhere that this contains a size in bytes, such max_length in this struct and the size parameters to any of the API calls (i.e. bplib_store) these should use the system-provided size_t type instead. This is the preferred type to use anywhere that deals with the length or size of an object in memory, and the type that all system library calls accept for this as well.