main: assert supported integer size, representation and conversion
Abort immediately on start if chronyd is compiled on a platform with int shorter than 32 bits, using other representation than two's complement, or unexpected conversion of large unsigned integers to signed.
This commit is contained in:
parent
8e71a46173
commit
bafb434f06
1 changed files with 14 additions and 0 deletions
14
main.c
14
main.c
|
@ -68,6 +68,18 @@ static REF_Mode ref_mode = REF_ModeNormal;
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
|
static void
|
||||||
|
do_platform_checks(void)
|
||||||
|
{
|
||||||
|
/* Require at least 32-bit integers, two's complement representation and
|
||||||
|
the usual implementation of conversion of unsigned integers */
|
||||||
|
assert(sizeof (int) >= 4);
|
||||||
|
assert(-1 == ~0);
|
||||||
|
assert((int32_t)4294967295 == (int32_t)-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
delete_pidfile(void)
|
delete_pidfile(void)
|
||||||
{
|
{
|
||||||
|
@ -351,6 +363,8 @@ int main
|
||||||
int system_log = 1;
|
int system_log = 1;
|
||||||
int config_args = 0;
|
int config_args = 0;
|
||||||
|
|
||||||
|
do_platform_checks();
|
||||||
|
|
||||||
LOG_Initialise();
|
LOG_Initialise();
|
||||||
|
|
||||||
/* Parse command line options */
|
/* Parse command line options */
|
||||||
|
|
Loading…
Reference in a new issue