Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
bfa9b692
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
bfa9b692
编写于
6月 18, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
6月 18, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2321 from taosdata/coverity_scan
Coverity scan
上级
1886b9c9
ea0c4dee
变更
12
显示空白变更内容
内联
并排
Showing
12 changed file
with
42 addition
and
65 deletion
+42
-65
src/util/inc/tstoken.h
src/util/inc/tstoken.h
+1
-0
src/util/src/tarray.c
src/util/src/tarray.c
+0
-3
src/util/src/tcache.c
src/util/src/tcache.c
+3
-5
src/util/src/tcompression.c
src/util/src/tcompression.c
+2
-2
src/util/src/tconfig.c
src/util/src/tconfig.c
+12
-3
src/util/src/tkvstore.c
src/util/src/tkvstore.c
+1
-0
src/util/src/tlog.c
src/util/src/tlog.c
+9
-2
src/util/src/tnote.c
src/util/src/tnote.c
+5
-2
src/util/src/tsocket.c
src/util/src/tsocket.c
+2
-2
src/util/src/ttime.c
src/util/src/ttime.c
+0
-43
src/util/src/ttimer.c
src/util/src/ttimer.c
+5
-1
src/util/src/tutil.c
src/util/src/tutil.c
+2
-2
未找到文件。
src/util/inc/tstoken.h
浏览文件 @
bfa9b692
...
...
@@ -120,6 +120,7 @@ static FORCE_INLINE int32_t isValidNumber(const SSQLToken* pToken) {
type
=
TK_FLOAT
;
goto
_end
;
break
;
}
case
'0'
:
{
...
...
src/util/src/tarray.c
浏览文件 @
bfa9b692
...
...
@@ -95,9 +95,6 @@ void* taosArrayGetP(const SArray* pArray, size_t index) {
assert
(
index
<
pArray
->
size
);
void
*
d
=
TARRAY_GET_ELEM
(
pArray
,
index
);
if
(
d
==
NULL
)
{
return
NULL
;
}
return
*
(
void
**
)
d
;
}
...
...
src/util/src/tcache.c
浏览文件 @
bfa9b692
...
...
@@ -119,7 +119,7 @@ static FORCE_INLINE void taosCacheReleaseNode(SCacheObj *pCacheObj, SCacheDataNo
int32_t
size
=
pNode
->
size
;
taosHashRemove
(
pCacheObj
->
pHashTable
,
pNode
->
key
,
pNode
->
keySize
);
uTrace
(
"key:%s is removed from cache,total:%
d,size:%l
dbytes"
,
pNode
->
key
,
pCacheObj
->
totalSize
,
size
);
uTrace
(
"key:%s is removed from cache,total:%
"
PRId64
",size:%
dbytes"
,
pNode
->
key
,
pCacheObj
->
totalSize
,
size
);
if
(
pCacheObj
->
freeFp
)
pCacheObj
->
freeFp
(
pNode
->
data
);
free
(
pNode
);
}
...
...
@@ -288,7 +288,7 @@ void *taosCachePut(SCacheObj *pCacheObj, const char *key, const void *pData, siz
if
(
NULL
!=
pNode
)
{
pCacheObj
->
totalSize
+=
pNode
->
size
;
uTrace
(
"key:%s %p added into cache, added:%"
PRIu64
", expire:%"
PRIu64
", total:%
d
, size:%"
PRId64
" bytes"
,
uTrace
(
"key:%s %p added into cache, added:%"
PRIu64
", expire:%"
PRIu64
", total:%
"
PRId64
"
, size:%"
PRId64
" bytes"
,
key
,
pNode
,
pNode
->
addedTime
,
pNode
->
expiredTime
,
pCacheObj
->
totalSize
,
dataSize
);
}
else
{
uError
(
"key:%s failed to added into cache, out of memory"
,
key
);
...
...
@@ -433,7 +433,6 @@ void taosCacheEmpty(SCacheObj *pCacheObj) {
__cache_wr_lock
(
pCacheObj
);
while
(
taosHashIterNext
(
pIter
))
{
if
(
pCacheObj
->
deleting
==
1
)
{
taosHashDestroyIter
(
pIter
);
break
;
}
...
...
@@ -507,7 +506,7 @@ void taosAddToTrash(SCacheObj *pCacheObj, SCacheDataNode *pNode) {
void
taosRemoveFromTrashCan
(
SCacheObj
*
pCacheObj
,
STrashElem
*
pElem
)
{
if
(
pElem
->
pData
->
signature
!=
(
uint64_t
)
pElem
->
pData
)
{
uError
(
"key:sig:
%d
%p data has been released, ignore"
,
pElem
->
pData
->
signature
,
pElem
->
pData
);
uError
(
"key:sig:
0x%x
%p data has been released, ignore"
,
pElem
->
pData
->
signature
,
pElem
->
pData
);
return
;
}
...
...
@@ -561,7 +560,6 @@ void taosTrashCanEmpty(SCacheObj *pCacheObj, bool force) {
}
}
assert
(
pCacheObj
->
numOfElemsInTrash
>=
0
);
__cache_unlock
(
pCacheObj
);
}
...
...
src/util/src/tcompression.c
浏览文件 @
bfa9b692
...
...
@@ -551,7 +551,7 @@ int tsDecompressTimestampImp(const char *const input, const int nelements, char
delta_of_delta
=
0
;
}
else
{
if
(
is_bigendian
())
{
memcpy
(
&
dd1
+
LONG_BYTES
-
nbytes
,
input
+
ipos
,
nbytes
);
memcpy
(
((
char
*
)(
&
dd1
))
+
LONG_BYTES
-
nbytes
,
input
+
ipos
,
nbytes
);
}
else
{
memcpy
(
&
dd1
,
input
+
ipos
,
nbytes
);
}
...
...
@@ -576,7 +576,7 @@ int tsDecompressTimestampImp(const char *const input, const int nelements, char
delta_of_delta
=
0
;
}
else
{
if
(
is_bigendian
())
{
memcpy
(
&
dd2
+
LONG_BYTES
-
nbytes
,
input
+
ipos
,
nbytes
);
memcpy
(
((
char
*
)(
&
dd2
))
+
LONG_BYTES
-
nbytes
,
input
+
ipos
,
nbytes
);
}
else
{
memcpy
(
&
dd2
,
input
+
ipos
,
nbytes
);
}
...
...
src/util/src/tconfig.c
浏览文件 @
bfa9b692
...
...
@@ -74,7 +74,7 @@ static void taosReadInt32Config(SGlobalCfg *cfg, char *input_value) {
*
option
=
value
;
cfg
->
cfgStatus
=
TAOS_CFG_CSTATUS_FILE
;
}
else
{
uWarn
(
"config option:%s, input value:%s, is configured by %s, use %
s
"
,
cfg
->
option
,
input_value
,
uWarn
(
"config option:%s, input value:%s, is configured by %s, use %
d
"
,
cfg
->
option
,
input_value
,
tsCfgStatusStr
[
cfg
->
cfgStatus
],
*
option
);
}
}
...
...
@@ -106,7 +106,11 @@ static void taosReadDirectoryConfig(SGlobalCfg *cfg, char *input_value) {
}
else
{
if
(
cfg
->
cfgStatus
<=
TAOS_CFG_CSTATUS_FILE
)
{
wordexp_t
full_path
;
wordexp
(
input_value
,
&
full_path
,
0
);
if
(
0
!=
wordexp
(
input_value
,
&
full_path
,
0
))
{
printf
(
"
\n
config dir: %s wordexp fail! reason:%s
\n
"
,
input_value
,
strerror
(
errno
));
wordfree
(
&
full_path
);
return
;
}
if
(
full_path
.
we_wordv
!=
NULL
&&
full_path
.
we_wordv
[
0
]
!=
NULL
)
{
strcpy
(
option
,
full_path
.
we_wordv
[
0
]);
}
...
...
@@ -240,7 +244,12 @@ void taosReadGlobalLogCfg() {
sdbDebugFlag
=
135
;
wordexp_t
full_path
;
wordexp
(
configDir
,
&
full_path
,
0
);
if
(
0
!=
wordexp
(
configDir
,
&
full_path
,
0
))
{
printf
(
"
\n
config file: %s wordexp fail! reason:%s
\n
"
,
configDir
,
strerror
(
errno
));
wordfree
(
&
full_path
);
return
;
}
if
(
full_path
.
we_wordv
!=
NULL
&&
full_path
.
we_wordv
[
0
]
!=
NULL
)
{
if
(
strlen
(
full_path
.
we_wordv
[
0
])
>=
TSDB_FILENAME_LEN
)
{
printf
(
"
\n
config file: %s path overflow max len %d, all variables are set to default
\n
"
,
full_path
.
we_wordv
[
0
],
TSDB_FILENAME_LEN
-
1
);
...
...
src/util/src/tkvstore.c
浏览文件 @
bfa9b692
...
...
@@ -537,5 +537,6 @@ static int tdRestoreKVStore(SKVStore *pStore) {
_err:
tfree
(
buf
);
taosHashDestroyIter
(
pIter
);
return
-
1
;
}
\ No newline at end of file
src/util/src/tlog.c
浏览文件 @
bfa9b692
...
...
@@ -142,6 +142,10 @@ static void *taosThreadToOpenNewFile(void *param) {
umask
(
0
);
int32_t
fd
=
open
(
name
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
S_IRWXU
|
S_IRWXG
|
S_IRWXO
);
if
(
fd
<
0
)
{
uError
(
"open new log file fail! fd:%d reason:%s"
,
fd
,
strerror
(
errno
));
return
NULL
;
}
taosLockFile
(
fd
);
lseek
(
fd
,
0
,
SEEK_SET
);
...
...
@@ -184,7 +188,7 @@ void taosResetLog() {
tsLogObj
.
lines
=
tsLogObj
.
maxLines
+
10
;
taosOpenNewLogFile
();
remove
(
lastName
);
(
void
)
remove
(
lastName
);
uPrint
(
"=================================="
);
uPrint
(
" reset log file "
);
...
...
@@ -279,7 +283,10 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) {
// only an estimate for number of lines
struct
stat
filestat
;
fstat
(
tsLogObj
.
logHandle
->
fd
,
&
filestat
);
if
(
fstat
(
tsLogObj
.
logHandle
->
fd
,
&
filestat
)
<
0
)
{
printf
(
"
\n
failed to fstat log file:%s, reason:%s
\n
"
,
name
,
strerror
(
errno
));
return
-
1
;
}
size
=
(
int32_t
)
filestat
.
st_size
;
tsLogObj
.
lines
=
size
/
60
;
...
...
src/util/src/tnote.c
浏览文件 @
bfa9b692
...
...
@@ -214,7 +214,10 @@ int taosOpenNoteWithMaxLines(char *fn, int maxLines, int maxNoteNum, taosNoteInf
// only an estimate for number of lines
struct
stat
filestat
;
fstat
(
pNote
->
taosNoteFd
,
&
filestat
);
if
(
fstat
(
pNote
->
taosNoteFd
,
&
filestat
)
<
0
)
{
fprintf
(
stderr
,
"failed to fstat note file:%s reason:%s
\n
"
,
name
,
strerror
(
errno
));
return
-
1
;
}
size
=
(
int
)
filestat
.
st_size
;
pNote
->
taosNoteLines
=
size
/
60
;
...
...
@@ -226,7 +229,7 @@ int taosOpenNoteWithMaxLines(char *fn, int maxLines, int maxNoteNum, taosNoteInf
void
taosNotePrint
(
taosNoteInfo
*
pNote
,
const
char
*
const
format
,
...)
{
va_list
argpointer
;
char
buffer
[
MAX_NOTE_LINE_SIZE
];
char
buffer
[
MAX_NOTE_LINE_SIZE
+
2
];
int
len
;
struct
tm
Tm
,
*
ptm
;
struct
timeval
timeSecs
;
...
...
src/util/src/tsocket.c
浏览文件 @
bfa9b692
...
...
@@ -278,7 +278,7 @@ int taosOpenUdpSocket(uint32_t ip, uint16_t port) {
/* bind socket to local address */
if
(
bind
(
sockFd
,
(
struct
sockaddr
*
)
&
localAddr
,
sizeof
(
localAddr
))
<
0
)
{
uError
(
"failed to bind udp socket: %d (%s), 0x%x:%hu"
,
errno
,
strerror
(
errno
),
ip
,
port
);
taosCloseSocket
(
sockFd
);
close
(
sockFd
);
return
-
1
;
}
...
...
@@ -321,7 +321,7 @@ int taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clientI
if
(
ret
!=
0
)
{
//uError("failed to connect socket, ip:0x%x, port:%hu(%s)", destIp, destPort, strerror(errno));
taosCloseSocket
(
sockFd
);
close
(
sockFd
);
sockFd
=
-
1
;
}
...
...
src/util/src/ttime.c
浏览文件 @
bfa9b692
...
...
@@ -72,49 +72,6 @@ void deltaToUtcInitOnce() {
return
;
}
int64_t
user_mktime
(
struct
tm
*
tm
)
{
#define TAOS_MINUTE 60
#define TAOS_HOUR (60*TAOS_MINUTE)
#define TAOS_DAY (24*TAOS_HOUR)
#define TAOS_YEAR (365*TAOS_DAY)
static
int
month
[
12
]
=
{
0
,
TAOS_DAY
*
(
31
),
TAOS_DAY
*
(
31
+
29
),
TAOS_DAY
*
(
31
+
29
+
31
),
TAOS_DAY
*
(
31
+
29
+
31
+
30
),
TAOS_DAY
*
(
31
+
29
+
31
+
30
+
31
),
TAOS_DAY
*
(
31
+
29
+
31
+
30
+
31
+
30
),
TAOS_DAY
*
(
31
+
29
+
31
+
30
+
31
+
30
+
31
),
TAOS_DAY
*
(
31
+
29
+
31
+
30
+
31
+
30
+
31
+
31
),
TAOS_DAY
*
(
31
+
29
+
31
+
30
+
31
+
30
+
31
+
31
+
30
),
TAOS_DAY
*
(
31
+
29
+
31
+
30
+
31
+
30
+
31
+
31
+
30
+
31
),
TAOS_DAY
*
(
31
+
29
+
31
+
30
+
31
+
30
+
31
+
31
+
30
+
31
+
30
)
};
int64_t
res
;
int
year
;
year
=
tm
->
tm_year
-
70
;
res
=
TAOS_YEAR
*
year
+
TAOS_DAY
*
((
year
+
1
)
/
4
);
res
+=
month
[
tm
->
tm_mon
];
if
(
tm
->
tm_mon
>
1
&&
((
year
+
2
)
%
4
))
{
res
-=
TAOS_DAY
;
}
res
+=
TAOS_DAY
*
(
tm
->
tm_mday
-
1
);
res
+=
TAOS_HOUR
*
tm
->
tm_hour
;
res
+=
TAOS_MINUTE
*
tm
->
tm_min
;
res
+=
tm
->
tm_sec
;
return
res
+
m_deltaUtc
;
}
static
int64_t
parseFraction
(
char
*
str
,
char
**
end
,
int32_t
timePrec
);
static
int32_t
parseTimeWithTz
(
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
);
static
int32_t
parseLocaltime
(
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
);
...
...
src/util/src/ttimer.c
浏览文件 @
bfa9b692
...
...
@@ -139,7 +139,7 @@ static void unlockTimerList(timer_list_t* list) {
int64_t
tid
=
taosGetPthreadId
();
if
(
atomic_val_compare_exchange_64
(
&
(
list
->
lockedBy
),
tid
,
0
)
!=
tid
)
{
assert
(
false
);
tmrError
(
"%
d
trying to unlock a timer list not locked by current thread."
,
tid
);
tmrError
(
"%
"
PRId64
"
trying to unlock a timer list not locked by current thread."
,
tid
);
}
}
...
...
@@ -290,6 +290,7 @@ static void addToExpired(tmr_obj_t* head) {
SSchedMsg
schedMsg
;
schedMsg
.
fp
=
NULL
;
schedMsg
.
tfp
=
processExpiredTimer
;
schedMsg
.
msg
=
NULL
;
schedMsg
.
ahandle
=
head
;
schedMsg
.
thandle
=
NULL
;
taosScheduleTask
(
tmrQhandle
,
&
schedMsg
);
...
...
@@ -513,14 +514,17 @@ static void taosTmrModuleInit(void) {
tmrError
(
"failed to create the mutex for wheel, reason:%s"
,
strerror
(
errno
));
return
;
}
pthread_mutex_lock
(
&
wheel
->
mutex
);
wheel
->
nextScanAt
=
now
+
wheel
->
resolution
;
wheel
->
index
=
0
;
wheel
->
slots
=
(
tmr_obj_t
**
)
calloc
(
wheel
->
size
,
sizeof
(
tmr_obj_t
*
));
if
(
wheel
->
slots
==
NULL
)
{
tmrError
(
"failed to allocate wheel slots"
);
pthread_mutex_unlock
(
&
wheel
->
mutex
);
return
;
}
timerMap
.
size
+=
wheel
->
size
;
pthread_mutex_unlock
(
&
wheel
->
mutex
);
}
timerMap
.
count
=
0
;
...
...
src/util/src/tutil.c
浏览文件 @
bfa9b692
...
...
@@ -557,7 +557,7 @@ bool taosGetVersionNumber(char *versionStr, int *versionNubmer) {
return
false
;
}
int
versionNumberPos
[
4
]
=
{
0
};
int
versionNumberPos
[
5
]
=
{
0
};
int
len
=
strlen
(
versionStr
);
int
dot
=
0
;
for
(
int
pos
=
0
;
pos
<
len
&&
dot
<
4
;
++
pos
)
{
...
...
@@ -709,7 +709,7 @@ void taosRemoveDir(char *rootDir) {
if
(
de
->
d_type
&
DT_DIR
)
{
taosRemoveDir
(
filename
);
}
else
{
remove
(
filename
);
(
void
)
remove
(
filename
);
uPrint
(
"file:%s is removed"
,
filename
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录