15 Star 2 Fork 56

src-openEuler/util-linux

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-lib-cpuset-exit-early-from-cpulist_parse.patch 1.14 KB
一键复制 编辑 原始数据 按行查看 历史
zhangyao2022 提交于 2024-11-15 16:22 . sync patches from the old version
From 566b1d348897a34016653d6de040688a2c0a136c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= <thomas@t-8ch.de>
Date: Thu, 1 Feb 2024 20:09:41 +0100
Subject: [PATCH] lib/cpuset: exit early from cpulist_parse
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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 <thomas@t-8ch.de>
Reference:https://github.com/util-linux/util-linux/commit/566b1d348897a34016653d6de040688a2c0a136c
Conflict:NA
---
lib/cpuset.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/cpuset.c b/lib/cpuset.c
index 643537f6d..533b8ab30 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;
}
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/util-linux.git
git@gitee.com:src-openeuler/util-linux.git
src-openeuler
util-linux
util-linux
master

搜索帮助