Format core source code and headers

Formatted core source code and headers with Astyle.
This commit is contained in:
Markus Mäkelä
2017-01-17 13:32:26 +02:00
parent f109144841
commit 0b6b9c3d81
37 changed files with 1757 additions and 1742 deletions

View File

@ -41,11 +41,12 @@ public:
// pointer_type : The type of a pointer to an element, either "uint8_t*" or "const uint8_t*". // pointer_type : The type of a pointer to an element, either "uint8_t*" or "const uint8_t*".
// reference_type: The type of a reference to an element, either "uint8_t&" or "const uint8_t&". // reference_type: The type of a reference to an element, either "uint8_t&" or "const uint8_t&".
template<class buf_type, class pointer_type, class reference_type> template<class buf_type, class pointer_type, class reference_type>
class iterator_base : public std::iterator<std::forward_iterator_tag, // The type of the iterator class iterator_base : public std::iterator <
std::forward_iterator_tag, // The type of the iterator
uint8_t, // The type of the elems uint8_t, // The type of the elems
std::ptrdiff_t, // Difference between two its std::ptrdiff_t, // Difference between two its
pointer_type, // The type of pointer to an elem pointer_type, // The type of pointer to an elem
reference_type> // The reference type of an elem reference_type > // The reference type of an elem
{ {
public: public:
/** /**

View File

@ -55,7 +55,7 @@ MXS_BEGIN_DECLS
{ \ { \
if (!(exp)) { \ if (!(exp)) { \
ss_dfprintf(stderr, \ ss_dfprintf(stderr, \
"debug assert %s:%d\n", \ "debug assert %s:%d \n", \
(char*)__FILE__, \ (char*)__FILE__, \
__LINE__); \ __LINE__); \
ss_dfflush(stderr); \ ss_dfflush(stderr); \
@ -153,7 +153,7 @@ typedef enum skygw_chk_t
((t) == QUERY_TYPE_SHOW_TABLES ? "QUERY_TYPE_SHOW_TABLES" : \ ((t) == QUERY_TYPE_SHOW_TABLES ? "QUERY_TYPE_SHOW_TABLES" : \
"Unknown query type"))))))))))))))))))))))) "Unknown query type")))))))))))))))))))))))
#define STRLOGPRIORITYNAME(n)\ #define STRLOGPRIORITYNAME(n) \
((n) == LOG_EMERG ? "LOG_EMERG" : \ ((n) == LOG_EMERG ? "LOG_EMERG" : \
((n) == LOG_ALERT ? "LOG_ALERT" : \ ((n) == LOG_ALERT ? "LOG_ALERT" : \
((n) == LOG_CRIT ? "LOG_CRIT" : \ ((n) == LOG_CRIT ? "LOG_CRIT" : \
@ -198,7 +198,7 @@ typedef enum skygw_chk_t
((s) == SESSION_STATE_LISTENER ? "SESSION_STATE_LISTENER" : \ ((s) == SESSION_STATE_LISTENER ? "SESSION_STATE_LISTENER" : \
((s) == SESSION_STATE_ROUTER_READY ? "SESSION_STATE_ROUTER_READY" : \ ((s) == SESSION_STATE_ROUTER_READY ? "SESSION_STATE_ROUTER_READY" : \
((s) == SESSION_STATE_LISTENER_STOPPED ? "SESSION_STATE_LISTENER_STOPPED" : \ ((s) == SESSION_STATE_LISTENER_STOPPED ? "SESSION_STATE_LISTENER_STOPPED" : \
(s) == SESSION_STATE_STOPPING ? "SESSION_STATE_STOPPING":\ (s) == SESSION_STATE_STOPPING ? "SESSION_STATE_STOPPING": \
"SESSION_STATE_UNKNOWN")))))) "SESSION_STATE_UNKNOWN"))))))
#define STRPROTOCOLSTATE(s) ((s) == MXS_AUTH_STATE_INIT ? "MXS_AUTH_STATE_INIT" : \ #define STRPROTOCOLSTATE(s) ((s) == MXS_AUTH_STATE_INIT ? "MXS_AUTH_STATE_INIT" : \
@ -528,37 +528,37 @@ typedef enum skygw_chk_t
ss_info_dassert((b)->be_chk_top == CHK_NUM_BACKEND && \ ss_info_dassert((b)->be_chk_top == CHK_NUM_BACKEND && \
(b)->be_chk_tail == CHK_NUM_BACKEND, \ (b)->be_chk_tail == CHK_NUM_BACKEND, \
"BACKEND has invalid check fields"); \ "BACKEND has invalid check fields"); \
} }
#define CHK_BACKEND_REF(r) { \ #define CHK_BACKEND_REF(r) { \
ss_info_dassert((r)->bref_chk_top == CHK_NUM_BACKEND_REF && \ ss_info_dassert((r)->bref_chk_top == CHK_NUM_BACKEND_REF && \
(r)->bref_chk_tail == CHK_NUM_BACKEND_REF, \ (r)->bref_chk_tail == CHK_NUM_BACKEND_REF, \
"Backend reference has invalid check fields"); \ "Backend reference has invalid check fields"); \
} }
#define CHK_PREP_STMT(p) { \ #define CHK_PREP_STMT(p) { \
ss_info_dassert((p)->pstmt_chk_top == CHK_NUM_PREP_STMT && \ ss_info_dassert((p)->pstmt_chk_top == CHK_NUM_PREP_STMT && \
(p)->pstmt_chk_tail == CHK_NUM_PREP_STMT, \ (p)->pstmt_chk_tail == CHK_NUM_PREP_STMT, \
"Prepared statement struct has invalid check fields"); \ "Prepared statement struct has invalid check fields"); \
} }
#define CHK_PARSING_INFO(p) { \ #define CHK_PARSING_INFO(p) { \
ss_info_dassert((p)->pi_chk_top == CHK_NUM_PINFO && \ ss_info_dassert((p)->pi_chk_top == CHK_NUM_PINFO && \
(p)->pi_chk_tail == CHK_NUM_PINFO, \ (p)->pi_chk_tail == CHK_NUM_PINFO, \
"Parsing info struct has invalid check fields"); \ "Parsing info struct has invalid check fields"); \
} }
#define CHK_MYSQL_SESSION(s) { \ #define CHK_MYSQL_SESSION(s) { \
ss_info_dassert((s)->myses_chk_top == CHK_NUM_MYSQLSES && \ ss_info_dassert((s)->myses_chk_top == CHK_NUM_MYSQLSES && \
(s)->myses_chk_tail == CHK_NUM_MYSQLSES, \ (s)->myses_chk_tail == CHK_NUM_MYSQLSES, \
"MYSQL session struct has invalid check fields"); \ "MYSQL session struct has invalid check fields"); \
} }
#define CHK_ADMIN_SESSION(s) { \ #define CHK_ADMIN_SESSION(s) { \
ss_info_dassert((s)->adminses_chk_top == CHK_NUM_ADMINSES && \ ss_info_dassert((s)->adminses_chk_top == CHK_NUM_ADMINSES && \
(s)->adminses_chk_tail == CHK_NUM_ADMINSES, \ (s)->adminses_chk_tail == CHK_NUM_ADMINSES, \
"Admin session struct has invalid check fields"); \ "Admin session struct has invalid check fields"); \
} }
MXS_END_DECLS MXS_END_DECLS

View File

@ -71,7 +71,8 @@ typedef struct ssl_listener
char *ssl_key; /*< SSL private key */ char *ssl_key; /*< SSL private key */
char *ssl_ca_cert; /*< SSL CA certificate */ char *ssl_ca_cert; /*< SSL CA certificate */
bool ssl_init_done; /*< If SSL has already been initialized for this service */ bool ssl_init_done; /*< If SSL has already been initialized for this service */
struct ssl_listener *next; /*< Next SSL configuration, currently used to store obsolete configurations */ struct ssl_listener
*next; /*< Next SSL configuration, currently used to store obsolete configurations */
} SSL_LISTENER; } SSL_LISTENER;
int ssl_authenticate_client(struct dcb *dcb, bool is_capable); int ssl_authenticate_client(struct dcb *dcb, bool is_capable);

