Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
3f13464e
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3f13464e
编写于
3月 18, 2020
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clang-tidy, part 5
上级
44cb1b83
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
95 addition
and
36 deletion
+95
-36
.clang-tidy
.clang-tidy
+36
-0
base/common/JSON.cpp
base/common/JSON.cpp
+1
-1
base/common/LineReader.cpp
base/common/LineReader.cpp
+1
-1
dbms/src/Common/MemoryTracker.cpp
dbms/src/Common/MemoryTracker.cpp
+2
-2
dbms/src/Common/NamePrompter.h
dbms/src/Common/NamePrompter.h
+2
-9
dbms/src/Common/ZooKeeper/ZooKeeper.cpp
dbms/src/Common/ZooKeeper/ZooKeeper.cpp
+16
-2
dbms/src/Common/malloc.cpp
dbms/src/Common/malloc.cpp
+10
-10
dbms/src/Common/parseAddress.cpp
dbms/src/Common/parseAddress.cpp
+1
-1
dbms/src/Compression/CompressedReadBufferBase.cpp
dbms/src/Compression/CompressedReadBufferBase.cpp
+4
-1
dbms/src/Compression/CompressedReadBufferFromFile.cpp
dbms/src/Compression/CompressedReadBufferFromFile.cpp
+5
-1
dbms/src/DataStreams/CollapsingFinalBlockInputStream.h
dbms/src/DataStreams/CollapsingFinalBlockInputStream.h
+4
-0
dbms/src/Dictionaries/HashedDictionary.cpp
dbms/src/Dictionaries/HashedDictionary.cpp
+1
-1
dbms/src/IO/BitHelpers.h
dbms/src/IO/BitHelpers.h
+6
-1
dbms/src/IO/ReadBufferAIO.h
dbms/src/IO/ReadBufferAIO.h
+1
-1
dbms/src/IO/WriteBufferAIO.h
dbms/src/IO/WriteBufferAIO.h
+1
-1
dbms/src/IO/WriteBufferFromHTTPServerResponse.h
dbms/src/IO/WriteBufferFromHTTPServerResponse.h
+1
-1
dbms/src/IO/WriteBufferFromVector.h
dbms/src/IO/WriteBufferFromVector.h
+1
-1
dbms/src/IO/WriteBufferValidUTF8.h
dbms/src/IO/WriteBufferValidUTF8.h
+1
-1
dbms/src/IO/tests/gtest_DateTime64_parsing_and_writing.cpp
dbms/src/IO/tests/gtest_DateTime64_parsing_and_writing.cpp
+1
-1
未找到文件。
.clang-tidy
浏览文件 @
3f13464e
...
...
@@ -123,6 +123,42 @@ Checks: '-*,
hicpp-exception-baseclass,
clang-analyzer-core.CallAndMessage,
clang-analyzer-core.DivideZero,
clang-analyzer-core.NonNullParamChecker,
clang-analyzer-core.NullDereference,
clang-analyzer-core.StackAddressEscape,
clang-analyzer-core.UndefinedBinaryOperatorResult,
clang-analyzer-core.VLASize,
clang-analyzer-core.uninitialized.ArraySubscript,
clang-analyzer-core.uninitialized.Assign,
clang-analyzer-core.uninitialized.Branch,
clang-analyzer-core.uninitialized.CapturedBlockVariable,
clang-analyzer-core.uninitialized.UndefReturn,
clang-analyzer-cplusplus.InnerPointer,
clang-analyzer-cplusplus.NewDelete,
clang-analyzer-cplusplus.NewDeleteLeaks,
clang-analyzer-cplusplus.PlacementNewChecker,
clang-analyzer-cplusplus.SelfAssignment,
clang-analyzer-deadcode.DeadStores,
clang-analyzer-optin.cplusplus.VirtualCall,
clang-analyzer-security.insecureAPI.UncheckedReturn,
clang-analyzer-security.insecureAPI.bcmp,
clang-analyzer-security.insecureAPI.bcopy,
clang-analyzer-security.insecureAPI.bzero,
clang-analyzer-security.insecureAPI.getpw,
clang-analyzer-security.insecureAPI.gets,
clang-analyzer-security.insecureAPI.mkstemp,
clang-analyzer-security.insecureAPI.mktemp,
clang-analyzer-security.insecureAPI.rand,
clang-analyzer-security.insecureAPI.strcpy,
clang-analyzer-unix.Malloc,
clang-analyzer-unix.MallocSizeof,
clang-analyzer-unix.MismatchedDeallocator,
clang-analyzer-unix.Vfork,
clang-analyzer-unix.cstring.BadSizeArg,
clang-analyzer-unix.cstring.NullArg,
boost-use-to-string,
'
WarningsAsErrors: '*'
base/common/JSON.cpp
浏览文件 @
3f13464e
...
...
@@ -215,7 +215,7 @@ JSON::ElementType JSON::getType() const
void
JSON
::
checkPos
(
Pos
pos
)
const
{
if
(
pos
>=
ptr_end
)
if
(
pos
>=
ptr_end
||
ptr_begin
==
nullptr
)
throw
JSONException
(
"JSON: unexpected end of data."
);
}
...
...
base/common/LineReader.cpp
浏览文件 @
3f13464e
...
...
@@ -30,7 +30,7 @@ void trim(String & s)
bool
hasInputData
()
{
timeval
timeout
=
{
0
,
0
};
fd_set
fds
;
fd_set
fds
{}
;
FD_ZERO
(
&
fds
);
FD_SET
(
STDIN_FILENO
,
&
fds
);
return
select
(
1
,
&
fds
,
nullptr
,
nullptr
,
&
timeout
)
==
1
;
...
...
dbms/src/Common/MemoryTracker.cpp
浏览文件 @
3f13464e
...
...
@@ -93,7 +93,7 @@ void MemoryTracker::alloc(Int64 size)
free
(
size
);
/// Prevent recursion. Exception::ctor -> std::string -> new[] -> MemoryTracker::alloc
auto
untrack_lock
=
blocker
.
cancel
();
auto
untrack_lock
=
blocker
.
cancel
();
// NOLINT
std
::
stringstream
message
;
message
<<
"Memory tracker"
;
...
...
@@ -118,7 +118,7 @@ void MemoryTracker::alloc(Int64 size)
free
(
size
);
/// Prevent recursion. Exception::ctor -> std::string -> new[] -> MemoryTracker::alloc
auto
untrack_lock
=
blocker
.
cancel
();
auto
untrack_lock
=
blocker
.
cancel
();
// NOLINT
std
::
stringstream
message
;
message
<<
"Memory limit"
;
...
...
dbms/src/Common/NamePrompter.h
浏览文件 @
3f13464e
#pragma once
#include <Core/Types.h>
#include <Common/PODArray.h>
#include <algorithm>
#include <cctype>
...
...
@@ -32,15 +33,7 @@ private:
size_t
m
=
lhs
.
size
();
size_t
n
=
rhs
.
size
();
static
constexpr
size_t
small_buffer_size
=
64
;
size_t
small_buffer
[
small_buffer_size
];
std
::
unique_ptr
<
size_t
[]
>
alloc_buffer
;
size_t
*
row
=
small_buffer
;
if
(
n
+
1
>
small_buffer_size
)
{
row
=
new
size_t
[
n
+
1
];
alloc_buffer
.
reset
(
row
);
}
PODArrayWithStackMemory
<
size_t
,
64
>
row
(
n
+
1
);
for
(
size_t
i
=
1
;
i
<=
n
;
++
i
)
row
[
i
]
=
i
;
...
...
dbms/src/Common/ZooKeeper/ZooKeeper.cpp
浏览文件 @
3f13464e
...
...
@@ -5,9 +5,9 @@
#include <random>
#include <functional>
#include <boost/algorithm/string.hpp>
#include <common/logger_useful.h>
#include <common/find_symbols.h>
#include <Common/StringUtils/StringUtils.h>
#include <Common/PODArray.h>
#include <Common/thread_local_rng.h>
...
...
@@ -61,7 +61,21 @@ void ZooKeeper::init(const std::string & implementation, const std::string & hos
throw
KeeperException
(
"No addresses passed to ZooKeeper constructor."
,
Coordination
::
ZBADARGUMENTS
);
std
::
vector
<
std
::
string
>
addresses_strings
;
boost
::
split
(
addresses_strings
,
hosts
,
boost
::
is_any_of
(
","
));
const
char
*
pos
=
hosts
.
data
();
const
char
*
end
=
pos
+
hosts
.
size
();
while
(
pos
<
end
)
{
const
char
*
comma_or_end
=
find_first_symbols
<
','
>
(
pos
,
end
);
addresses_strings
.
emplace_back
(
pos
,
comma_or_end
);
if
(
comma_or_end
<
end
)
pos
=
comma_or_end
+
1
;
else
pos
=
comma_or_end
;
}
Coordination
::
ZooKeeper
::
Addresses
addresses
;
addresses
.
reserve
(
addresses_strings
.
size
());
...
...
dbms/src/Common/malloc.cpp
浏览文件 @
3f13464e
...
...
@@ -30,15 +30,15 @@ static void dummyFunctionForInterposing() __attribute__((used));
static
void
dummyFunctionForInterposing
()
{
void
*
dummy
;
/// Suppression for PVS-Studio.
free
(
nullptr
);
// -V575
ignore
(
malloc
(
0
));
// -V575
ignore
(
calloc
(
0
,
0
));
// -V575
ignore
(
realloc
(
nullptr
,
0
));
// -V575
ignore
(
posix_memalign
(
&
dummy
,
0
,
0
));
// -V575
ignore
(
aligned_alloc
(
0
,
0
));
// -V575
ignore
(
valloc
(
0
));
// -V575
ignore
(
memalign
(
0
,
0
));
// -V575
ignore
(
pvalloc
(
0
));
// -V575
/// Suppression for PVS-Studio
and clang-tidy
.
free
(
nullptr
);
// -V575
NOLINT
ignore
(
malloc
(
0
));
// -V575
NOLINT
ignore
(
calloc
(
0
,
0
));
// -V575
NOLINT
ignore
(
realloc
(
nullptr
,
0
));
// -V575
NOLINT
ignore
(
posix_memalign
(
&
dummy
,
0
,
0
));
// -V575
NOLINT
ignore
(
aligned_alloc
(
0
,
0
));
// -V575
NOLINT
ignore
(
valloc
(
0
));
// -V575
NOLINT
ignore
(
memalign
(
0
,
0
));
// -V575
NOLINT
ignore
(
pvalloc
(
0
));
// -V575
NOLINT
}
#endif
dbms/src/Common/parseAddress.cpp
浏览文件 @
3f13464e
...
...
@@ -19,7 +19,7 @@ std::pair<std::string, UInt16> parseAddress(const std::string & str, UInt16 defa
const
char
*
begin
=
str
.
data
();
const
char
*
end
=
begin
+
str
.
size
();
const
char
*
port
=
end
;
const
char
*
port
=
end
;
// NOLINT
if
(
begin
[
0
]
==
'['
)
{
...
...
dbms/src/Compression/CompressedReadBufferBase.cpp
浏览文件 @
3f13464e
#include "CompressedReadBufferBase.h"
#include <vector>
#include <string.h>
#include <cstring>
#include <cassert>
#include <city.h>
#include <Common/PODArray.h>
#include <Common/ProfileEvents.h>
...
...
@@ -118,6 +119,8 @@ size_t CompressedReadBufferBase::readCompressedData(size_t & size_decompressed,
size_compressed_without_checksum
=
ICompressionCodec
::
readCompressedBlockSize
(
own_compressed_buffer
.
data
());
size_decompressed
=
ICompressionCodec
::
readDecompressedBlockSize
(
own_compressed_buffer
.
data
());
assert
(
size_decompressed
>
0
);
if
(
size_compressed_without_checksum
>
DBMS_MAX_COMPRESSED_SIZE
)
throw
Exception
(
"Too large size_compressed_without_checksum: "
+
toString
(
size_compressed_without_checksum
)
...
...
dbms/src/Compression/CompressedReadBufferFromFile.cpp
浏览文件 @
3f13464e
#include <cassert>
#include "CompressedReadBufferFromFile.h"
#include <Compression/CompressionInfo.h>
...
...
@@ -16,12 +18,14 @@ namespace ErrorCodes
bool
CompressedReadBufferFromFile
::
nextImpl
()
{
size_t
size_decompressed
;
size_t
size_decompressed
=
0
;
size_t
size_compressed_without_checksum
;
size_compressed
=
readCompressedData
(
size_decompressed
,
size_compressed_without_checksum
);
if
(
!
size_compressed
)
return
false
;
assert
(
size_decompressed
>
0
);
memory
.
resize
(
size_decompressed
+
codec
->
getAdditionalSizeAtTheEndOfBuffer
());
working_buffer
=
Buffer
(
memory
.
data
(),
&
memory
[
size_decompressed
]);
...
...
dbms/src/DataStreams/CollapsingFinalBlockInputStream.h
浏览文件 @
3f13464e
...
...
@@ -5,6 +5,8 @@
#include <Columns/ColumnsNumber.h>
#include <Common/typeid_cast.h>
#include <queue>
#include <cassert>
namespace
DB
{
...
...
@@ -115,6 +117,8 @@ private:
MergingBlockPtr
&
operator
=
(
const
MergingBlockPtr
&
rhs
)
{
assert
(
ptr
!=
rhs
.
ptr
);
destroy
();
ptr
=
rhs
.
ptr
;
if
(
ptr
)
...
...
dbms/src/Dictionaries/HashedDictionary.cpp
浏览文件 @
3f13464e
...
...
@@ -444,7 +444,7 @@ void HashedDictionary::addAttributeSize(const Attribute & attribute)
bucket_count
=
map_ref
->
bucket_count
();
/** TODO: more accurate calculation */
bytes_allocated
+=
sizeof
(
CollectionType
<
T
>
);
bytes_allocated
+=
sizeof
(
Sparse
CollectionType
<
T
>
);
bytes_allocated
+=
bucket_count
;
bytes_allocated
+=
map_ref
->
size
()
*
(
sizeof
(
Key
)
+
sizeof
(
T
));
}
...
...
dbms/src/IO/BitHelpers.h
浏览文件 @
3f13464e
...
...
@@ -4,7 +4,8 @@
#include <Common/BitHelpers.h>
#include <Common/Exception.h>
#include <string.h>
#include <cstring>
#include <cassert>
#if defined(__OpenBSD__) || defined(__FreeBSD__)
# include <sys/endian.h>
...
...
@@ -115,6 +116,8 @@ private:
template
<
GetBitsMode
mode
>
inline
UInt64
getBitsFromBitBuffer
(
UInt8
bits_to_read
)
{
assert
(
bits_to_read
>
0
);
// push down the high-bits
const
UInt64
result
=
static_cast
<
UInt64
>
(
bits_buffer
>>
(
sizeof
(
bits_buffer
)
*
8
-
bits_to_read
));
...
...
@@ -186,6 +189,8 @@ public:
// write `bits_to_write` low-bits of `value` to the buffer
inline
void
writeBits
(
UInt8
bits_to_write
,
UInt64
value
)
{
assert
(
bits_to_write
>
0
);
UInt32
capacity
=
BIT_BUFFER_SIZE
-
bits_count
;
if
(
capacity
<
bits_to_write
)
{
...
...
dbms/src/IO/ReadBufferAIO.h
浏览文件 @
3f13464e
...
...
@@ -25,7 +25,7 @@ namespace DB
/** Class for asynchronous data reading.
*/
class
ReadBufferAIO
:
public
ReadBufferFromFileBase
class
ReadBufferAIO
final
:
public
ReadBufferFromFileBase
{
public:
ReadBufferAIO
(
const
std
::
string
&
filename_
,
size_t
buffer_size_
=
DBMS_DEFAULT_BUFFER_SIZE
,
int
flags_
=
-
1
,
...
...
dbms/src/IO/WriteBufferAIO.h
浏览文件 @
3f13464e
...
...
@@ -24,7 +24,7 @@ namespace DB
/** Class for asynchronous data writing.
*/
class
WriteBufferAIO
:
public
WriteBufferFromFileBase
class
WriteBufferAIO
final
:
public
WriteBufferFromFileBase
{
public:
WriteBufferAIO
(
const
std
::
string
&
filename_
,
size_t
buffer_size_
=
DBMS_DEFAULT_BUFFER_SIZE
,
int
flags_
=
-
1
,
mode_t
mode_
=
0666
,
...
...
dbms/src/IO/WriteBufferFromHTTPServerResponse.h
浏览文件 @
3f13464e
...
...
@@ -41,7 +41,7 @@ namespace DB
/// Also this class write and flush special X-ClickHouse-Progress HTTP headers
/// if no data was sent at the time of progress notification.
/// This allows to implement progress bar in HTTP clients.
class
WriteBufferFromHTTPServerResponse
:
public
BufferWithOwnMemory
<
WriteBuffer
>
class
WriteBufferFromHTTPServerResponse
final
:
public
BufferWithOwnMemory
<
WriteBuffer
>
{
private:
Poco
::
Net
::
HTTPServerRequest
&
request
;
...
...
dbms/src/IO/WriteBufferFromVector.h
浏览文件 @
3f13464e
...
...
@@ -65,7 +65,7 @@ public:
set
(
reinterpret_cast
<
Position
>
(
vector
.
data
()
+
old_size
),
(
size
-
old_size
)
*
sizeof
(
typename
VectorType
::
value_type
));
}
void
finalize
()
override
void
finalize
()
override
final
{
if
(
is_finished
)
return
;
...
...
dbms/src/IO/WriteBufferValidUTF8.h
浏览文件 @
3f13464e
...
...
@@ -11,7 +11,7 @@ namespace DB
* If the valid UTF-8 is already written, it works faster.
* Note: before using the resulting string, destroy this object.
*/
class
WriteBufferValidUTF8
:
public
BufferWithOwnMemory
<
WriteBuffer
>
class
WriteBufferValidUTF8
final
:
public
BufferWithOwnMemory
<
WriteBuffer
>
{
private:
WriteBuffer
&
output_buffer
;
...
...
dbms/src/IO/tests/gtest_DateTime64_parsing_and_writing.cpp
浏览文件 @
3f13464e
...
...
@@ -37,7 +37,7 @@ TEST_P(DateTime64StringParseTest, readDateTime64Text)
const
auto
&
param
=
GetParam
();
ReadBufferFromMemory
read_buffer
(
param
.
string
.
data
(),
param
.
string
.
size
());
DateTime64
actual
;
DateTime64
actual
{}
;
EXPECT_TRUE
(
tryReadDateTime64Text
(
actual
,
param
.
scale
,
read_buffer
,
param
.
timezone
));
EXPECT_EQ
(
param
.
dt64
,
actual
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录