10 Star 4 Fork 14

src-openEuler/vmtop

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
utils-del-realpath-from-read_file.patch 968 Bytes
一键复制 编辑 原始数据 按行查看 历史
alexchen 提交于 2021-03-16 20:04 . utils: del realpath from read_file
From 6f48c7f25e6db54941c110517ff25648d6287ec8 Mon Sep 17 00:00:00 2001
From: nocjj <[email protected]>
Date: Tue, 16 Mar 2021 20:04:32 +0800
Subject: [PATCH] utils: del realpath from read_file
Since the path in read_file is constructed by vmtop, there is no need
to use realpath to modify the path. So, del realpath to release cpu time.
Signed-off-by: nocjj <[email protected]>
---
src/utils.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/utils.c b/src/utils.c
index 3cb1146..29de9c9 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -24,12 +24,11 @@ int read_file(char *buf, int bufsize, const char *path)
{
int fd;
int len;
- char mpath[PATH_MAX];
- if (strlen(path) > PATH_MAX - 1 || realpath(path, mpath) == NULL) {
+ if (strlen(path) > PATH_MAX - 1) {
return -1;
}
- fd = open(mpath, O_RDONLY, 0);
+ fd = open(path, O_RDONLY, 0);
if (fd == -1) {
return -1;
}
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/vmtop.git
[email protected]:src-openeuler/vmtop.git
src-openeuler
vmtop
vmtop
master

搜索帮助