mirror of
https://github.com/python/cpython.git
synced 2025-09-15 13:16:12 +00:00
bpo-31338 (#3374)
* Add Py_UNREACHABLE() as an alias to abort(). * Use Py_UNREACHABLE() instead of assert(0) * Convert more unreachable code to use Py_UNREACHABLE() * Document Py_UNREACHABLE() and a few other macros.
This commit is contained in:
parent
d384a81f55
commit
b2e5794870
22 changed files with 128 additions and 111 deletions
|
@ -630,10 +630,7 @@ _PyTime_GetSystemClock(void)
|
|||
_PyTime_t t;
|
||||
if (pygettimeofday(&t, NULL, 0) < 0) {
|
||||
/* should not happen, _PyTime_Init() checked the clock at startup */
|
||||
assert(0);
|
||||
|
||||
/* use a fixed value instead of a random value from the stack */
|
||||
t = 0;
|
||||
Py_UNREACHABLE();
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
@ -663,7 +660,7 @@ pymonotonic(_PyTime_t *tp, _Py_clock_info_t *info, int raise)
|
|||
return -1;
|
||||
}
|
||||
/* Hello, time traveler! */
|
||||
assert(0);
|
||||
Py_UNREACHABLE();
|
||||
}
|
||||
*tp = t * MS_TO_NS;
|
||||
|
||||
|
@ -771,10 +768,7 @@ _PyTime_GetMonotonicClock(void)
|
|||
if (pymonotonic(&t, NULL, 0) < 0) {
|
||||
/* should not happen, _PyTime_Init() checked that monotonic clock at
|
||||
startup */
|
||||
assert(0);
|
||||
|
||||
/* use a fixed value instead of a random value from the stack */
|
||||
t = 0;
|
||||
Py_UNREACHABLE();
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue