[td-98]fix uninitialised value access warning by valgrind
This commit is contained in:
parent
54f28dc5f3
commit
f843a22bb8
|
@ -14,13 +14,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include <locale.h>
|
|
||||||
|
|
||||||
|
#include "taosdef.h"
|
||||||
|
#include "taoserror.h"
|
||||||
#include "tglobalcfg.h"
|
#include "tglobalcfg.h"
|
||||||
#include "tkey.h"
|
#include "tkey.h"
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
#include "taosdef.h"
|
|
||||||
#include "taoserror.h"
|
|
||||||
#include "tsocket.h"
|
#include "tsocket.h"
|
||||||
#include "tsystem.h"
|
#include "tsystem.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
|
@ -833,9 +832,8 @@ void tsReadGlobalLogConfig() {
|
||||||
|
|
||||||
FILE * fp;
|
FILE * fp;
|
||||||
char * line, *option, *value;
|
char * line, *option, *value;
|
||||||
size_t len;
|
|
||||||
int olen, vlen;
|
int olen, vlen;
|
||||||
char fileName[128];
|
char fileName[PATH_MAX] = {0};
|
||||||
|
|
||||||
mdebugFlag = 135;
|
mdebugFlag = 135;
|
||||||
sdbDebugFlag = 135;
|
sdbDebugFlag = 135;
|
||||||
|
@ -851,27 +849,30 @@ void tsReadGlobalLogConfig() {
|
||||||
wordfree(&full_path);
|
wordfree(&full_path);
|
||||||
|
|
||||||
tsReadLogOption("logDir", logDir);
|
tsReadLogOption("logDir", logDir);
|
||||||
|
|
||||||
sprintf(fileName, "%s/taos.cfg", configDir);
|
sprintf(fileName, "%s/taos.cfg", configDir);
|
||||||
fp = fopen(fileName, "r");
|
fp = fopen(fileName, "r");
|
||||||
if (fp == NULL) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
line = NULL;
|
size_t len = 1024;
|
||||||
|
line = calloc(1, len);
|
||||||
|
|
||||||
while (!feof(fp)) {
|
while (!feof(fp)) {
|
||||||
tfree(line);
|
memset(line, 0, len);
|
||||||
line = option = value = NULL;
|
|
||||||
len = olen = vlen = 0;
|
option = value = NULL;
|
||||||
|
olen = vlen = 0;
|
||||||
|
|
||||||
getline(&line, &len, fp);
|
getline(&line, &len, fp);
|
||||||
if (line == NULL) break;
|
|
||||||
|
|
||||||
paGetToken(line, &option, &olen);
|
paGetToken(line, len, &option, &olen);
|
||||||
if (olen == 0) continue;
|
if (olen == 0) continue;
|
||||||
option[olen] = 0;
|
option[olen] = 0;
|
||||||
|
|
||||||
paGetToken(option + olen + 1, &value, &vlen);
|
paGetToken(option + olen + 1, len, &value, &vlen);
|
||||||
if (vlen == 0) continue;
|
if (vlen == 0) continue;
|
||||||
value[vlen] = 0;
|
value[vlen] = 0;
|
||||||
|
|
||||||
|
@ -885,44 +886,45 @@ void tsReadGlobalLogConfig() {
|
||||||
bool tsReadGlobalConfig() {
|
bool tsReadGlobalConfig() {
|
||||||
tsInitGlobalConfig();
|
tsInitGlobalConfig();
|
||||||
|
|
||||||
FILE * fp;
|
|
||||||
char * line, *option, *value, *value1;
|
char * line, *option, *value, *value1;
|
||||||
size_t len;
|
|
||||||
int olen, vlen, vlen1;
|
int olen, vlen, vlen1;
|
||||||
char fileName[128];
|
char fileName[PATH_MAX] = {0};
|
||||||
|
|
||||||
sprintf(fileName, "%s/taos.cfg", configDir);
|
sprintf(fileName, "%s/taos.cfg", configDir);
|
||||||
fp = fopen(fileName, "r");
|
FILE* fp = fopen(fileName, "r");
|
||||||
if (fp == NULL) {
|
|
||||||
} else {
|
size_t len = 1024;
|
||||||
line = NULL;
|
line = calloc(1, len);
|
||||||
|
|
||||||
|
if (fp != NULL) {
|
||||||
while (!feof(fp)) {
|
while (!feof(fp)) {
|
||||||
tfree(line);
|
memset(line, 0, len);
|
||||||
line = option = value = NULL;
|
|
||||||
len = olen = vlen = 0;
|
option = value = NULL;
|
||||||
|
olen = vlen = 0;
|
||||||
|
|
||||||
getline(&line, &len, fp);
|
getline(&line, &len, fp);
|
||||||
if (line == NULL) break;
|
|
||||||
|
|
||||||
paGetToken(line, &option, &olen);
|
paGetToken(line, len, &option, &olen);
|
||||||
if (olen == 0) continue;
|
if (olen == 0) continue;
|
||||||
option[olen] = 0;
|
option[olen] = 0;
|
||||||
|
|
||||||
paGetToken(option + olen + 1, &value, &vlen);
|
paGetToken(option + olen + 1, len, &value, &vlen);
|
||||||
if (vlen == 0) continue;
|
if (vlen == 0) continue;
|
||||||
value[vlen] = 0;
|
value[vlen] = 0;
|
||||||
|
|
||||||
// For dataDir, the format is:
|
// For dataDir, the format is:
|
||||||
// dataDir /mnt/disk1 0
|
// dataDir /mnt/disk1 0
|
||||||
paGetToken(value + vlen + 1, &value1, &vlen1);
|
paGetToken(value + vlen + 1, len, &value1, &vlen1);
|
||||||
|
|
||||||
tsReadConfigOption(option, value);
|
tsReadConfigOption(option, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
tfree(line);
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tfree(line);
|
||||||
|
|
||||||
if (tsReadStorageConfig) {
|
if (tsReadStorageConfig) {
|
||||||
tsReadStorageConfig();
|
tsReadStorageConfig();
|
||||||
}
|
}
|
||||||
|
@ -976,6 +978,7 @@ bool tsReadGlobalConfig() {
|
||||||
strcpy(tsLocalIp, tsPrivateIp);
|
strcpy(tsLocalIp, tsPrivateIp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo refactor
|
||||||
tsVersion = 0;
|
tsVersion = 0;
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
if (version[i] >= '0' && version[i] <= '9') {
|
if (version[i] >= '0' && version[i] <= '9') {
|
||||||
|
@ -984,6 +987,7 @@ bool tsReadGlobalConfig() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tsVersion = 10 * tsVersion;
|
tsVersion = 10 * tsVersion;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -994,10 +998,11 @@ int tsCfgDynamicOptions(char *msg) {
|
||||||
int olen, vlen, code = 0;
|
int olen, vlen, code = 0;
|
||||||
int vint = 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;
|
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)
|
if (vlen == 0)
|
||||||
vint = 135;
|
vint = 135;
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in New Issue