未验证 提交 08601f4b 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #20451 from taosdata/fix/TD-23134

fix: fix coverity scan
...@@ -130,21 +130,25 @@ SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath, int ...@@ -130,21 +130,25 @@ SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath, int
char cfgPath[1030]; char cfgPath[1030];
sprintf(cfgPath, "%s/cfg", statePath); sprintf(cfgPath, "%s/cfg", statePath);
szPage = szPage < 0 ? 4096 : szPage;
pages = pages < 0 ? 256 : pages;
char cfg[1024]; char cfg[1024];
memset(cfg, 0, 1024); memset(cfg, 0, 1024);
TdFilePtr pCfgFile = taosOpenFile(cfgPath, TD_FILE_READ); TdFilePtr pCfgFile = taosOpenFile(cfgPath, TD_FILE_READ);
if (pCfgFile != NULL) { if (pCfgFile != NULL) {
int64_t size; int64_t size = 0;
taosFStatFile(pCfgFile, &size, NULL); taosFStatFile(pCfgFile, &size, NULL);
taosReadFile(pCfgFile, cfg, size); if (size > 0) {
sscanf(cfg, "%d\n%d\n", &szPage, &pages); taosReadFile(pCfgFile, cfg, size);
sscanf(cfg, "%d\n%d\n", &szPage, &pages);
}
} else { } else {
taosMulModeMkDir(statePath, 0755); int32_t code = taosMulModeMkDir(statePath, 0755);
pCfgFile = taosOpenFile(cfgPath, TD_FILE_WRITE | TD_FILE_CREATE); if (code == 0) {
szPage = szPage < 0 ? 4096 : szPage; pCfgFile = taosOpenFile(cfgPath, TD_FILE_WRITE | TD_FILE_CREATE);
pages = pages < 0 ? 256 : pages; sprintf(cfg, "%d\n%d\n", szPage, pages);
sprintf(cfg, "%d\n%d\n", szPage, pages); taosWriteFile(pCfgFile, cfg, strlen(cfg));
taosWriteFile(pCfgFile, cfg, strlen(cfg)); }
} }
taosCloseFile(&pCfgFile); taosCloseFile(&pCfgFile);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册