Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
eendebakpt committed Feb 20, 2023
1 parent 8ca17f7 commit 4377b07
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Include/internal/pycore_abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ extern "C" {
# error "this header requires Py_BUILD_CORE define"
#endif

// Return 1 if 0 <= index < limit
// Return 1 if 0 <= index < limit and 0 otherwise
// The argument limit should be non-negative
static inline int _Py_is_valid_index(Py_ssize_t index, Py_ssize_t limit)
{
/* The cast to size_t lets us use just a single comparison
Expand All @@ -20,6 +21,7 @@ static inline int _Py_is_valid_index(Py_ssize_t index, Py_ssize_t limit)
The function is not affected by -fwrapv, -fno-wrapv and -ftrapv
compiler options of GCC and clang
*/
assert(limit >= 0);
return (size_t)index < (size_t)limit;
}

Expand Down

0 comments on commit 4377b07

Please sign in to comment.