10 Star 4 Fork 14

src-openEuler/vmtop

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
bugfix-check-unsigned-number-flip-before-getting-del.patch 1.75 KB
一键复制 编辑 原始数据 按行查看 历史
nocjj 提交于 2020-09-21 11:55 . spec: Update release and changelog
From 4eb3e65353484c6c5cf81046d7b2296151ef3b83 Mon Sep 17 00:00:00 2001
From: nocjj <[email protected]>
Date: Sat, 19 Sep 2020 14:48:06 +0800
Subject: [PATCH 4/4] bugfix: check unsigned number flip before getting delta
Sometimes, a very large number will appear in EXTxxx display items.
The reason of this phenomenon is that we do not check the size of
two unsigned numbers before getting delta value of them,
which will cause unsigned number flip.
So add check before getting delta value.
Signed-off-by: Jiajun Chen <[email protected]>
---
src/type.h | 6 +++++-
src/vmtop.c | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/type.h b/src/type.h
index 85edc52..0e92388 100644
--- a/src/type.h
+++ b/src/type.h
@@ -42,7 +42,11 @@ typedef unsigned long long u64;
static inline void DELTA_NAME(v)(struct domain *new, \
struct domain *old) \
{ \
- new->DELTA_VALUE(v) = new->v - old->v; \
+ if (new->v >= old->v) { \
+ new->DELTA_VALUE(v) = new->v - old->v; \
+ } else { \
+ new->DELTA_VALUE(v) = old->DELTA_VALUE(v); \
+ } \
}
#define SUM_NAME(v) domain_sum_ ## v
diff --git a/src/vmtop.c b/src/vmtop.c
index 18d3010..7a1b19b 100644
--- a/src/vmtop.c
+++ b/src/vmtop.c
@@ -250,7 +250,7 @@ static void show_task(struct domain *task)
int showd_field = 0;
showd_task++;
if (showd_task < begin_task ||
- showd_task - begin_task > scr_row_size - 4) {
+ showd_task - begin_task > scr_row_size - 5) {
return;
}
clrtoeol();
--
2.23.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/vmtop.git
[email protected]:src-openeuler/vmtop.git
src-openeuler
vmtop
vmtop
master

搜索帮助