mirror of https://gitee.com/bigwinds/arangodb
fix issues found by codescan (#7198)
This commit is contained in:
parent
3384a848fd
commit
8f1ce5b396
|
@ -1091,8 +1091,13 @@ std::pair<ExecutionState, size_t> RemoteBlock::skipSome(size_t atMost) {
|
||||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_CLUSTER_AQL_COMMUNICATION);
|
THROW_ARANGO_EXCEPTION(TRI_ERROR_CLUSTER_AQL_COMMUNICATION);
|
||||||
}
|
}
|
||||||
size_t skipped = 0;
|
size_t skipped = 0;
|
||||||
if (slice.hasKey("skipped")) {
|
VPackSlice s = slice.get("skipped");
|
||||||
skipped = slice.get("skipped").getNumericValue<size_t>();
|
if (s.isNumber()) {
|
||||||
|
int64_t value = s.getNumericValue<int64_t>();
|
||||||
|
if (value < 0) {
|
||||||
|
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_BAD_PARAMETER, "skipped cannot be negative");
|
||||||
|
}
|
||||||
|
skipped = s.getNumericValue<size_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Check if we can get better with HASMORE/DONE
|
// TODO Check if we can get better with HASMORE/DONE
|
||||||
|
|
|
@ -514,16 +514,28 @@ void QueryCache::properties(VPackSlice const& properties) {
|
||||||
|
|
||||||
v = properties.get("maxResults");
|
v = properties.get("maxResults");
|
||||||
if (v.isNumber()) {
|
if (v.isNumber()) {
|
||||||
|
int64_t value = v.getNumericValue<int64_t>();
|
||||||
|
if (value <= 0) {
|
||||||
|
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_BAD_PARAMETER, "invalid value for maxResults");
|
||||||
|
}
|
||||||
maxResultsCount = v.getNumericValue<size_t>();
|
maxResultsCount = v.getNumericValue<size_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
v = properties.get("maxResultsSize");
|
v = properties.get("maxResultsSize");
|
||||||
if (v.isNumber()) {
|
if (v.isNumber()) {
|
||||||
|
int64_t value = v.getNumericValue<int64_t>();
|
||||||
|
if (value <= 0) {
|
||||||
|
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_BAD_PARAMETER, "invalid value for maxResultsSize");
|
||||||
|
}
|
||||||
maxResultsSize = v.getNumericValue<size_t>();
|
maxResultsSize = v.getNumericValue<size_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
v = properties.get("maxEntrySize");
|
v = properties.get("maxEntrySize");
|
||||||
if (v.isNumber()) {
|
if (v.isNumber()) {
|
||||||
|
int64_t value = v.getNumericValue<int64_t>();
|
||||||
|
if (value <= 0) {
|
||||||
|
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_BAD_PARAMETER, "invalid value for maxEntrySize");
|
||||||
|
}
|
||||||
maxEntrySize = v.getNumericValue<size_t>();
|
maxEntrySize = v.getNumericValue<size_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -169,7 +169,7 @@ void registerFunctions(arangodb::aql::AqlFunctionFeature& functions) {
|
||||||
),
|
),
|
||||||
[](arangodb::aql::Query*,
|
[](arangodb::aql::Query*,
|
||||||
arangodb::transaction::Methods*,
|
arangodb::transaction::Methods*,
|
||||||
arangodb::SmallVector<arangodb::aql::AqlValue> const& args) noexcept {
|
arangodb::SmallVector<arangodb::aql::AqlValue> const& args) {
|
||||||
auto arg = arangodb::aql::Functions::ExtractFunctionParameterValue(args, 0);
|
auto arg = arangodb::aql::Functions::ExtractFunctionParameterValue(args, 0);
|
||||||
auto const floatValue = *reinterpret_cast<float_t const*>(arg.slice().begin());
|
auto const floatValue = *reinterpret_cast<float_t const*>(arg.slice().begin());
|
||||||
return arangodb::aql::AqlValue(arangodb::aql::AqlValueHintDouble(double_t(floatValue)));
|
return arangodb::aql::AqlValue(arangodb::aql::AqlValueHintDouble(double_t(floatValue)));
|
||||||
|
@ -859,4 +859,4 @@ NS_END // arangodb
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- END-OF-FILE
|
// --SECTION-- END-OF-FILE
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
|
@ -253,8 +253,7 @@ void dropCollectionFromAllViews(
|
||||||
|
|
||||||
if (!impl) {
|
if (!impl) {
|
||||||
LOG_TOPIC(TRACE, arangodb::iresearch::TOPIC)
|
LOG_TOPIC(TRACE, arangodb::iresearch::TOPIC)
|
||||||
<< "error finding view: '" << view->name() << "': not an arangosearch view";
|
<< "error finding view: not an arangosearch view";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2058,8 +2058,6 @@ arangodb::Result IResearchView::updateProperties(
|
||||||
std::string("error updating properties for arangosearch view '") + name() + "'"
|
std::string("error updating properties for arangosearch view '") + name() + "'"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return arangodb::Result();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
arangodb::Result IResearchView::updateProperties(
|
arangodb::Result IResearchView::updateProperties(
|
||||||
|
@ -2200,4 +2198,4 @@ void IResearchView::verifyKnownCollections() {
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- END-OF-FILE
|
// --SECTION-- END-OF-FILE
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
|
@ -476,8 +476,6 @@ arangodb::Result IResearchViewCoordinator::updateProperties(
|
||||||
std::string("error updating properties for arangosearch view '") + name() + "'"
|
std::string("error updating properties for arangosearch view '") + name() + "'"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return arangodb::Result();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result IResearchViewCoordinator::dropImpl() {
|
Result IResearchViewCoordinator::dropImpl() {
|
||||||
|
@ -534,4 +532,4 @@ Result IResearchViewCoordinator::dropImpl() {
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- END-OF-FILE
|
// --SECTION-- END-OF-FILE
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
|
@ -59,13 +59,14 @@ static constexpr bool isLittleEndian() {return true;}
|
||||||
static constexpr bool isLittleEndian() {return false;}
|
static constexpr bool isLittleEndian() {return false;}
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#pragma messsage("unsupported os or compiler")
|
#pragma messsage("unsupported os or compiler")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template<typename T, size_t size> struct EndianTraits;
|
template<typename T, size_t size> struct EndianTraits;
|
||||||
|
|
||||||
template<typename T> struct EndianTraits<T, 2> {
|
template<typename T> struct EndianTraits<T, 2> {
|
||||||
typedef typename std::make_unsigned<T>::type type;
|
typedef typename std::make_unsigned<T>::type type;
|
||||||
|
|
||||||
inline static type htole(type in) {
|
inline static type htole(type in) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
return OSSwapHostToLittleInt16(in);
|
return OSSwapHostToLittleInt16(in);
|
||||||
|
@ -75,9 +76,12 @@ template<typename T> struct EndianTraits<T, 2> {
|
||||||
if (!isLittleEndian()) {
|
if (!isLittleEndian()) {
|
||||||
return _byteswap_ushort(in);
|
return _byteswap_ushort(in);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return in;
|
return in;
|
||||||
|
#else
|
||||||
|
return in;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static type letoh(type in) {
|
inline static type letoh(type in) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
return OSSwapLittleToHostInt16(in);
|
return OSSwapLittleToHostInt16(in);
|
||||||
|
@ -87,9 +91,12 @@ template<typename T> struct EndianTraits<T, 2> {
|
||||||
if (!isLittleEndian()) {
|
if (!isLittleEndian()) {
|
||||||
return _byteswap_ushort(in);
|
return _byteswap_ushort(in);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return in;
|
return in;
|
||||||
|
#else
|
||||||
|
return in;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static type htobe(type in) {
|
inline static type htobe(type in) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
return OSSwapHostToBigInt16(in);
|
return OSSwapHostToBigInt16(in);
|
||||||
|
@ -99,8 +106,10 @@ template<typename T> struct EndianTraits<T, 2> {
|
||||||
if (isLittleEndian()) {
|
if (isLittleEndian()) {
|
||||||
return _byteswap_ushort(in);
|
return _byteswap_ushort(in);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return in;
|
return in;
|
||||||
|
#else
|
||||||
|
return in;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
inline static type betoh(type in) {
|
inline static type betoh(type in) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
@ -111,13 +120,16 @@ template<typename T> struct EndianTraits<T, 2> {
|
||||||
if (isLittleEndian()) {
|
if (isLittleEndian()) {
|
||||||
return _byteswap_ushort(in);
|
return _byteswap_ushort(in);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return in;
|
return in;
|
||||||
|
#else
|
||||||
|
return in;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T> struct EndianTraits<T, 4> {
|
template<typename T> struct EndianTraits<T, 4> {
|
||||||
typedef typename std::make_unsigned<T>::type type;
|
typedef typename std::make_unsigned<T>::type type;
|
||||||
|
|
||||||
inline static type htole(type in) {
|
inline static type htole(type in) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
return OSSwapHostToLittleInt32(in);
|
return OSSwapHostToLittleInt32(in);
|
||||||
|
@ -127,9 +139,12 @@ template<typename T> struct EndianTraits<T, 4> {
|
||||||
if (!isLittleEndian()) {
|
if (!isLittleEndian()) {
|
||||||
return _byteswap_ulong(in);
|
return _byteswap_ulong(in);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return in;
|
return in;
|
||||||
|
#else
|
||||||
|
return in;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static type letoh(type in) {
|
inline static type letoh(type in) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
return OSSwapLittleToHostInt32(in);
|
return OSSwapLittleToHostInt32(in);
|
||||||
|
@ -139,9 +154,12 @@ template<typename T> struct EndianTraits<T, 4> {
|
||||||
if (!isLittleEndian()) {
|
if (!isLittleEndian()) {
|
||||||
return _byteswap_ulong(in);
|
return _byteswap_ulong(in);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return in;
|
return in;
|
||||||
|
#else
|
||||||
|
return in;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static type htobe(type in) {
|
inline static type htobe(type in) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
return OSSwapHostToBigInt32(in);
|
return OSSwapHostToBigInt32(in);
|
||||||
|
@ -151,9 +169,12 @@ template<typename T> struct EndianTraits<T, 4> {
|
||||||
if (isLittleEndian()) {
|
if (isLittleEndian()) {
|
||||||
return _byteswap_ulong(in);
|
return _byteswap_ulong(in);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return in;
|
return in;
|
||||||
|
#else
|
||||||
|
return in;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static type betoh(type in) {
|
inline static type betoh(type in) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
return OSSwapBigToHostInt32(in);
|
return OSSwapBigToHostInt32(in);
|
||||||
|
@ -163,13 +184,16 @@ template<typename T> struct EndianTraits<T, 4> {
|
||||||
if (isLittleEndian()) {
|
if (isLittleEndian()) {
|
||||||
return _byteswap_ulong(in);
|
return _byteswap_ulong(in);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return in;
|
return in;
|
||||||
|
#else
|
||||||
|
return in;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T> struct EndianTraits<T, 8> {
|
template<typename T> struct EndianTraits<T, 8> {
|
||||||
typedef typename std::make_unsigned<T>::type type;
|
typedef typename std::make_unsigned<T>::type type;
|
||||||
|
|
||||||
inline static type htole(type in) {
|
inline static type htole(type in) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
return OSSwapHostToLittleInt64(in);
|
return OSSwapHostToLittleInt64(in);
|
||||||
|
@ -179,9 +203,12 @@ template<typename T> struct EndianTraits<T, 8> {
|
||||||
if (!isLittleEndian()) {
|
if (!isLittleEndian()) {
|
||||||
return _byteswap_uint64(in);
|
return _byteswap_uint64(in);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return in;
|
return in;
|
||||||
|
#else
|
||||||
|
return in;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static type letoh(type in) {
|
inline static type letoh(type in) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
return OSSwapLittleToHostInt64(in);
|
return OSSwapLittleToHostInt64(in);
|
||||||
|
@ -191,9 +218,12 @@ template<typename T> struct EndianTraits<T, 8> {
|
||||||
if (!isLittleEndian()) {
|
if (!isLittleEndian()) {
|
||||||
return _byteswap_uint64(in);
|
return _byteswap_uint64(in);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return in;
|
return in;
|
||||||
|
#else
|
||||||
|
return in;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static type htobe(type in) {
|
inline static type htobe(type in) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
return OSSwapHostToBigInt64(in);
|
return OSSwapHostToBigInt64(in);
|
||||||
|
@ -203,9 +233,12 @@ template<typename T> struct EndianTraits<T, 8> {
|
||||||
if (isLittleEndian()) {
|
if (isLittleEndian()) {
|
||||||
return _byteswap_uint64(in);
|
return _byteswap_uint64(in);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return in;
|
return in;
|
||||||
|
#else
|
||||||
|
return in;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static type betoh(type in) {
|
inline static type betoh(type in) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
return OSSwapBigToHostInt64(in);
|
return OSSwapBigToHostInt64(in);
|
||||||
|
@ -215,8 +248,10 @@ template<typename T> struct EndianTraits<T, 8> {
|
||||||
if (isLittleEndian()) {
|
if (isLittleEndian()) {
|
||||||
return _byteswap_uint64(in);
|
return _byteswap_uint64(in);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return in;
|
return in;
|
||||||
|
#else
|
||||||
|
return in;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -509,7 +509,7 @@ void Communicator::handleResult(CURL* handle, CURLcode rc) {
|
||||||
|
|
||||||
transformResult(handle, std::move(rip->_responseHeaders),
|
transformResult(handle, std::move(rip->_responseHeaders),
|
||||||
std::move(rip->_responseBody),
|
std::move(rip->_responseBody),
|
||||||
dynamic_cast<HttpResponse*>(response.get()));
|
static_cast<HttpResponse*>(response.get()));
|
||||||
|
|
||||||
if (httpStatusCode < 400) {
|
if (httpStatusCode < 400) {
|
||||||
callSuccessFn(rip->_ticketId, rip->_destination, rip->_callbacks, std::move(response));
|
callSuccessFn(rip->_ticketId, rip->_destination, rip->_callbacks, std::move(response));
|
||||||
|
|
Loading…
Reference in New Issue