diff options
author | Ludovic Henry <luhenry@microsoft.com> | 2019-04-05 14:07:57 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-05 14:07:57 -0700 |
commit | 98d2b480ff9fc207f568ed2ac8dcbcb7c9d6a719 (patch) | |
tree | ccb796867c463792012596bc5bbd18197bad68bf /src/pal/src | |
parent | 5b9db5fcd995b52fda09aff38ae42e75f48f8dfa (diff) | |
download | coreclr-98d2b480ff9fc207f568ed2ac8dcbcb7c9d6a719.tar.gz coreclr-98d2b480ff9fc207f568ed2ac8dcbcb7c9d6a719.tar.bz2 coreclr-98d2b480ff9fc207f568ed2ac8dcbcb7c9d6a719.zip |
Fix rounding to UINT32_MAX (#23764)
In case you would have UINT32_MAX - 1 CPUs, you would round up to return UINT32_MAX CPUs.
Diffstat (limited to 'src/pal/src')
-rw-r--r-- | src/pal/src/misc/cgroup.cpp | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/pal/src/misc/cgroup.cpp b/src/pal/src/misc/cgroup.cpp index 97b2cb287c..2018df4eda 100644 --- a/src/pal/src/misc/cgroup.cpp +++ b/src/pal/src/misc/cgroup.cpp @@ -107,16 +107,9 @@ public: return true; } - cpu_count = (double) quota / period; - if (cpu_count < UINT_MAX - 1) - { - // round up - *val = (UINT)(cpu_count + 0.999999999); - } - else - { - *val = UINT_MAX; - } + // Calculate cpu count based on quota and round it up + cpu_count = (double) quota / period + 0.999999999; + *val = (cpu_count < UINT_MAX) ? (UINT)cpu_count : UINT_MAX; return true; } |