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

