1
0
Fork 0

honor some cppcheck recommendations (#5817)

This commit is contained in:
Jan 2018-07-10 13:50:30 +02:00 committed by GitHub
parent 208f1297e1
commit 2cac8b8a51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 11 deletions

View File

@ -317,14 +317,14 @@ class Query {
/// @brief setter for the continue callback: /// @brief setter for the continue callback:
/// We can either have a handler or a callback /// We can either have a handler or a callback
void setContinueCallback(std::function<void()> cb) { void setContinueCallback(std::function<void()> const& cb) {
_continueCallback = cb; _continueCallback = cb;
_hasHandler = false; _hasHandler = false;
} }
/// @brief setter for the continue handler: /// @brief setter for the continue handler:
/// We can either have a handler or a callback /// We can either have a handler or a callback
void setContinueHandler(std::function<void()> handler) { void setContinueHandler(std::function<void()> const& handler) {
_continueCallback = handler; _continueCallback = handler;
_hasHandler = true; _hasHandler = true;
} }

View File

@ -703,10 +703,8 @@ RestStatus RestAqlHandler::handleUseQuery(std::string const& operation, Query* q
VPackObjectBuilder guard(&answerBuilder); VPackObjectBuilder guard(&answerBuilder);
if (operation == "lock") { if (operation == "lock") {
// Mark current thread as potentially blocking: // Mark current thread as potentially blocking:
int res = TRI_ERROR_INTERNAL; int res = query->trx()->lockCollections();
// let exceptions propagate from here // let exceptions propagate from here
res = query->trx()->lockCollections();
answerBuilder.add(StaticStrings::Error, VPackValue(res != TRI_ERROR_NO_ERROR)); answerBuilder.add(StaticStrings::Error, VPackValue(res != TRI_ERROR_NO_ERROR));
answerBuilder.add(StaticStrings::Code, VPackValue(res)); answerBuilder.add(StaticStrings::Code, VPackValue(res));

View File

@ -208,7 +208,7 @@ Scheduler::~Scheduler() {
} }
// do not pass callback by reference, might get deleted before execution // do not pass callback by reference, might get deleted before execution
void Scheduler::post(std::function<void()> const callback) { void Scheduler::post(std::function<void()> const& callback) {
incQueued(); incQueued();
try { try {
@ -229,7 +229,7 @@ void Scheduler::post(std::function<void()> const callback) {
// do not pass callback by reference, might get deleted before execution // do not pass callback by reference, might get deleted before execution
void Scheduler::post(asio_ns::io_context::strand& strand, void Scheduler::post(asio_ns::io_context::strand& strand,
std::function<void()> const callback) { std::function<void()> const& callback) {
incQueued(); incQueued();
try { try {
@ -341,7 +341,7 @@ bool Scheduler::pushToFifo(size_t fifo, std::function<void()> const& callback) {
size_t p = fifo - 1; size_t p = fifo - 1;
TRI_ASSERT(0 < fifo && p < NUMBER_FIFOS); TRI_ASSERT(0 < fifo && p < NUMBER_FIFOS);
std::unique_ptr<FifoJob> job(new FifoJob(callback)); auto job = std::make_unique<FifoJob>(callback);
try { try {
if (0 < _maxFifoSize[p] && (int64_t)_maxFifoSize[p] <= _fifoSize[p]) { if (0 < _maxFifoSize[p] && (int64_t)_maxFifoSize[p] <= _fifoSize[p]) {

View File

@ -91,9 +91,9 @@ class Scheduler {
uint64_t _queued; uint64_t _queued;
}; };
void post(std::function<void()> const callback); void post(std::function<void()> const& callback);
void post(asio_ns::io_context::strand&, void post(asio_ns::io_context::strand&,
std::function<void()> const callback); std::function<void()> const& callback);
bool queue(RequestPriority prio, std::function<void()> const&); bool queue(RequestPriority prio, std::function<void()> const&);
void drain(); void drain();
@ -175,7 +175,7 @@ class Scheduler {
// queue is full // queue is full
struct FifoJob { struct FifoJob {
FifoJob(std::function<void()> const& callback) : _callback(callback) {} explicit FifoJob(std::function<void()> const& callback) : _callback(callback) {}
std::function<void()> _callback; std::function<void()> _callback;
}; };