提交 f843a22b 编写于 作者: H hjxilinx

[td-98]fix uninitialised value access warning by valgrind

上级 54f28dc5
......@@ -14,13 +14,12 @@
*/
#include "os.h"
#include <locale.h>
#include "taosdef.h"
#include "taoserror.h"
#include "tglobalcfg.h"
#include "tkey.h"
#include "tlog.h"
#include "taosdef.h"
#include "taoserror.h"
#include "tsocket.h"
#include "tsystem.h"
#include "tutil.h"
......@@ -833,9 +832,8 @@ void tsReadGlobalLogConfig() {
FILE * fp;
char * line, *option, *value;
size_t len;
int olen, vlen;
char fileName[128];
char fileName[PATH_MAX] = {0};
mdebugFlag = 135;
sdbDebugFlag = 135;
......@@ -851,27 +849,30 @@ void tsReadGlobalLogConfig() {
wordfree(&full_path);
tsReadLogOption("logDir", logDir);
sprintf(fileName, "%s/taos.cfg", configDir);
fp = fopen(fileName, "r");
if (fp == NULL) {
printf("\noption file:%s not found, all options are set to system default\n", fileName);
printf("\nconfig file:%s not found, all variables are set to default\n", fileName);
return;
}
line = NULL;
size_t len = 1024;
line = calloc(1, len);
while (!feof(fp)) {
tfree(line);
line = option = value = NULL;
len = olen = vlen = 0;
memset(line, 0, len);
option = value = NULL;
olen = vlen = 0;
getline(&line, &len, fp);
if (line == NULL) break;
paGetToken(line, &option, &olen);
paGetToken(line, len, &option, &olen);
if (olen == 0) continue;
option[olen] = 0;
paGetToken(option + olen + 1, &value, &vlen);
paGetToken(option + olen + 1, len, &value, &vlen);
if (vlen == 0) continue;
value[vlen] = 0;
......@@ -885,44 +886,45 @@ void tsReadGlobalLogConfig() {
bool tsReadGlobalConfig() {
tsInitGlobalConfig();
FILE * fp;
char * line, *option, *value, *value1;
size_t len;
int olen, vlen, vlen1;
char fileName[128];
char fileName[PATH_MAX] = {0};
sprintf(fileName, "%s/taos.cfg", configDir);
fp = fopen(fileName, "r");
if (fp == NULL) {
} else {
line = NULL;
FILE* fp = fopen(fileName, "r");
size_t len = 1024;
line = calloc(1, len);
if (fp != NULL) {
while (!feof(fp)) {
tfree(line);
line = option = value = NULL;
len = olen = vlen = 0;
memset(line, 0, len);
option = value = NULL;
olen = vlen = 0;
getline(&line, &len, fp);
if (line == NULL) break;
paGetToken(line, &option, &olen);
paGetToken(line, len, &option, &olen);
if (olen == 0) continue;
option[olen] = 0;
paGetToken(option + olen + 1, &value, &vlen);
paGetToken(option + olen + 1, len, &value, &vlen);
if (vlen == 0) continue;
value[vlen] = 0;
// For dataDir, the format is:
// dataDir /mnt/disk1 0
paGetToken(value + vlen + 1, &value1, &vlen1);
paGetToken(value + vlen + 1, len, &value1, &vlen1);
tsReadConfigOption(option, value);
}
tfree(line);
fclose(fp);
}
tfree(line);
if (tsReadStorageConfig) {
tsReadStorageConfig();
}
......@@ -976,6 +978,7 @@ bool tsReadGlobalConfig() {
strcpy(tsLocalIp, tsPrivateIp);
}
// todo refactor
tsVersion = 0;
for (int i = 0; i < 10; i++) {
if (version[i] >= '0' && version[i] <= '9') {
......@@ -984,6 +987,7 @@ bool tsReadGlobalConfig() {
break;
}
}
tsVersion = 10 * tsVersion;
return true;
......@@ -994,10 +998,11 @@ int tsCfgDynamicOptions(char *msg) {
int olen, vlen, code = 0;
int vint = 0;
paGetToken(msg, &option, &olen);
size_t len = 120;
paGetToken(msg, len, &option, &olen);
if (olen == 0) return TSDB_CODE_INVALID_MSG_CONTENT;
paGetToken(option + olen + 1, &value, &vlen);
paGetToken(option + olen + 1, len, &value, &vlen);
if (vlen == 0)
vint = 135;
else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册