View File

@ -107,7 +107,7 @@ typedef struct mxs_enum_value
{ {
const char *name; /**< Name of the enum value */ const char *name; /**< Name of the enum value */
int enum_value; /**< The integer value of the enum */ int enum_value; /**< The integer value of the enum */
}MXS_ENUM_VALUE; } MXS_ENUM_VALUE;
/** Module parameter declaration */ /** Module parameter declaration */
typedef struct mxs_module_param typedef struct mxs_module_param

View File

@ -66,7 +66,7 @@ static inline int
mxs_queue_count(QUEUE_CONFIG *queue_config) mxs_queue_count(QUEUE_CONFIG *queue_config)
{ {
int count = queue_config->end - queue_config->start; int count = queue_config->end - queue_config->start;
return count < 0 ? (count + queue_config->queue_limit + 1): count; return count < 0 ? (count + queue_config->queue_limit + 1) : count;
} }
MXS_END_DECLS MXS_END_DECLS

View File

@ -531,8 +531,8 @@ int gwbuf_compare(const GWBUF* lhs, const GWBUF* rhs)
uint8_t lc; uint8_t lc;
uint8_t rc; uint8_t rc;
ss_debug(bool rv1 =) gwbuf_get_byte(&lhs, &loffset, &lc); ss_debug(bool rv1 = ) gwbuf_get_byte(&lhs, &loffset, &lc);
ss_debug(bool rv2 =) gwbuf_get_byte(&rhs, &roffset, &rc); ss_debug(bool rv2 = ) gwbuf_get_byte(&rhs, &roffset, &rc);
ss_dassert(rv1 && rv2); ss_dassert(rv1 && rv2);

