From 370c793becb4c9cd0779023e8a8b6cac99b3c4eb Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Wed, 5 Jun 2024 11:15:18 +0800 Subject: [PATCH 1/2] feat: if command pass host port , json file had been ignored --- src/benchJsonOpt.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/benchJsonOpt.c b/src/benchJsonOpt.c index 45f10b83..15227c17 100644 --- a/src/benchJsonOpt.c +++ b/src/benchJsonOpt.c @@ -1390,12 +1390,20 @@ static int getMetaFromCommonJsonFile(tools_cJSON *json) { tools_cJSON *host = tools_cJSON_GetObjectItem(json, "host"); if (host && host->type == tools_cJSON_String && host->valuestring != NULL) { - g_arguments->host = host->valuestring; + if(g_arguments->host && strlen(g_arguments->host) > 0) { + warnPrint("command line already pass host is %s, json config host had been ignored.\n", g_arguments->host); + } else { + g_arguments->host = host->valuestring; + } } tools_cJSON *port = tools_cJSON_GetObjectItem(json, "port"); if (port && port->type == tools_cJSON_Number) { - g_arguments->port = (uint16_t)port->valueint; + if(g_arguments->port != DEFAULT_PORT) { + warnPrint("command line already pass port is %d, json config port had been ignored.\n", g_arguments->port); + } else { + g_arguments->port = (uint16_t)port->valueint; + } } tools_cJSON *user = tools_cJSON_GetObjectItem(json, "user"); From 47db1ed8ffb4d0523aa35714cdc789ea6320bcca Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Wed, 5 Jun 2024 11:39:10 +0800 Subject: [PATCH 2/2] fix: add json value tips --- src/benchJsonOpt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/benchJsonOpt.c b/src/benchJsonOpt.c index 15227c17..f458b663 100644 --- a/src/benchJsonOpt.c +++ b/src/benchJsonOpt.c @@ -1391,7 +1391,7 @@ static int getMetaFromCommonJsonFile(tools_cJSON *json) { tools_cJSON *host = tools_cJSON_GetObjectItem(json, "host"); if (host && host->type == tools_cJSON_String && host->valuestring != NULL) { if(g_arguments->host && strlen(g_arguments->host) > 0) { - warnPrint("command line already pass host is %s, json config host had been ignored.\n", g_arguments->host); + warnPrint("command line already pass host is %s, json config host(%s) had been ignored.\n", g_arguments->host, host->valuestring); } else { g_arguments->host = host->valuestring; } @@ -1400,7 +1400,7 @@ static int getMetaFromCommonJsonFile(tools_cJSON *json) { tools_cJSON *port = tools_cJSON_GetObjectItem(json, "port"); if (port && port->type == tools_cJSON_Number) { if(g_arguments->port != DEFAULT_PORT) { - warnPrint("command line already pass port is %d, json config port had been ignored.\n", g_arguments->port); + warnPrint("command line already pass port is %d, json config port(%d) had been ignored.\n", g_arguments->port, (uint16_t)port->valueint); } else { g_arguments->port = (uint16_t)port->valueint; }