1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-02-26 09:57:26 +03:00

CODING_STYLE: elaborate on usage of C99 fixed size integer types

This commit is contained in:
Lennart Poettering 2015-11-09 23:47:16 +01:00
parent 9905e698b4
commit fa195fa775

View File

@ -145,11 +145,15 @@
- Think about the types you use. If a value cannot sensibly be - Think about the types you use. If a value cannot sensibly be
negative, do not use "int", but use "unsigned". negative, do not use "int", but use "unsigned".
- Do not use types like "short". They *never* make sense. Use ints, - Use "char" only for actual characters. Use "uint8_t" or "int8_t"
longs, long longs, all in unsigned+signed fashion, and the fixed when you actually mean a byte-sized signed or unsigned
size types uint32_t and so on, as well as size_t, but nothing integers. When referring to a generic byte, we generally prefer the
else. Do not use kernel types like u32 and so on, leave that to the unsigned variant "uint8_t". Do not use types based on "short". They
kernel. *never* make sense. Use ints, longs, long longs, all in
unsigned+signed fashion, and the fixed size types
uint8_t/uint16_t/uint32_t/uint64_t/int8_t/int16_t/int32_t and so on,
as well as size_t, but nothing else. Do not use kernel types like
u32 and so on, leave that to the kernel.
- Public API calls (i.e. functions exported by our shared libraries) - Public API calls (i.e. functions exported by our shared libraries)
must be marked "_public_" and need to be prefixed with "sd_". No must be marked "_public_" and need to be prefixed with "sd_". No