Skip to content

Commit

Permalink
Apply clang-tidy to codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Neverlord committed Jan 5, 2017
1 parent d6f545d commit 78023b7
Show file tree
Hide file tree
Showing 154 changed files with 515 additions and 695 deletions.
30 changes: 30 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,modernize-*,performance-*,readability-*,-readability-braces-around-statements,-readability-named-parameter'
WarningsAsErrors: ''
HeaderFilterRegex: '/caf/'
AnalyzeTemporaryDtors: false
CheckOptions:
- key: cert-oop11-cpp.UseCERTSemantics
value: '1'
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
...

2 changes: 1 addition & 1 deletion examples/broker/protobuf_broker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void protobuf_io(broker* self, connection_handle hdl, const actor& buddy) {
self->become(await_length_prefix);
}

behavior server(broker* self, actor buddy) {
behavior server(broker* self, const actor& buddy) {
print_on_exit(self, "server");
aout(self) << "server is running" << endl;
return {
Expand Down
24 changes: 12 additions & 12 deletions examples/curl/curl_fuse.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/******************************************************************************\
/******************************************************************************
* This example *
* - emulates a client launching a request every 10-300ms *
* - uses a CURL-backend consisting of a master and 10 workers *
Expand Down Expand Up @@ -28,12 +28,12 @@
* | |<--/ *
* | <-------------(reply)-------------- | *
* X *
\ ******************************************************************************/
******************************************************************************/

// C includes
#include <time.h>
#include <signal.h>
#include <stdlib.h>
#include <ctime>
#include <csignal>
#include <cstdlib>

// C++ includes
#include <string>
Expand Down Expand Up @@ -129,7 +129,7 @@ struct base_state {
};

// encapsulates an HTTP request
behavior client_job(stateful_actor<base_state>* self, actor parent) {
behavior client_job(stateful_actor<base_state>* self, const actor& parent) {
if (!self->state.init("client-job", color::blue))
return {}; // returning an empty behavior terminates the actor
self->send(parent, read_atom::value,
Expand Down Expand Up @@ -164,7 +164,7 @@ struct client_state : base_state {
};

// spawns HTTP requests
behavior client(stateful_actor<client_state>* self, actor parent) {
behavior client(stateful_actor<client_state>* self, const actor& parent) {
using std::chrono::milliseconds;
self->link_to(parent);
if (!self->state.init("client", color::green))
Expand All @@ -190,8 +190,8 @@ struct curl_state : base_state {
// nop
}

~curl_state() {
if (curl)
~curl_state() override {
if (curl != nullptr)
curl_easy_cleanup(curl);
}

Expand All @@ -206,7 +206,7 @@ struct curl_state : base_state {

bool init(std::string m_name, std::string m_color) override {
curl = curl_easy_init();
if (!curl)
if (curl == nullptr)
return false;
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &curl_state::callback);
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
Expand All @@ -218,7 +218,7 @@ struct curl_state : base_state {
};

// manages a CURL session
behavior curl_worker(stateful_actor<curl_state>* self, actor parent) {
behavior curl_worker(stateful_actor<curl_state>* self, const actor& parent) {
if (!self->state.init("curl-worker", color::yellow))
return {}; // returning an empty behavior terminates the actor
return {
Expand Down Expand Up @@ -340,7 +340,7 @@ void caf_main(actor_system& system) {
struct sigaction act;
act.sa_handler = [](int) { shutdown_flag = true; };
auto set_sighandler = [&] {
if (sigaction(SIGINT, &act, 0)) {
if (sigaction(SIGINT, &act, nullptr) != 0) {
std::cerr << "fatal: cannot set signal handler" << std::endl;
abort();
}
Expand Down
18 changes: 10 additions & 8 deletions examples/dynamic_behavior/dining_philosophers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <map>
#include <thread>
#include <utility>
#include <vector>
#include <chrono>
#include <sstream>
Expand Down Expand Up @@ -34,7 +35,8 @@ using think_atom = atom_constant<atom("think")>;
using chopstick = typed_actor<replies_to<take_atom>::with<taken_atom, bool>,
reacts_to<put_atom>>;

chopstick::behavior_type taken_chopstick(chopstick::pointer, strong_actor_ptr);
chopstick::behavior_type taken_chopstick(chopstick::pointer,
const strong_actor_ptr&);

// either taken by a philosopher or available
chopstick::behavior_type available_chopstick(chopstick::pointer self) {
Expand All @@ -50,7 +52,7 @@ chopstick::behavior_type available_chopstick(chopstick::pointer self) {
}

chopstick::behavior_type taken_chopstick(chopstick::pointer self,
strong_actor_ptr user) {
const strong_actor_ptr& user) {
return {
[](take_atom) -> std::tuple<taken_atom, bool> {
return std::make_tuple(taken_atom::value, false);
Expand Down Expand Up @@ -94,13 +96,13 @@ chopstick::behavior_type taken_chopstick(chopstick::pointer self,
class philosopher : public event_based_actor {
public:
philosopher(actor_config& cfg,
const std::string& n,
const chopstick& l,
const chopstick& r)
std::string n,
chopstick l,
chopstick r)
: event_based_actor(cfg),
name_(n),
left_(l),
right_(r) {
name_(std::move(n)),
left_(std::move(l)),
right_(std::move(r)) {
// we only accept one message per state and skip others in the meantime
set_default_handler(skip);
// a philosopher that receives {eat} stops thinking and becomes hungry
Expand Down
4 changes: 2 additions & 2 deletions examples/message_passing/delegating.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ using namespace caf;

using calc = typed_actor<replies_to<add_atom, int, int>::with<int>>;

void actor_a(event_based_actor* self, calc worker) {
void actor_a(event_based_actor* self, const calc& worker) {
self->request(worker, std::chrono::seconds(10), add_atom::value, 1, 2).then(
[=](int result) {
aout(self) << "1 + 2 = " << result << endl;
}
);
}

calc::behavior_type actor_b(calc::pointer self, calc worker) {
calc::behavior_type actor_b(calc::pointer self, const calc& worker) {
return {
[=](add_atom add, int x, int y) {
return self->delegate(worker, add, x, y);
Expand Down
213 changes: 0 additions & 213 deletions examples/message_passing/dining_philosophers.cpp

This file was deleted.

Loading

0 comments on commit 78023b7

Please sign in to comment.