Merge pull request #2872 from elindsey:master

PiperOrigin-RevId: 320224740
This commit is contained in:
Gennadiy Rozental 2020-07-09 13:35:44 -04:00
commit c7f05e08af

View File

@ -198,7 +198,8 @@ size_t GetThreadCount() {
if (sysctl(mib, miblen, NULL, &size, NULL, 0)) { if (sysctl(mib, miblen, NULL, &size, NULL, 0)) {
return 0; return 0;
} }
mib[5] = size / mib[4];
mib[5] = static_cast<int>(size / static_cast<size_t>(mib[4]));
// populate array of structs // populate array of structs
struct kinfo_proc info[mib[5]]; struct kinfo_proc info[mib[5]];
@ -207,8 +208,8 @@ size_t GetThreadCount() {
} }
// exclude empty members // exclude empty members
int nthreads = 0; size_t nthreads = 0;
for (size_t i = 0; i < size / mib[4]; i++) { for (size_t i = 0; i < size / static_cast<size_t>(mib[4]); i++) {
if (info[i].p_tid != -1) if (info[i].p_tid != -1)
nthreads++; nthreads++;
} }