From: Thomas Weißschuh Date: Thu, 1 Feb 2024 19:09:41 +0000 (+0100) Subject: lib/cpuset: exit early from cpulist_parse X-Git-Tag: v2.41-start~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=566b1d348897a34016653d6de040688a2c0a136c;p=thirdparty%2Futil-linux.git lib/cpuset: exit early from cpulist_parse If `a` exceeds `max`, any increment of `a` will also `exceed` max. In this case the CPU_SET_S will never do anything all additional loops are wasted. Fixes #2748 Signed-off-by: Thomas Weißschuh --- diff --git a/lib/cpuset.c b/lib/cpuset.c index 643537f6d9..533b8ab309 100644 --- a/lib/cpuset.c +++ b/lib/cpuset.c @@ -326,8 +326,12 @@ int cpulist_parse(const char *str, cpu_set_t *set, size_t setsize, int fail) if (!(a <= b)) return 1; while (a <= b) { - if (fail && (a >= max)) - return 2; + if (a >= max) { + if (fail) + return 2; + else + break; + } CPU_SET_S(a, setsize, set); a += s; }