Format rest of the sources

This commit is contained in:
Markus Mäkelä
2019-05-09 11:31:40 +03:00
parent fbd61967a7
commit de95fcc9d6
29 changed files with 384 additions and 388 deletions

View File

@ -55,7 +55,8 @@ namespace
struct TimePointLessEqual
{
TimePoint lhs;
TimePointLessEqual(TimePoint tp) : lhs(tp)
TimePointLessEqual(TimePoint tp)
: lhs(tp)
{
}
bool operator()(const EventCount::Timestamp& rhs) const
@ -134,7 +135,8 @@ namespace
struct MatchEventId
{
std::string event_id;
MatchEventId(const std::string& id) : event_id(id)
MatchEventId(const std::string& id)
: event_id(id)
{
}
bool operator()(const EventCount& stats) const

View File

@ -95,5 +95,4 @@ std::string string_printf(const char* format, ...)
}
return rval;
}
}

View File

@ -271,5 +271,4 @@ bool reverse_dns(const std::string& ip, std::string* output)
}
return success;
}
}

View File

@ -117,7 +117,7 @@ size_t header_callback(char* ptr, size_t size, size_t nmemb, void* userdata)
CURL* get_easy_curl(const std::string& url,
const std::string& user, const std::string& password,
const Config& config,
Result *pRes,
Result* pRes,
char* pErrbuf)
{
CURL* pCurl = curl_easy_init();
@ -126,8 +126,10 @@ CURL* get_easy_curl(const std::string& url,
if (pCurl)
{
checked_curl_setopt(pCurl, CURLOPT_NOSIGNAL, 1);
checked_curl_setopt(pCurl, CURLOPT_CONNECTTIMEOUT, config.connect_timeout_s);// For connection phase
checked_curl_setopt(pCurl, CURLOPT_TIMEOUT, config.timeout_s); // For data transfer phase
checked_curl_setopt(pCurl, CURLOPT_CONNECTTIMEOUT, config.connect_timeout_s); // For connection
// phase
checked_curl_setopt(pCurl, CURLOPT_TIMEOUT, config.timeout_s); // For data transfer
// phase
checked_curl_setopt(pCurl, CURLOPT_ERRORBUFFER, pErrbuf);
checked_curl_setopt(pCurl, CURLOPT_WRITEFUNCTION, write_callback);
checked_curl_setopt(pCurl, CURLOPT_WRITEDATA, &pRes->body);
@ -169,7 +171,7 @@ struct Context
}
mxb::http::Result* pResult;
Errbuf * pErrbuf;
Errbuf* pErrbuf;
};
class ReadyImp : public Async::Imp
@ -228,7 +230,7 @@ public:
for (auto& item : m_curls)
{
CURL* pCurl = item.first;
MXB_AT_DEBUG(CURLMcode rv =) curl_multi_remove_handle(m_pCurlm, pCurl);
MXB_AT_DEBUG(CURLMcode rv = ) curl_multi_remove_handle(m_pCurlm, pCurl);
mxb_assert(rv == CURLM_OK);
curl_easy_cleanup(pCurl);
}
@ -440,7 +442,6 @@ private:
int m_still_running;
long m_wait_no_more_than;
};
}
@ -546,7 +547,7 @@ Result get(const std::string& url, const std::string& user, const std::string& p
{
case CURLE_OK:
{
long code = 0; // needs to be a long
long code = 0; // needs to be a long
curl_easy_getinfo(pCurl, CURLINFO_RESPONSE_CODE, &code);
res.code = code;
}
@ -614,7 +615,5 @@ const char* to_string(Async::status_t status)
mxb_assert(!true);
return "Unknown";
}
}
}

View File

