mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 18:12:02 +00:00
Fix warnings by PVS-Studio in some third-party code
This commit is contained in:
parent
8a804f1e35
commit
0af587a346
@ -78,6 +78,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Disable warnings by PVS-Studio
|
||||||
|
//-V::GA
|
||||||
|
|
||||||
static const double
|
static const double
|
||||||
pi = 3.14159265358979311600e+00, /* 0x400921FB, 0x54442D18 */
|
pi = 3.14159265358979311600e+00, /* 0x400921FB, 0x54442D18 */
|
||||||
a0 = 7.72156649015328655494e-02, /* 0x3FB3C467, 0xE37DB0C8 */
|
a0 = 7.72156649015328655494e-02, /* 0x3FB3C467, 0xE37DB0C8 */
|
||||||
|
@ -85,6 +85,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Disable warnings by PVS-Studio
|
||||||
|
//-V::GA
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "libm.h"
|
#include "libm.h"
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#ifndef _LIBM_H
|
#ifndef _LIBM_H
|
||||||
#define _LIBM_H
|
#define _LIBM_H
|
||||||
|
|
||||||
|
// Disable warnings by PVS-Studio
|
||||||
|
//-V::GA
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Disable warnings by PVS-Studio
|
||||||
|
//-V::GA
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "libm.h"
|
#include "libm.h"
|
||||||
|
@ -447,69 +447,6 @@ inline SrcIter uneven_copy(SrcIter src_first,
|
|||||||
std::integral_constant<bool, DEST_IS_SMALLER>{});
|
std::integral_constant<bool, DEST_IS_SMALLER>{});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* generate_to, fill in a fixed-size array of integral type using a SeedSeq
|
|
||||||
* (actually works for any random-access iterator)
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <size_t size, typename SeedSeq, typename DestIter>
|
|
||||||
inline void generate_to_impl(SeedSeq&& generator, DestIter dest,
|
|
||||||
std::true_type)
|
|
||||||
{
|
|
||||||
generator.generate(dest, dest+size);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t size, typename SeedSeq, typename DestIter>
|
|
||||||
void generate_to_impl(SeedSeq&& generator, DestIter dest,
|
|
||||||
std::false_type)
|
|
||||||
{
|
|
||||||
typedef typename std::iterator_traits<DestIter>::value_type dest_t;
|
|
||||||
constexpr auto DEST_SIZE = sizeof(dest_t);
|
|
||||||
constexpr auto GEN_SIZE = sizeof(uint32_t);
|
|
||||||
|
|
||||||
constexpr bool GEN_IS_SMALLER = GEN_SIZE < DEST_SIZE;
|
|
||||||
constexpr size_t FROM_ELEMS =
|
|
||||||
GEN_IS_SMALLER
|
|
||||||
? size * ((DEST_SIZE+GEN_SIZE-1) / GEN_SIZE)
|
|
||||||
: (size + (GEN_SIZE / DEST_SIZE) - 1)
|
|
||||||
/ ((GEN_SIZE / DEST_SIZE) + GEN_IS_SMALLER);
|
|
||||||
// this odd code ^^^^^^^^^^^^^^^^^ is work-around for
|
|
||||||
// a bug: http://llvm.org/bugs/show_bug.cgi?id=21287
|
|
||||||
|
|
||||||
if (FROM_ELEMS <= 1024) {
|
|
||||||
uint32_t buffer[FROM_ELEMS];
|
|
||||||
generator.generate(buffer, buffer+FROM_ELEMS);
|
|
||||||
uneven_copy(buffer, dest, dest+size);
|
|
||||||
} else {
|
|
||||||
uint32_t* buffer = static_cast<uint32_t*>(malloc(GEN_SIZE * FROM_ELEMS));
|
|
||||||
generator.generate(buffer, buffer+FROM_ELEMS);
|
|
||||||
uneven_copy(buffer, dest, dest+size);
|
|
||||||
free(static_cast<void*>(buffer));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t size, typename SeedSeq, typename DestIter>
|
|
||||||
inline void generate_to(SeedSeq&& generator, DestIter dest)
|
|
||||||
{
|
|
||||||
typedef typename std::iterator_traits<DestIter>::value_type dest_t;
|
|
||||||
constexpr bool IS_32BIT = sizeof(dest_t) == sizeof(uint32_t);
|
|
||||||
|
|
||||||
generate_to_impl<size>(std::forward<SeedSeq>(generator), dest,
|
|
||||||
std::integral_constant<bool, IS_32BIT>{});
|
|
||||||
}
|
|
||||||
|
|
||||||
/* generate_one, produce a value of integral type using a SeedSeq
|
|
||||||
* (optionally, we can have it produce more than one and pick which one
|
|
||||||
* we want)
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <typename UInt, size_t i = 0UL, size_t N = i+1UL, typename SeedSeq>
|
|
||||||
inline UInt generate_one(SeedSeq&& generator)
|
|
||||||
{
|
|
||||||
UInt result[N];
|
|
||||||
generate_to<N>(std::forward<SeedSeq>(generator), result);
|
|
||||||
return result[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename RngType>
|
template <typename RngType>
|
||||||
auto bounded_rand(RngType& rng, typename RngType::result_type upper_bound)
|
auto bounded_rand(RngType& rng, typename RngType::result_type upper_bound)
|
||||||
-> typename RngType::result_type
|
-> typename RngType::result_type
|
||||||
@ -517,7 +454,7 @@ auto bounded_rand(RngType& rng, typename RngType::result_type upper_bound)
|
|||||||
typedef typename RngType::result_type rtype;
|
typedef typename RngType::result_type rtype;
|
||||||
rtype threshold = (RngType::max() - RngType::min() + rtype(1) - upper_bound)
|
rtype threshold = (RngType::max() - RngType::min() + rtype(1) - upper_bound)
|
||||||
% upper_bound;
|
% upper_bound;
|
||||||
for (;;) {
|
for (;;) { //-V1044
|
||||||
rtype r = rng() - RngType::min();
|
rtype r = rng() - RngType::min();
|
||||||
if (r >= threshold)
|
if (r >= threshold)
|
||||||
return r % upper_bound;
|
return r % upper_bound;
|
||||||
|
@ -928,7 +928,7 @@ struct rxs_m_xs_mixin {
|
|||||||
constexpr bitcount_t shift = bits - xtypebits;
|
constexpr bitcount_t shift = bits - xtypebits;
|
||||||
constexpr bitcount_t mask = (1 << opbits) - 1;
|
constexpr bitcount_t mask = (1 << opbits) - 1;
|
||||||
bitcount_t rshift =
|
bitcount_t rshift =
|
||||||
opbits ? bitcount_t(internal >> (bits - opbits)) & mask : 0;
|
opbits ? bitcount_t(internal >> (bits - opbits)) & mask : 0; //-V547
|
||||||
internal ^= internal >> (opbits + rshift);
|
internal ^= internal >> (opbits + rshift);
|
||||||
internal *= mcg_multiplier<itype>::multiplier();
|
internal *= mcg_multiplier<itype>::multiplier();
|
||||||
xtype result = internal >> shift;
|
xtype result = internal >> shift;
|
||||||
@ -950,7 +950,7 @@ struct rxs_m_xs_mixin {
|
|||||||
|
|
||||||
internal *= mcg_unmultiplier<itype>::unmultiplier();
|
internal *= mcg_unmultiplier<itype>::unmultiplier();
|
||||||
|
|
||||||
bitcount_t rshift = opbits ? (internal >> (bits - opbits)) & mask : 0;
|
bitcount_t rshift = opbits ? (internal >> (bits - opbits)) & mask : 0; //-V547
|
||||||
internal = unxorshift(internal, bits, opbits + rshift);
|
internal = unxorshift(internal, bits, opbits + rshift);
|
||||||
|
|
||||||
return internal;
|
return internal;
|
||||||
@ -975,7 +975,7 @@ struct rxs_m_mixin {
|
|||||||
: 2;
|
: 2;
|
||||||
constexpr bitcount_t shift = bits - xtypebits;
|
constexpr bitcount_t shift = bits - xtypebits;
|
||||||
constexpr bitcount_t mask = (1 << opbits) - 1;
|
constexpr bitcount_t mask = (1 << opbits) - 1;
|
||||||
bitcount_t rshift = opbits ? (internal >> (bits - opbits)) & mask : 0;
|
bitcount_t rshift = opbits ? (internal >> (bits - opbits)) & mask : 0; //-V547
|
||||||
internal ^= internal >> (opbits + rshift);
|
internal ^= internal >> (opbits + rshift);
|
||||||
internal *= mcg_multiplier<itype>::multiplier();
|
internal *= mcg_multiplier<itype>::multiplier();
|
||||||
xtype result = internal >> shift;
|
xtype result = internal >> shift;
|
||||||
@ -1366,7 +1366,7 @@ void extended<table_pow2,advance_pow2,baseclass,extvalclass,kdd>::selfinit()
|
|||||||
// - any strange correlations would only be apparent if we
|
// - any strange correlations would only be apparent if we
|
||||||
// were to backstep the generator so that the base generator
|
// were to backstep the generator so that the base generator
|
||||||
// was generating the same values again
|
// was generating the same values again
|
||||||
result_type xdiff = baseclass::operator()() - baseclass::operator()();
|
result_type xdiff = baseclass::operator()() - baseclass::operator()(); //-V501
|
||||||
for (size_t i = 0; i < table_size; ++i) {
|
for (size_t i = 0; i < table_size; ++i) {
|
||||||
data_[i] = baseclass::operator()() ^ xdiff;
|
data_[i] = baseclass::operator()() ^ xdiff;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user