View File

@ -1840,12 +1840,12 @@ void printAllDCBs()
void void
dprintOneDCB(DCB *pdcb, DCB *dcb) dprintOneDCB(DCB *pdcb, DCB *dcb)
{ {
/* TODO: Uncomment once listmanager code is in use /* TODO: Uncomment once listmanager code is in use
if (false == dcb->entry_is_in_use) if (false == dcb->entry_is_in_use)
{ {
return; return;
} }
*/ */
dcb_printf(pdcb, "DCB: %p\n", (void *)dcb); dcb_printf(pdcb, "DCB: %p\n", (void *)dcb);
dcb_printf(pdcb, "\tDCB state: %s\n", dcb_printf(pdcb, "\tDCB state: %s\n",
gw_dcb_state2string(dcb->state)); gw_dcb_state2string(dcb->state));

View File

@ -235,7 +235,7 @@ listener_init_SSL(SSL_LISTENER *ssl_listener)
if (!ssl_listener->ssl_init_done) if (!ssl_listener->ssl_init_done)
{ {
switch(ssl_listener->ssl_method_type) switch (ssl_listener->ssl_method_type)
{ {
case SERVICE_TLS10: case SERVICE_TLS10:
ssl_listener->method = (SSL_METHOD*)TLSv1_method(); ssl_listener->method = (SSL_METHOD*)TLSv1_method();
@ -356,9 +356,10 @@ listener_init_SSL(SSL_LISTENER *ssl_listener)
static RSA * static RSA *
tmp_rsa_callback(SSL *s, int is_export, int keylength) tmp_rsa_callback(SSL *s, int is_export, int keylength)
{ {
RSA *rsa_tmp=NULL; RSA *rsa_tmp = NULL;
switch (keylength) { switch (keylength)
{
case 512: case 512:
if (rsa_512) if (rsa_512)
{ {
@ -367,28 +368,28 @@ tmp_rsa_callback(SSL *s, int is_export, int keylength)
else else
{ {
/* generate on the fly, should not happen in this example */ /* generate on the fly, should not happen in this example */
rsa_tmp = RSA_generate_key(keylength,RSA_F4,NULL,NULL); rsa_tmp = RSA_generate_key(keylength, RSA_F4, NULL, NULL);
rsa_512 = rsa_tmp; /* Remember for later reuse */ rsa_512 = rsa_tmp; /* Remember for later reuse */
} }
break; break;
case 1024: case 1024:
if (rsa_1024) if (rsa_1024)
{ {
rsa_tmp=rsa_1024; rsa_tmp = rsa_1024;
} }
break; break;
default: default:
/* Generating a key on the fly is very costly, so use what is there */ /* Generating a key on the fly is very costly, so use what is there */
if (rsa_1024) if (rsa_1024)
{ {
rsa_tmp=rsa_1024; rsa_tmp = rsa_1024;
} }
else else
{ {
rsa_tmp=rsa_512; /* Use at least a shorter key */ rsa_tmp = rsa_512; /* Use at least a shorter key */
} }
} }
return(rsa_tmp); return (rsa_tmp);
} }
/** /**

View File

@ -55,11 +55,12 @@ typedef enum { MES_RC_FAIL, MES_RC_SUCCESS, MES_RC_TIMEOUT } skygw_mes_rc_t;
static const char* timestamp_formatstr = "%04d-%02d-%02d %02d:%02d:%02d "; static const char* timestamp_formatstr = "%04d-%02d-%02d %02d:%02d:%02d ";
/** One for terminating '\0' */ /** One for terminating '\0' */
static const size_t timestamp_len = (4+1 +2+1 +2+1 +2+1 +2+1 +2+3 +1) * sizeof(char); static const size_t timestamp_len = (4 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 3 + 1) * sizeof(char);
static const char* timestamp_formatstr_hp = "%04d-%02d-%02d %02d:%02d:%02d.%03d "; static const char* timestamp_formatstr_hp = "%04d-%02d-%02d %02d:%02d:%02d.%03d ";
/** One for terminating '\0' */ /** One for terminating '\0' */
static const size_t timestamp_len_hp = (4+1 +2+1 +2+1 +2+1 +2+1 +2+1+3+3 +1) * sizeof(char); static const size_t timestamp_len_hp = (4 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 3 + 3 + 1) * sizeof(
char);
struct skygw_thread_st struct skygw_thread_st
{ {

View File

@ -571,16 +571,20 @@ static uint64_t unpack_bytes(uint8_t *ptr, size_t bytes)
val = (uint64_t)ptr[3] | ((uint64_t)ptr[2] << 8) | ((uint64_t)ptr[1] << 16) | ((uint64_t)ptr[0] << 24); val = (uint64_t)ptr[3] | ((uint64_t)ptr[2] << 8) | ((uint64_t)ptr[1] << 16) | ((uint64_t)ptr[0] << 24);
break; break;
case 5: case 5:
val = (uint64_t)ptr[4] | ((uint64_t)ptr[3] << 8) | ((uint64_t)ptr[2] << 16) | ((uint64_t)ptr[1] << 24) | ((uint64_t)ptr[0] << 32); val = (uint64_t)ptr[4] | ((uint64_t)ptr[3] << 8) | ((uint64_t)ptr[2] << 16) | ((uint64_t)ptr[1] << 24) | ((
uint64_t)ptr[0] << 32);
break; break;
case 6: case 6:
val = (uint64_t)ptr[5] | ((uint64_t)ptr[4] << 8) | ((uint64_t)ptr[3] << 16) | ((uint64_t)ptr[2] << 24) | ((uint64_t)ptr[1] << 32) | ((uint64_t)ptr[0] << 40); val = (uint64_t)ptr[5] | ((uint64_t)ptr[4] << 8) | ((uint64_t)ptr[3] << 16) | ((uint64_t)ptr[2] << 24) | ((
uint64_t)ptr[1] << 32) | ((uint64_t)ptr[0] << 40);
break; break;
case 7: case 7:
val = (uint64_t)ptr[6] | ((uint64_t)ptr[5] << 8) | ((uint64_t)ptr[4] << 16) | ((uint64_t)ptr[3] << 24) | ((uint64_t)ptr[2] << 32) | ((uint64_t)ptr[1] << 40) | ((uint64_t)ptr[0] << 48); val = (uint64_t)ptr[6] | ((uint64_t)ptr[5] << 8) | ((uint64_t)ptr[4] << 16) | ((uint64_t)ptr[3] << 24) | ((
uint64_t)ptr[2] << 32) | ((uint64_t)ptr[1] << 40) | ((uint64_t)ptr[0] << 48);
break; break;
case 8: case 8:
val = (uint64_t)ptr[7] | ((uint64_t)ptr[6] << 8) | ((uint64_t)ptr[5] << 16) | ((uint64_t)ptr[4] << 24) | ((uint64_t)ptr[3] << 32) | ((uint64_t)ptr[2] << 40) | ((uint64_t)ptr[1] << 48) | ((uint64_t)ptr[0] << 56); val = (uint64_t)ptr[7] | ((uint64_t)ptr[6] << 8) | ((uint64_t)ptr[5] << 16) | ((uint64_t)ptr[4] << 24) | ((
uint64_t)ptr[3] << 32) | ((uint64_t)ptr[2] << 40) | ((uint64_t)ptr[1] << 48) | ((uint64_t)ptr[0] << 56);
break; break;
} }

View File

@ -1629,11 +1629,16 @@ dShowEventStats(DCB *pdcb)
int i; int i;
dcb_printf(pdcb, "\nEvent statistics.\n"); dcb_printf(pdcb, "\nEvent statistics.\n");
dcb_printf(pdcb, "Maximum queue time: %3" PRId64 "00ms\n", ts_stats_get(queueStats.maxqtime, TS_STATS_MAX)); dcb_printf(pdcb, "Maximum queue time: %3" PRId64 "00ms\n", ts_stats_get(queueStats.maxqtime,
dcb_printf(pdcb, "Maximum execution time: %3" PRId64 "00ms\n", ts_stats_get(queueStats.maxexectime, TS_STATS_MAX)); TS_STATS_MAX));
dcb_printf(pdcb, "Maximum event queue length: %3" PRId64 "\n", ts_stats_get(pollStats.evq_max, TS_STATS_MAX)); dcb_printf(pdcb, "Maximum execution time: %3" PRId64 "00ms\n", ts_stats_get(queueStats.maxexectime,
dcb_printf(pdcb, "Total event queue length: %3" PRId64 "\n", ts_stats_get(pollStats.evq_length, TS_STATS_SUM)); TS_STATS_MAX));
dcb_printf(pdcb, "Average event queue length: %3" PRId64 "\n", ts_stats_get(pollStats.evq_length, TS_STATS_AVG)); dcb_printf(pdcb, "Maximum event queue length: %3" PRId64 "\n", ts_stats_get(pollStats.evq_max,
TS_STATS_MAX));
dcb_printf(pdcb, "Total event queue length: %3" PRId64 "\n", ts_stats_get(pollStats.evq_length,
TS_STATS_SUM));
dcb_printf(pdcb, "Average event queue length: %3" PRId64 "\n", ts_stats_get(pollStats.evq_length,
TS_STATS_AVG));
dcb_printf(pdcb, "\n"); dcb_printf(pdcb, "\n");
dcb_printf(pdcb, " | Number of events\n"); dcb_printf(pdcb, " | Number of events\n");
dcb_printf(pdcb, "Duration | Queued | Executed\n"); dcb_printf(pdcb, "Duration | Queued | Executed\n");

View File

@ -55,7 +55,7 @@ QUEUE_CONFIG
QUEUE_CONFIG *new_queue = (QUEUE_CONFIG *)MXS_CALLOC(1, sizeof(QUEUE_CONFIG)); QUEUE_CONFIG *new_queue = (QUEUE_CONFIG *)MXS_CALLOC(1, sizeof(QUEUE_CONFIG));
if (new_queue) if (new_queue)
{ {
new_queue->queue_array = MXS_CALLOC(limit+1, sizeof(QUEUE_ENTRY)); new_queue->queue_array = MXS_CALLOC(limit + 1, sizeof(QUEUE_ENTRY));
if (new_queue->queue_array) if (new_queue->queue_array)
{ {
new_queue->queue_limit = limit; new_queue->queue_limit = limit;

View File

@ -514,16 +514,16 @@ dprintSession(DCB *dcb, SESSION *print_session)
if (print_session->client_dcb && print_session->client_dcb->remote) if (print_session->client_dcb && print_session->client_dcb->remote)
{ {
double idle = (hkheartbeat - print_session->client_dcb->last_read); double idle = (hkheartbeat - print_session->client_dcb->last_read);
idle = idle > 0 ? idle/10.f : 0; idle = idle > 0 ? idle / 10.f : 0;
dcb_printf(dcb, "\tClient Address: %s%s%s\n", dcb_printf(dcb, "\tClient Address: %s%s%s\n",
print_session->client_dcb->user?print_session->client_dcb->user:"", print_session->client_dcb->user ? print_session->client_dcb->user : "",
print_session->client_dcb->user?"@":"", print_session->client_dcb->user ? "@" : "",
print_session->client_dcb->remote); print_session->client_dcb->remote);
dcb_printf(dcb, "\tConnected: %s\n", dcb_printf(dcb, "\tConnected: %s\n",
asctime_r(localtime_r(&print_session->stats.connect, &result), buf)); asctime_r(localtime_r(&print_session->stats.connect, &result), buf));
if (print_session->client_dcb->state == DCB_STATE_POLLING) if (print_session->client_dcb->state == DCB_STATE_POLLING)
{ {
dcb_printf(dcb, "\tIdle: %.0f seconds\n",idle); dcb_printf(dcb, "\tIdle: %.0f seconds\n", idle);
} }
} }

View File

@ -467,7 +467,7 @@ void acquire_lock(int* l)
misscount += 1; misscount += 1;
if (misscount > 10) if (misscount > 10)
{ {
ts1.tv_nsec = (random_jkiss() % misscount)*1000000; ts1.tv_nsec = (random_jkiss() % misscount) * 1000000;
nanosleep(&ts1, NULL); nanosleep(&ts1, NULL);
} }
} }

View File

@ -359,7 +359,8 @@ int test_domain_matching()
const char *ns = "mysqlmon"; const char *ns = "mysqlmon";
const char *id = "test_domain_matching"; const char *id = "test_domain_matching";
modulecmd_arg_type_t args[] = { modulecmd_arg_type_t args[] =
{
{MODULECMD_ARG_MONITOR | MODULECMD_ARG_NAME_MATCHES_DOMAIN, ""} {MODULECMD_ARG_MONITOR | MODULECMD_ARG_NAME_MATCHES_DOMAIN, ""}
}; };

View File

@ -755,7 +755,8 @@ char* replace_literal(char* haystack, const char* needle, const char* replacemen
memcpy(newstr, haystack, match.rm_so + 1); memcpy(newstr, haystack, match.rm_so + 1);
memcpy(newstr + match.rm_so + 1, replacement, rlen); memcpy(newstr + match.rm_so + 1, replacement, rlen);
/** +1 is terminating byte */ /** +1 is terminating byte */
memcpy(newstr + match.rm_so + 1 + rlen, haystack + match.rm_so + 1 + nlen, hlen - (match.rm_so + 1) - nlen + 1); memcpy(newstr + match.rm_so + 1 + rlen, haystack + match.rm_so + 1 + nlen,
hlen - (match.rm_so + 1) - nlen + 1);
regfree(&re); regfree(&re);
free(haystack); free(haystack);