@ -32,7 +32,7 @@ class ConversationData
public:
string m_client;
string m_password;
int m_counter {0};
int m_counter {0};
string m_expected_msg;
ConversationData(const string& client, const string& password, const string& expected_msg)
@ -97,7 +97,6 @@ int conversation_func(int num_msg,
}
return rval;
}
}
namespace maxbase
@ -123,25 +122,25 @@ PamResult pam_authenticate(const string& user, const string& password, const str
pam_status = pam_authenticate(pam_handle, 0);
switch (pam_status)
{
case PAM_SUCCESS:
authenticated = true;
MXB_DEBUG("pam_authenticate returned success.");
break;
case PAM_SUCCESS:
authenticated = true;
MXB_DEBUG("pam_authenticate returned success.");
break;
case PAM_USER_UNKNOWN:
case PAM_AUTH_ERR:
// Normal failure, username or password was wrong.
result.type = PamResult::Result::WRONG_USER_PW;
result.error = mxb::string_printf(PAM_AUTH_ERR_MSG, user.c_str(), service.c_str(),
pam_strerror(pam_handle, pam_status));
break;
case PAM_USER_UNKNOWN:
case PAM_AUTH_ERR:
// Normal failure, username or password was wrong.
result.type = PamResult::Result::WRONG_USER_PW;
result.error = mxb::string_printf(PAM_AUTH_ERR_MSG, user.c_str(), service.c_str(),
pam_strerror(pam_handle, pam_status));
break;
default:
// More exotic error
result.type = PamResult::Result::MISC_ERROR;
result.error = mxb::string_printf(PAM_AUTH_ERR_MSG, user.c_str(), service.c_str(),
pam_strerror(pam_handle, pam_status));
break;
default:
// More exotic error
result.type = PamResult::Result::MISC_ERROR;
result.error = mxb::string_printf(PAM_AUTH_ERR_MSG, user.c_str(), service.c_str(),
pam_strerror(pam_handle, pam_status));
break;
}
}
else
@ -156,20 +155,19 @@ PamResult pam_authenticate(const string& user, const string& password, const str
pam_status = pam_acct_mgmt(pam_handle, 0);
switch (pam_status)
{
case PAM_SUCCESS:
result.type = PamResult::Result::SUCCESS;
break;
case PAM_SUCCESS:
result.type = PamResult::Result::SUCCESS;
break;
default:
// Credentials have already been checked to be ok, so this is a somewhat unexpected error.
result.type = PamResult::Result::ACCOUNT_INVALID;
result.error = mxb::string_printf(PAM_ACC_ERR_MSG, user.c_str(), service.c_str(),
pam_strerror(pam_handle, pam_status));
break;
default:
// Credentials have already been checked to be ok, so this is a somewhat unexpected error.
result.type = PamResult::Result::ACCOUNT_INVALID;
result.error = mxb::string_printf(PAM_ACC_ERR_MSG, user.c_str(), service.c_str(),
pam_strerror(pam_handle, pam_status));
break;
}
}
pam_end(pam_handle, pam_status);
return result;
}
}

View File

@ -19,7 +19,7 @@ namespace maxbase
// static
void Semaphore::get_current_timespec(time_t seconds,
long nseconds,
long nseconds,
timespec* pTs)
{
mxb_assert(nseconds <= 999999999);

View File

@ -19,7 +19,6 @@ namespace
{
thread_local char errbuf[512]; // Enough for all errors
}
const char* mxb_strerror(int error)
@ -73,5 +72,4 @@ char* trim(char* str)
{
return ltrim(rtrim(str));
}
}

View File

@ -103,8 +103,8 @@ int test_multi_http()
{
cout << __func__ << endl;
vector<string> urls = { "http://www.example.com/", "http://www.example.com/", "http://non-existent.xyz" };
vector<bool> expected_successes = { true, true, false };
vector<string> urls = {"http://www.example.com/", "http://www.example.com/", "http://non-existent.xyz"};
vector<bool> expected_successes = {true, true, false};
vector<mxb::http::Result> results = mxb::http::get(urls);
int rv = check_results(urls, expected_successes, results);
@ -118,8 +118,8 @@ int test_async_http()
int rv = EXIT_FAILURE;
vector<string> urls = { "http://www.example.com/", "http://www.example.com/", "http://non-existent.xyz" };
vector<bool> expected_successes = { true, true, false };
vector<string> urls = {"http://www.example.com/", "http://www.example.com/", "http://non-existent.xyz"};
vector<bool> expected_successes = {true, true, false};
mxb::http::Async http = mxb::http::get_async(urls);
while (http.perform(0) == mxb::http::Async::PENDING)
@ -148,7 +148,6 @@ int test_async_http()
return rv == EXIT_FAILURE ? 1 : 0;
}
}
uint64_t time_since_epoch_ms()

View File

@ -116,7 +116,6 @@ int test_rtrim()
cout << "rtrim()" << endl;
return test(rtrim_testcases, n_rtrim_testcases, mxb::rtrim);
}
}
int main(int argc, char* argv[])

View File

@ -111,7 +111,7 @@ uint64_t WorkerLoad::get_time_ms()
int rv = clock_gettime(CLOCK_MONOTONIC_COARSE, &t);
if (rv != 0)
{
mxb_assert(errno == EINVAL); // CLOCK_MONOTONIC_COARSE not supported.
mxb_assert(errno == EINVAL); // CLOCK_MONOTONIC_COARSE not supported.
rv = clock_gettime(CLOCK_MONOTONIC, &t);
mxb_assert(rv == 0);
}