Insignificant changes for PVS-Studio [#CLICKHOUSE-3]

This commit is contained in:
Alexey Milovidov 2018-06-04 22:22:27 +03:00
parent e5682e81f7
commit ca52d96e09
7 changed files with 21 additions and 22 deletions

View File

@ -165,12 +165,13 @@ public:
set.resize(reserved);
// Specialized here because there's no deserialiser for StringRef
size_t count = 0;
readVarUInt(count, buf);
for (size_t i = 0; i < count; ++i)
size_t size = 0;
readVarUInt(size, buf);
for (size_t i = 0; i < size; ++i)
{
auto ref = readStringBinaryInto(*arena, buf);
UInt64 count, error;
UInt64 count;
UInt64 error;
readVarUInt(count, buf);
readVarUInt(error, buf);
set.insert(ref, count, error);

View File

@ -169,9 +169,9 @@ void ConfigProcessor::mergeRecursive(XMLDocumentPtr config, Node * config_root,
bool remove = false;
if (with_node->nodeType() == Node::ELEMENT_NODE)
{
Element * with_element = dynamic_cast<Element *>(with_node);
remove = with_element->hasAttribute("remove");
bool replace = with_element->hasAttribute("replace");
Element & with_element = dynamic_cast<Element &>(*with_node);
remove = with_element.hasAttribute("remove");
bool replace = with_element.hasAttribute("replace");
if (remove && replace)
throw Poco::Exception("both remove and replace attributes set for element <" + with_node->nodeName() + ">");
@ -189,7 +189,7 @@ void ConfigProcessor::mergeRecursive(XMLDocumentPtr config, Node * config_root,
}
else if (replace)
{
with_element->removeAttribute("replace");
with_element.removeAttribute("replace");
NodePtr new_node = config->importNode(with_node, true);
config_root->replaceChild(new_node, config_node);
}
@ -294,17 +294,17 @@ void ConfigProcessor::doIncludesRecursive(
}
else
{
Element * element = dynamic_cast<Element *>(node);
Element & element = dynamic_cast<Element &>(*node);
element->removeAttribute("incl");
element->removeAttribute("from_zk");
element.removeAttribute("incl");
element.removeAttribute("from_zk");
if (replace)
{
while (Node * child = node->firstChild())
node->removeChild(child);
element->removeAttribute("replace");
element.removeAttribute("replace");
}
const NodeListPtr children = node_to_include->childNodes();
@ -317,7 +317,7 @@ void ConfigProcessor::doIncludesRecursive(
const NamedNodeMapPtr from_attrs = node_to_include->attributes();
for (size_t i = 0, size = from_attrs->length(); i < size; ++i)
{
element->setAttributeNode(dynamic_cast<Attr *>(config->importNode(from_attrs->item(i), true)));
element.setAttributeNode(dynamic_cast<Attr *>(config->importNode(from_attrs->item(i), true)));
}
included_something = true;

View File

@ -54,7 +54,7 @@ struct RadixSortFloatTransform
static KeyBits forward(KeyBits x)
{
return x ^ (-((x >> (sizeof(KeyBits) * 8 - 1) | (KeyBits(1) << (sizeof(KeyBits) * 8 - 1)))));
return x ^ (-(x >> (sizeof(KeyBits) * 8 - 1) | (KeyBits(1) << (sizeof(KeyBits) * 8 - 1))));
}
static KeyBits backward(KeyBits x)

View File

@ -1038,7 +1038,6 @@ public:
return std::make_shared<DataTypeNumber<typename IndexConv::ResultType>>();
}
/// Perform function on the given block.
void executeImpl(Block & block, const ColumnNumbers & arguments, size_t result, size_t /*input_rows_count*/) override
{
/// If one or both arguments passed to this function are nullable,
@ -1056,8 +1055,7 @@ public:
/// values.
bool is_nullable;
const ColumnArray * col_array = nullptr;
col_array = checkAndGetColumn<ColumnArray>(block.getByPosition(arguments[0]).column.get());
const ColumnArray * col_array = checkAndGetColumn<ColumnArray>(block.getByPosition(arguments[0]).column.get());
if (col_array)
is_nullable = col_array->getData().isColumnNullable();
else

View File

@ -38,7 +38,7 @@ private:
/// Passed into file_in.
ReadBufferFromFileBase::ProfileCallback profile_callback;
clockid_t clock_type;
clockid_t clock_type {};
public:
CachedCompressedReadBuffer(

View File

@ -45,7 +45,7 @@ void CompressedWriteBuffer::nextImpl()
compressed_buffer.resize(header_size + LZ4_COMPRESSBOUND(uncompressed_size));
#pragma GCC diagnostic pop
compressed_buffer[0] = static_cast<UInt8>(CompressionMethodByte::LZ4);
compressed_buffer[0] = static_cast<char>(CompressionMethodByte::LZ4);
if (compression_settings.method == CompressionMethod::LZ4)
compressed_size = header_size + LZ4_compress_default(
@ -76,7 +76,7 @@ void CompressedWriteBuffer::nextImpl()
compressed_buffer.resize(header_size + ZSTD_compressBound(uncompressed_size));
compressed_buffer[0] = static_cast<UInt8>(CompressionMethodByte::ZSTD);
compressed_buffer[0] = static_cast<char>(CompressionMethodByte::ZSTD);
size_t res = ZSTD_compress(
&compressed_buffer[header_size],
@ -109,7 +109,7 @@ void CompressedWriteBuffer::nextImpl()
compressed_buffer.resize(compressed_size);
compressed_buffer[0] = static_cast<UInt8>(CompressionMethodByte::NONE);
compressed_buffer[0] = static_cast<char>(CompressionMethodByte::NONE);
unalignedStore(&compressed_buffer[1], compressed_size_32);
unalignedStore(&compressed_buffer[5], uncompressed_size_32);

View File

@ -1098,7 +1098,7 @@ private:
if (!position)
position = decltype(position)(
static_cast<void *>(new typename Map::const_iterator(map.begin())),
static_cast<void *>(new typename Map::const_iterator(map.begin())), //-V572
[](void * ptr) { delete reinterpret_cast<typename Map::const_iterator *>(ptr); });
auto & it = *reinterpret_cast<typename Map::const_iterator *>(position.get());