1
0
Fork 0

fix issues found by codescan (#7198)

This commit is contained in:
Jan 2018-11-02 18:53:34 +01:00 committed by GitHub
parent 3384a848fd
commit 8f1ce5b396
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 73 additions and 26 deletions

View File

@ -1091,8 +1091,13 @@ std::pair<ExecutionState, size_t> RemoteBlock::skipSome(size_t atMost) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_CLUSTER_AQL_COMMUNICATION);
}
size_t skipped = 0;
if (slice.hasKey("skipped")) {
skipped = slice.get("skipped").getNumericValue<size_t>();
VPackSlice s = slice.get("skipped");
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

View File

@ -514,16 +514,28 @@ void QueryCache::properties(VPackSlice const& properties) {
v = properties.get("maxResults");
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>();
}
v = properties.get("maxResultsSize");
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>();
}
v = properties.get("maxEntrySize");
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>();
}

View File

@ -169,7 +169,7 @@ void registerFunctions(arangodb::aql::AqlFunctionFeature& functions) {
),
[](arangodb::aql::Query*,
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 const floatValue = *reinterpret_cast<float_t const*>(arg.slice().begin());
return arangodb::aql::AqlValue(arangodb::aql::AqlValueHintDouble(double_t(floatValue)));
@ -859,4 +859,4 @@ NS_END // arangodb
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

View File

@ -253,8 +253,7 @@ void dropCollectionFromAllViews(
if (!impl) {
LOG_TOPIC(TRACE, arangodb::iresearch::TOPIC)
<< "error finding view: '" << view->name() << "': not an arangosearch view";
<< "error finding view: not an arangosearch view";
return true;
}

View File

@ -2058,8 +2058,6 @@ arangodb::Result IResearchView::updateProperties(
std::string("error updating properties for arangosearch view '") + name() + "'"
);
}
return arangodb::Result();
}
arangodb::Result IResearchView::updateProperties(
@ -2200,4 +2198,4 @@ void IResearchView::verifyKnownCollections() {
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

View File

@ -476,8 +476,6 @@ arangodb::Result IResearchViewCoordinator::updateProperties(
std::string("error updating properties for arangosearch view '") + name() + "'"
);
}
return arangodb::Result();
}
Result IResearchViewCoordinator::dropImpl() {
@ -534,4 +532,4 @@ Result IResearchViewCoordinator::dropImpl() {
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

View File

@ -59,13 +59,14 @@ static constexpr bool isLittleEndian() {return true;}
static constexpr bool isLittleEndian() {return false;}
#endif
#else
#pragma messsage("unsupported os or compiler")
#pragma messsage("unsupported os or compiler")
#endif
template<typename T, size_t size> struct EndianTraits;
template<typename T> struct EndianTraits<T, 2> {
typedef typename std::make_unsigned<T>::type type;
inline static type htole(type in) {
#ifdef __APPLE__
return OSSwapHostToLittleInt16(in);
@ -75,9 +76,12 @@ template<typename T> struct EndianTraits<T, 2> {
if (!isLittleEndian()) {
return _byteswap_ushort(in);
}
#endif
return in;
#else
return in;
#endif
}
inline static type letoh(type in) {
#ifdef __APPLE__
return OSSwapLittleToHostInt16(in);
@ -87,9 +91,12 @@ template<typename T> struct EndianTraits<T, 2> {
if (!isLittleEndian()) {
return _byteswap_ushort(in);
}
#endif
return in;
#else
return in;
#endif
}
inline static type htobe(type in) {
#ifdef __APPLE__
return OSSwapHostToBigInt16(in);
@ -99,8 +106,10 @@ template<typename T> struct EndianTraits<T, 2> {
if (isLittleEndian()) {
return _byteswap_ushort(in);
}
#endif
return in;
#else
return in;
#endif
}
inline static type betoh(type in) {
#ifdef __APPLE__
@ -111,13 +120,16 @@ template<typename T> struct EndianTraits<T, 2> {
if (isLittleEndian()) {
return _byteswap_ushort(in);
}
#endif
return in;
#else
return in;
#endif
}
};
template<typename T> struct EndianTraits<T, 4> {
typedef typename std::make_unsigned<T>::type type;
inline static type htole(type in) {
#ifdef __APPLE__
return OSSwapHostToLittleInt32(in);
@ -127,9 +139,12 @@ template<typename T> struct EndianTraits<T, 4> {
if (!isLittleEndian()) {
return _byteswap_ulong(in);
}
#endif
return in;
#else
return in;
#endif
}
inline static type letoh(type in) {
#ifdef __APPLE__
return OSSwapLittleToHostInt32(in);
@ -139,9 +154,12 @@ template<typename T> struct EndianTraits<T, 4> {
if (!isLittleEndian()) {
return _byteswap_ulong(in);
}
#endif
return in;
#else
return in;
#endif
}
inline static type htobe(type in) {
#ifdef __APPLE__
return OSSwapHostToBigInt32(in);
@ -151,9 +169,12 @@ template<typename T> struct EndianTraits<T, 4> {
if (isLittleEndian()) {
return _byteswap_ulong(in);
}
#endif
return in;
#else
return in;
#endif
}
inline static type betoh(type in) {
#ifdef __APPLE__
return OSSwapBigToHostInt32(in);
@ -163,13 +184,16 @@ template<typename T> struct EndianTraits<T, 4> {
if (isLittleEndian()) {
return _byteswap_ulong(in);
}
#endif
return in;
#else
return in;
#endif
}
};
template<typename T> struct EndianTraits<T, 8> {
typedef typename std::make_unsigned<T>::type type;
inline static type htole(type in) {
#ifdef __APPLE__
return OSSwapHostToLittleInt64(in);
@ -179,9 +203,12 @@ template<typename T> struct EndianTraits<T, 8> {
if (!isLittleEndian()) {
return _byteswap_uint64(in);
}
#endif
return in;
#else
return in;
#endif
}
inline static type letoh(type in) {
#ifdef __APPLE__
return OSSwapLittleToHostInt64(in);
@ -191,9 +218,12 @@ template<typename T> struct EndianTraits<T, 8> {
if (!isLittleEndian()) {
return _byteswap_uint64(in);
}
#endif
return in;
#else
return in;
#endif
}
inline static type htobe(type in) {
#ifdef __APPLE__
return OSSwapHostToBigInt64(in);
@ -203,9 +233,12 @@ template<typename T> struct EndianTraits<T, 8> {
if (isLittleEndian()) {
return _byteswap_uint64(in);
}
#endif
return in;
#else
return in;
#endif
}
inline static type betoh(type in) {
#ifdef __APPLE__
return OSSwapBigToHostInt64(in);
@ -215,8 +248,10 @@ template<typename T> struct EndianTraits<T, 8> {
if (isLittleEndian()) {
return _byteswap_uint64(in);
}
#endif
return in;
#else
return in;
#endif
}
};

View File

@ -509,7 +509,7 @@ void Communicator::handleResult(CURL* handle, CURLcode rc) {
transformResult(handle, std::move(rip->_responseHeaders),
std::move(rip->_responseBody),
dynamic_cast<HttpResponse*>(response.get()));
static_cast<HttpResponse*>(response.get()));
if (httpStatusCode < 400) {
callSuccessFn(rip->_ticketId, rip->_destination, rip->_callbacks, std::move(response));