MXS-1840 Compile all routers as C++
Minimal changes, only what is needed in order to make it compile.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
add_library(maxinfo SHARED maxinfo.c maxinfo_parse.c maxinfo_error.c maxinfo_exec.c)
|
||||
add_library(maxinfo SHARED maxinfo.cc maxinfo_parse.cc maxinfo_error.cc maxinfo_exec.cc)
|
||||
set_target_properties(maxinfo PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${MAXSCALE_LIBDIR} VERSION "1.0.0")
|
||||
target_link_libraries(maxinfo maxscale-common)
|
||||
install_module(maxinfo core)
|
||||
|
@ -92,7 +92,7 @@ static INFO_INSTANCE *instances;
|
||||
*
|
||||
* @return The module object
|
||||
*/
|
||||
MXS_MODULE* MXS_CREATE_MODULE()
|
||||
extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{
|
||||
MXS_NOTICE("Initialise MaxInfo router module.");
|
||||
spinlock_init(&instlock);
|
||||
@ -149,7 +149,7 @@ createInstance(SERVICE *service, char **options)
|
||||
INFO_INSTANCE *inst;
|
||||
int i;
|
||||
|
||||
if ((inst = MXS_MALLOC(sizeof(INFO_INSTANCE))) == NULL)
|
||||
if ((inst = static_cast<INFO_INSTANCE*>(MXS_MALLOC(sizeof(INFO_INSTANCE)))) == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@ -207,7 +207,7 @@ newSession(MXS_ROUTER *instance, MXS_SESSION *session)
|
||||
|
||||
session->state = SESSION_STATE_READY;
|
||||
|
||||
return (void *)client;
|
||||
return reinterpret_cast<MXS_ROUTER_SESSION*>(client);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -329,7 +329,7 @@ execute(MXS_ROUTER *rinstance, MXS_ROUTER_SESSION *router_session, GWBUF *queue)
|
||||
}
|
||||
data = (uint8_t *)GWBUF_DATA(queue);
|
||||
length = data[0] + (data[1] << 8) + (data[2] << 16);
|
||||
if (length + 4 > GWBUF_LENGTH(queue))
|
||||
if (length + 4 > static_cast<int>(GWBUF_LENGTH(queue)))
|
||||
{
|
||||
// Incomplete packet, must be buffered
|
||||
session->queue = queue;
|
||||
@ -684,7 +684,7 @@ typedef RESULTSET *(*RESULTSETFUNC)();
|
||||
*/
|
||||
static struct uri_table
|
||||
{
|
||||
char *uri;
|
||||
const char *uri;
|
||||
RESULTSETFUNC func;
|
||||
} supported_uri[] =
|
||||
{
|
@ -135,9 +135,8 @@ typedef enum
|
||||
extern MAXINFO_TREE *maxinfo_parse(char *, PARSE_ERROR *);
|
||||
extern void maxinfo_free_tree(MAXINFO_TREE *);
|
||||
extern void maxinfo_execute(DCB *, MAXINFO_TREE *);
|
||||
extern void maxinfo_send_error(DCB *, int, char *);
|
||||
extern void maxinfo_send_error(DCB *, int, const char *);
|
||||
extern void maxinfo_send_parse_error(DCB *, char *, PARSE_ERROR);
|
||||
extern void maxinfo_send_error(DCB *, int, char *);
|
||||
extern RESULTSET *maxinfo_variables();
|
||||
extern RESULTSET *maxinfo_status();
|
||||
|
||||
|
@ -51,7 +51,7 @@
|
||||
void
|
||||
maxinfo_send_parse_error(DCB *dcb, char *sql, PARSE_ERROR err)
|
||||
{
|
||||
char *desc = "";
|
||||
const char *desc = "";
|
||||
char *msg;
|
||||
int len;
|
||||
|
||||
@ -86,7 +86,7 @@ maxinfo_send_parse_error(DCB *dcb, char *sql, PARSE_ERROR err)
|
||||
* @param msg The slave server instance
|
||||
*/
|
||||
void
|
||||
maxinfo_send_error(DCB *dcb, int errcode, char *msg)
|
||||
maxinfo_send_error(DCB *dcb, int errcode, const char *msg)
|
||||
{
|
||||
GWBUF *pkt;
|
||||
unsigned char *data;
|
@ -55,7 +55,7 @@ static void exec_show(DCB *dcb, MAXINFO_TREE *tree);
|
||||
static void exec_select(DCB *dcb, MAXINFO_TREE *tree);
|
||||
static void exec_show_variables(DCB *dcb, MAXINFO_TREE *filter);
|
||||
static void exec_show_status(DCB *dcb, MAXINFO_TREE *filter);
|
||||
static int maxinfo_pattern_match(char *pattern, char *str);
|
||||
static int maxinfo_pattern_match(const char *pattern, const char *str);
|
||||
static void exec_flush(DCB *dcb, MAXINFO_TREE *tree);
|
||||
static void exec_set(DCB *dcb, MAXINFO_TREE *tree);
|
||||
static void exec_clear(DCB *dcb, MAXINFO_TREE *tree);
|
||||
@ -272,7 +272,7 @@ exec_show_eventTimes(DCB *dcb, MAXINFO_TREE *tree)
|
||||
*/
|
||||
static struct
|
||||
{
|
||||
char *name;
|
||||
const char *name;
|
||||
void (*func)(DCB *, MAXINFO_TREE *);
|
||||
} show_commands[] =
|
||||
{
|
||||
@ -334,7 +334,7 @@ void exec_flush_logs(DCB *dcb, MAXINFO_TREE *tree)
|
||||
*/
|
||||
static struct
|
||||
{
|
||||
char *name;
|
||||
const char *name;
|
||||
void (*func)(DCB *, MAXINFO_TREE *);
|
||||
} flush_commands[] =
|
||||
{
|
||||
@ -421,7 +421,7 @@ void exec_set_server(DCB *dcb, MAXINFO_TREE *tree)
|
||||
*/
|
||||
static struct
|
||||
{
|
||||
char *name;
|
||||
const char *name;
|
||||
void (*func)(DCB *, MAXINFO_TREE *);
|
||||
} set_commands[] =
|
||||
{
|
||||
@ -502,7 +502,7 @@ void exec_clear_server(DCB *dcb, MAXINFO_TREE *tree)
|
||||
*/
|
||||
static struct
|
||||
{
|
||||
char *name;
|
||||
const char *name;
|
||||
void (*func)(DCB *, MAXINFO_TREE *);
|
||||
} clear_commands[] =
|
||||
{
|
||||
@ -621,7 +621,7 @@ void exec_shutdown_service(DCB *dcb, MAXINFO_TREE *tree)
|
||||
*/
|
||||
static struct
|
||||
{
|
||||
char *name;
|
||||
const char *name;
|
||||
void (*func)(DCB *, MAXINFO_TREE *);
|
||||
} shutdown_commands[] =
|
||||
{
|
||||
@ -731,7 +731,7 @@ void exec_restart_service(DCB *dcb, MAXINFO_TREE *tree)
|
||||
*/
|
||||
static struct
|
||||
{
|
||||
char *name;
|
||||
const char *name;
|
||||
void (*func)(DCB *, MAXINFO_TREE *);
|
||||
} restart_commands[] =
|
||||
{
|
||||
@ -777,10 +777,10 @@ exec_restart(DCB *dcb, MAXINFO_TREE *tree)
|
||||
static char *
|
||||
getVersion()
|
||||
{
|
||||
return MAXSCALE_VERSION;
|
||||
return const_cast<char*>(MAXSCALE_VERSION);
|
||||
}
|
||||
|
||||
static char *versionComment = "MariaDB MaxScale";
|
||||
static const char *versionComment = "MariaDB MaxScale";
|
||||
/**
|
||||
* Return the current MaxScale version
|
||||
*
|
||||
@ -789,7 +789,7 @@ static char *versionComment = "MariaDB MaxScale";
|
||||
static char *
|
||||
getVersionComment()
|
||||
{
|
||||
return versionComment;
|
||||
return const_cast<char*>(versionComment);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -813,7 +813,7 @@ typedef void *(*STATSFUNC)();
|
||||
*/
|
||||
static struct
|
||||
{
|
||||
char *name;
|
||||
const char *name;
|
||||
int type;
|
||||
STATSFUNC func;
|
||||
} variables[] =
|
||||
@ -833,7 +833,7 @@ static struct
|
||||
typedef struct
|
||||
{
|
||||
int index;
|
||||
char *like;
|
||||
const char *like;
|
||||
} VARCONTEXT;
|
||||
/**
|
||||
* Callback function to populate rows of the show variable
|
||||
@ -894,7 +894,7 @@ exec_show_variables(DCB *dcb, MAXINFO_TREE *filter)
|
||||
RESULTSET *result;
|
||||
VARCONTEXT *context;
|
||||
|
||||
if ((context = MXS_MALLOC(sizeof(VARCONTEXT))) == NULL)
|
||||
if ((context = static_cast<VARCONTEXT*>(MXS_MALLOC(sizeof(VARCONTEXT)))) == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -931,7 +931,7 @@ maxinfo_variables()
|
||||
{
|
||||
RESULTSET *result;
|
||||
VARCONTEXT *context;
|
||||
if ((context = MXS_MALLOC(sizeof(VARCONTEXT))) == NULL)
|
||||
if ((context = static_cast<VARCONTEXT*>(MXS_MALLOC(sizeof(VARCONTEXT)))) == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@ -1079,9 +1079,9 @@ maxinfo_max_event_exec_time()
|
||||
*/
|
||||
static struct
|
||||
{
|
||||
char *name;
|
||||
int type;
|
||||
STATSFUNC func;
|
||||
const char *name;
|
||||
int type;
|
||||
STATSFUNC func;
|
||||
} status[] =
|
||||
{
|
||||
{ "Uptime", VT_INT, (STATSFUNC)maxscale_uptime },
|
||||
@ -1166,7 +1166,7 @@ exec_show_status(DCB *dcb, MAXINFO_TREE *filter)
|
||||
RESULTSET *result;
|
||||
VARCONTEXT *context;
|
||||
|
||||
if ((context = MXS_MALLOC(sizeof(VARCONTEXT))) == NULL)
|
||||
if ((context = static_cast<VARCONTEXT*>(MXS_MALLOC(sizeof(VARCONTEXT)))) == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -1203,7 +1203,7 @@ maxinfo_status()
|
||||
{
|
||||
RESULTSET *result;
|
||||
VARCONTEXT *context;
|
||||
if ((context = MXS_MALLOC(sizeof(VARCONTEXT))) == NULL)
|
||||
if ((context = static_cast<VARCONTEXT*>(MXS_MALLOC(sizeof(VARCONTEXT)))) == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@ -1242,10 +1242,10 @@ exec_select(DCB *dcb, MAXINFO_TREE *tree)
|
||||
* @return Zero on match
|
||||
*/
|
||||
static int
|
||||
maxinfo_pattern_match(char *pattern, char *str)
|
||||
maxinfo_pattern_match(const char *pattern, const char *str)
|
||||
{
|
||||
int anchor = 0, len, trailing;
|
||||
char *fixed;
|
||||
const char *fixed;
|
||||
|
||||
if (*pattern != '%')
|
||||
{
|
||||
@ -1275,7 +1275,7 @@ maxinfo_pattern_match(char *pattern, char *str)
|
||||
}
|
||||
else
|
||||
{
|
||||
char *portion = MXS_MALLOC(len + 1);
|
||||
char *portion = static_cast<char*>(MXS_MALLOC(len + 1));
|
||||
MXS_ABORT_IF_NULL(portion);
|
||||
int rval;
|
||||
strncpy(portion, fixed, len - trailing);
|
@ -305,7 +305,7 @@ maxinfo_free_tree(MAXINFO_TREE *tree)
|
||||
*/
|
||||
static struct
|
||||
{
|
||||
char *text;
|
||||
const char *text;
|
||||
int token;
|
||||
} keywords[] =
|
||||
{
|
Reference in New Issue
Block a user