node
node copied to clipboard
test: check that sysconf returns a positive value
Static analysis insists that sysconf(_SC_PAGE_SIZE)
might return a negative integer (even though it never will). This was supposed to be handled by the existing check EXPECT_GE(page, static_cast<int>(N))
. I assume that static analysis does not consider this sufficient because static_cast<int>(N)
could be negative or zero if N
exceeds INT_MAX
(even though it never will).
To resolve this (theoretical) problem, explicitly check that the return value is positive and then cast it to a size_t
.
CI: https://ci.nodejs.org/job/node-test-pull-request/46625/
CI: https://ci.nodejs.org/job/node-test-pull-request/46629/
cc @nodejs/cpp-reviewers
@RaisinTen Thanks for reviewing!
Does coverity pick up static asserts?
Good point, it probably would. Either way, size_t
is the semantically correct type here so I'm happy to get rid of int
:)
Landed in 3492320fddf28e15d45b842014549a9ae7dc6ded
@RaisinTen Huh, this did not work -- coverity found a new issue. I just realized that EXPECT_*
is non-fatal, so that is likely the problem. We can't use ASSERT_*
though, so I'll try CHECK_*
instead.
Edit: See https://github.com/nodejs/node/pull/44795.