1 Star 0 Fork 32

Ren Zhijie/gazelle

forked from src-openEuler/gazelle 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0107-ltran-optimize-config-file-error-message.patch 1.63 KB
一键复制 编辑 原始数据 按行查看 历史
From e46c71fda9678df02d7373a1bb987cbc3979f1f6 Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Fri, 5 Jan 2024 18:07:42 +0800
Subject: [PATCH] ltran: optimize config file error message
---
src/ltran/ltran_param.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/ltran/ltran_param.c b/src/ltran/ltran_param.c
index 11a4bc8..1eaace4 100644
--- a/src/ltran/ltran_param.c
+++ b/src/ltran/ltran_param.c
@@ -664,8 +664,15 @@ struct param_parser g_param_parse_tbl[] = {
int32_t parse_config_file_args(const char *conf_file_path, struct ltran_config *ltran_config)
{
config_t config;
- config_init(&config);
int32_t ret;
+ char real_path[PATH_MAX];
+
+ if (realpath(conf_file_path, real_path) == NULL) {
+ syslog(LOG_ERR, "Err: Config file path %s error, please check conf file path.\n", conf_file_path);
+ return -1;
+ }
+
+ config_init(&config);
ret = memset_s(ltran_config, sizeof(struct ltran_config), 0, sizeof(struct ltran_config));
if (ret != 0) {
@@ -673,10 +680,10 @@ int32_t parse_config_file_args(const char *conf_file_path, struct ltran_config *
syslog(LOG_ERR, "memset_s failed\n");
return ret;
}
- ret = config_read_file(&config, conf_file_path);
+ ret = config_read_file(&config, real_path);
if (ret == 0) {
+ syslog(LOG_ERR, "Err: Read config file \"%s\" error: %s\n", real_path, config_error_text(&config));
config_destroy(&config);
- syslog(LOG_ERR, "Err: Config file path %s error, please check conf file path.\n", conf_file_path);
return -GAZELLE_EPATH;
}
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/byterzj/gazelle.git
git@gitee.com:byterzj/gazelle.git
byterzj
gazelle
gazelle
master

搜索帮助