Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
f5ae3389
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看板
未验证
提交
f5ae3389
编写于
7月 01, 2021
作者:
H
Haojun Liao
提交者:
GitHub
7月 01, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6687 from bit-hope/develop
fix cmake scripts and reduce compile warnings
上级
5f62c311
1978c772
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
108 addition
and
33 deletion
+108
-33
CMakeLists.txt
CMakeLists.txt
+0
-7
cmake/define.inc
cmake/define.inc
+5
-1
src/os/src/detail/osSysinfo.c
src/os/src/detail/osSysinfo.c
+17
-9
src/plugins/http/src/httpJson.c
src/plugins/http/src/httpJson.c
+2
-0
src/util/src/tbuffer.c
src/util/src/tbuffer.c
+54
-8
src/util/src/tconfig.c
src/util/src/tconfig.c
+16
-4
src/util/src/tutil.c
src/util/src/tutil.c
+14
-4
未找到文件。
CMakeLists.txt
浏览文件 @
f5ae3389
...
...
@@ -42,13 +42,6 @@ INCLUDE(cmake/env.inc)
INCLUDE
(
cmake/version.inc
)
INCLUDE
(
cmake/install.inc
)
IF
(
CMAKE_SYSTEM_NAME MATCHES
"Linux"
)
SET
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-pipe -Wall -Wshadow -Werror"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-pipe -Wall -Wshadow -Werror"
)
ENDIF
()
MESSAGE
(
STATUS
"CMAKE_C_FLAGS:
${
CMAKE_C_FLAGS
}
"
)
MESSAGE
(
STATUS
"CMAKE_CXX_FLAGS:
${
CMAKE_CXX_FLAGS
}
"
)
ADD_SUBDIRECTORY
(
deps
)
ADD_SUBDIRECTORY
(
src
)
ADD_SUBDIRECTORY
(
tests
)
...
...
cmake/define.inc
浏览文件 @
f5ae3389
...
...
@@ -182,7 +182,7 @@ IF (TD_WINDOWS)
MESSAGE
(
"memory sanitizer detected as false"
)
SET
(
DEBUG_FLAGS
"/Zi /W3 /GL"
)
ENDIF
()
SET
(
RELEASE_FLAGS
"/W0 /O
3 /GL"
)
SET
(
RELEASE_FLAGS
"/W0 /O
2 /GL"
)
# MSVC only support O2
ENDIF
()
INCLUDE_DIRECTORIES
(
$
{
TD_COMMUNITY_DIR
}
/
deps
/
pthread
)
...
...
@@ -205,6 +205,10 @@ IF (TD_WINDOWS_32)
MESSAGE
(
STATUS
"windows32 is defined"
)
ENDIF
()
IF
(
TD_LINUX
)
SET
(
COMMON_FLAGS
"${COMMON_FLAGS} -pipe -Wshadow"
)
ENDIF
()
INCLUDE_DIRECTORIES
(
$
{
TD_COMMUNITY_DIR
}
/
src
/
inc
)
INCLUDE_DIRECTORIES
(
$
{
TD_COMMUNITY_DIR
}
/
src
/
os
/
inc
)
INCLUDE_DIRECTORIES
(
$
{
TD_COMMUNITY_DIR
}
/
src
/
util
/
inc
)
...
...
src/os/src/detail/osSysinfo.c
浏览文件 @
f5ae3389
...
...
@@ -74,13 +74,14 @@ bool taosGetProcMemory(float *memoryUsedMB) {
return
false
;
}
ssize_t
_bytes
=
0
;
size_t
len
;
char
*
line
=
NULL
;
while
(
!
feof
(
fp
))
{
tfree
(
line
);
len
=
0
;
getline
(
&
line
,
&
len
,
fp
);
if
(
line
==
NULL
)
{
_bytes
=
getline
(
&
line
,
&
len
,
fp
);
if
(
(
_bytes
<
0
)
||
(
line
==
NULL
)
)
{
break
;
}
if
(
strstr
(
line
,
"VmRSS:"
)
!=
NULL
)
{
...
...
@@ -113,8 +114,8 @@ static bool taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
size_t
len
;
char
*
line
=
NULL
;
getline
(
&
line
,
&
len
,
fp
);
if
(
line
==
NULL
)
{
ssize_t
_bytes
=
getline
(
&
line
,
&
len
,
fp
);
if
(
(
_bytes
<
0
)
||
(
line
==
NULL
)
)
{
uError
(
"read file:%s failed"
,
tsSysCpuFile
);
fclose
(
fp
);
return
false
;
...
...
@@ -138,8 +139,8 @@ static bool taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
size_t
len
=
0
;
char
*
line
=
NULL
;
getline
(
&
line
,
&
len
,
fp
);
if
(
line
==
NULL
)
{
ssize_t
_bytes
=
getline
(
&
line
,
&
len
,
fp
);
if
(
(
_bytes
<
0
)
||
(
line
==
NULL
)
)
{
uError
(
"read file:%s failed"
,
tsProcCpuFile
);
fclose
(
fp
);
return
false
;
...
...
@@ -339,6 +340,7 @@ static bool taosGetCardInfo(int64_t *bytes) {
return
false
;
}
ssize_t
_bytes
=
0
;
size_t
len
=
2048
;
char
*
line
=
calloc
(
1
,
len
);
...
...
@@ -357,7 +359,12 @@ static bool taosGetCardInfo(int64_t *bytes) {
int64_t
nouse6
=
0
;
char
nouse0
[
200
]
=
{
0
};
getline
(
&
line
,
&
len
,
fp
);
_bytes
=
getline
(
&
line
,
&
len
,
fp
);
if
(
_bytes
<
0
)
{
break
;
}
line
[
len
-
1
]
=
0
;
if
(
strstr
(
line
,
"lo:"
)
!=
NULL
)
{
...
...
@@ -420,6 +427,7 @@ static bool taosReadProcIO(int64_t *readbyte, int64_t *writebyte) {
return
false
;
}
ssize_t
_bytes
=
0
;
size_t
len
;
char
*
line
=
NULL
;
char
tmp
[
10
];
...
...
@@ -428,8 +436,8 @@ static bool taosReadProcIO(int64_t *readbyte, int64_t *writebyte) {
while
(
!
feof
(
fp
))
{
tfree
(
line
);
len
=
0
;
getline
(
&
line
,
&
len
,
fp
);
if
(
line
==
NULL
)
{
_bytes
=
getline
(
&
line
,
&
len
,
fp
);
if
(
(
_bytes
<
0
)
||
(
line
==
NULL
)
)
{
break
;
}
if
(
strstr
(
line
,
"rchar:"
)
!=
NULL
)
{
...
...
src/plugins/http/src/httpJson.c
浏览文件 @
f5ae3389
...
...
@@ -297,6 +297,7 @@ void httpJsonTimestamp(JsonBuf* buf, int64_t t, int32_t timePrecision) {
}
default:
fractionLen
=
0
;
assert
(
false
);
}
...
...
@@ -342,6 +343,7 @@ void httpJsonUtcTimestamp(JsonBuf* buf, int64_t t, int32_t timePrecision) {
}
default:
fractionLen
=
0
;
assert
(
false
);
}
...
...
src/util/src/tbuffer.c
浏览文件 @
f5ae3389
...
...
@@ -18,6 +18,24 @@
#include "exception.h"
#include "taoserror.h"
typedef
union
Un4B
{
uint32_t
ui
;
float
f
;
}
Un4B
;
#if __STDC_VERSION__ >= 201112L
static_assert
(
sizeof
(
Un4B
)
==
sizeof
(
uint32_t
),
"sizeof(Un4B) must equal to sizeof(uint32_t)"
);
static_assert
(
sizeof
(
Un4B
)
==
sizeof
(
float
),
"sizeof(Un4B) must equal to sizeof(float)"
);
#endif
typedef
union
Un8B
{
uint64_t
ull
;
double
d
;
}
Un8B
;
#if __STDC_VERSION__ >= 201112L
static_assert
(
sizeof
(
Un8B
)
==
sizeof
(
uint64_t
),
"sizeof(Un8B) must equal to sizeof(uint64_t)"
);
static_assert
(
sizeof
(
Un8B
)
==
sizeof
(
double
),
"sizeof(Un8B) must equal to sizeof(double)"
);
#endif
////////////////////////////////////////////////////////////////////////////////
// reader functions
...
...
@@ -175,13 +193,21 @@ uint64_t tbufReadUint64( SBufferReader* buf ) {
}
float
tbufReadFloat
(
SBufferReader
*
buf
)
{
uint32_t
ret
=
tbufReadUint32
(
buf
);
return
*
(
float
*
)(
&
ret
);
Un4B
_un
;
tbufReadToBuffer
(
buf
,
&
_un
,
sizeof
(
_un
)
);
if
(
buf
->
endian
)
{
_un
.
ui
=
ntohl
(
_un
.
ui
);
}
return
_un
.
f
;
}
double
tbufReadDouble
(
SBufferReader
*
buf
)
{
uint64_t
ret
=
tbufReadUint64
(
buf
);
return
*
(
double
*
)(
&
ret
);
Un8B
_un
;
tbufReadToBuffer
(
buf
,
&
_un
,
sizeof
(
_un
)
);
if
(
buf
->
endian
)
{
_un
.
ull
=
htobe64
(
_un
.
ull
);
}
return
_un
.
d
;
}
////////////////////////////////////////////////////////////////////////////////
...
...
@@ -381,17 +407,37 @@ void tbufWriteUint64At( SBufferWriter* buf, size_t pos, uint64_t data ) {
}
void
tbufWriteFloat
(
SBufferWriter
*
buf
,
float
data
)
{
tbufWriteUint32
(
buf
,
*
(
uint32_t
*
)(
&
data
)
);
Un4B
_un
;
_un
.
f
=
data
;
if
(
buf
->
endian
)
{
_un
.
ui
=
htonl
(
_un
.
ui
);
}
tbufWrite
(
buf
,
&
_un
,
sizeof
(
_un
)
);
}
void
tbufWriteFloatAt
(
SBufferWriter
*
buf
,
size_t
pos
,
float
data
)
{
tbufWriteUint32At
(
buf
,
pos
,
*
(
uint32_t
*
)(
&
data
)
);
Un4B
_un
;
_un
.
f
=
data
;
if
(
buf
->
endian
)
{
_un
.
ui
=
htonl
(
_un
.
ui
);
}
tbufWriteAt
(
buf
,
pos
,
&
_un
,
sizeof
(
_un
)
);
}
void
tbufWriteDouble
(
SBufferWriter
*
buf
,
double
data
)
{
tbufWriteUint64
(
buf
,
*
(
uint64_t
*
)(
&
data
)
);
Un8B
_un
;
_un
.
d
=
data
;
if
(
buf
->
endian
)
{
_un
.
ull
=
htobe64
(
_un
.
ull
);
}
tbufWrite
(
buf
,
&
_un
,
sizeof
(
_un
)
);
}
void
tbufWriteDoubleAt
(
SBufferWriter
*
buf
,
size_t
pos
,
double
data
)
{
tbufWriteUint64At
(
buf
,
pos
,
*
(
uint64_t
*
)(
&
data
)
);
Un8B
_un
;
_un
.
d
=
data
;
if
(
buf
->
endian
)
{
_un
.
ull
=
htobe64
(
_un
.
ull
);
}
tbufWriteAt
(
buf
,
pos
,
&
_un
,
sizeof
(
_un
)
);
}
src/util/src/tconfig.c
浏览文件 @
f5ae3389
...
...
@@ -327,7 +327,8 @@ void taosReadGlobalLogCfg() {
printf
(
"
\n
config file:%s not found, all variables are set to default
\n
"
,
fileName
);
return
;
}
ssize_t
_bytes
=
0
;
size_t
len
=
1024
;
line
=
calloc
(
1
,
len
);
...
...
@@ -337,7 +338,12 @@ void taosReadGlobalLogCfg() {
option
=
value
=
NULL
;
olen
=
vlen
=
0
;
tgetline
(
&
line
,
&
len
,
fp
);
_bytes
=
tgetline
(
&
line
,
&
len
,
fp
);
if
(
_bytes
<
0
)
{
break
;
}
line
[
len
-
1
]
=
0
;
paGetToken
(
line
,
&
option
,
&
olen
);
...
...
@@ -373,7 +379,8 @@ bool taosReadGlobalCfg() {
return
false
;
}
}
ssize_t
_bytes
=
0
;
size_t
len
=
1024
;
line
=
calloc
(
1
,
len
);
...
...
@@ -383,7 +390,12 @@ bool taosReadGlobalCfg() {
option
=
value
=
value2
=
value3
=
NULL
;
olen
=
vlen
=
vlen2
=
vlen3
=
0
;
tgetline
(
&
line
,
&
len
,
fp
);
_bytes
=
tgetline
(
&
line
,
&
len
,
fp
);
if
(
_bytes
<
0
)
{
break
;
}
line
[
len
-
1
]
=
0
;
paGetToken
(
line
,
&
option
,
&
olen
);
...
...
src/util/src/tutil.c
浏览文件 @
f5ae3389
...
...
@@ -427,13 +427,23 @@ char *taosIpStr(uint32_t ipInt) {
}
FORCE_INLINE
float
taos_align_get_float
(
const
char
*
pBuf
)
{
float
fv
=
0
;
*
(
int32_t
*
)(
&
fv
)
=
*
(
int32_t
*
)
pBuf
;
#if __STDC_VERSION__ >= 201112L
static_assert
(
sizeof
(
float
)
==
sizeof
(
uint32_t
),
"sizeof(float) must equal to sizeof(uint32_t)"
);
#else
assert
(
sizeof
(
float
)
==
sizeof
(
uint32_t
));
#endif
float
fv
=
0
;
memcpy
(
&
fv
,
pBuf
,
sizeof
(
fv
));
// in ARM, return *((const float*)(pBuf)) may cause problem
return
fv
;
}
FORCE_INLINE
double
taos_align_get_double
(
const
char
*
pBuf
)
{
double
dv
=
0
;
*
(
int64_t
*
)(
&
dv
)
=
*
(
int64_t
*
)
pBuf
;
#if __STDC_VERSION__ >= 201112L
static_assert
(
sizeof
(
double
)
==
sizeof
(
uint64_t
),
"sizeof(double) must equal to sizeof(uint64_t)"
);
#else
assert
(
sizeof
(
double
)
==
sizeof
(
uint64_t
));
#endif
double
dv
=
0
;
memcpy
(
&
dv
,
pBuf
,
sizeof
(
dv
));
// in ARM, return *((const double*)(pBuf)) may cause problem
return
dv
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录