GWBUF_DATA(...) explicitly returns uint8_t*

This commit is contained in:
Johan Wikman 2016-11-24 13:31:29 +02:00
parent 04753bbb76
commit 265aacaf15
16 changed files with 27 additions and 26 deletions

View File

@ -151,7 +151,7 @@ typedef struct gwbuf
* Macros to access the data in the buffers
*/
/*< First valid, unconsumed byte in the buffer */
#define GWBUF_DATA(b) ((b)->start)
#define GWBUF_DATA(b) ((uint8_t*)(b)->start)
/*< Number of bytes in the individual buffer */
#define GWBUF_LENGTH(b) ((char *)(b)->end - (char *)(b)->start)

View File

@ -854,9 +854,9 @@ gwbuf_get_property(GWBUF *buf, char *name)
GWBUF *
gwbuf_make_contiguous(GWBUF *orig)
{
GWBUF *newbuf;
char *ptr;
int len;
GWBUF *newbuf;
uint8_t *ptr;
int len;
if (orig == NULL)
{

View File

@ -2286,10 +2286,10 @@ dcb_printf(DCB *dcb, const char *fmt, ...)
return;
}
va_start(args, fmt);
vsnprintf(GWBUF_DATA(buf), 10240, fmt, args);
vsnprintf((char*)GWBUF_DATA(buf), 10240, fmt, args);
va_end(args);
buf->end = (void *)((char *)GWBUF_DATA(buf) + strlen(GWBUF_DATA(buf)));
buf->end = (void *)((char *)GWBUF_DATA(buf) + strlen((char*)GWBUF_DATA(buf)));
dcb->func.write(dcb, buf);
}

View File

@ -349,12 +349,12 @@ test1()
ss_dfprintf(stderr, "\t..done\nSet a property for the buffer");
gwbuf_add_property(buffer, "name", "value");
ss_info_dassert(0 == strcmp("value", gwbuf_get_property(buffer, "name")), "Should now have correct property");
strcpy(GWBUF_DATA(buffer), "The quick brown fox jumps over the lazy dog");
strcpy((char*)GWBUF_DATA(buffer), "The quick brown fox jumps over the lazy dog");
ss_dfprintf(stderr, "\t..done\nLoad some data into the buffer");
ss_info_dassert('q' == GWBUF_DATA_CHAR(buffer, 4), "Fourth character of buffer must be 'q'");
ss_info_dassert(-1 == GWBUF_DATA_CHAR(buffer, 105), "Hundred and fifth character of buffer must return -1");
ss_info_dassert(0 == GWBUF_IS_SQL(buffer), "Must say buffer is not SQL, as it does not have marker");
strcpy(GWBUF_DATA(buffer), "1234\x03SELECT * FROM sometable");
strcpy((char*)GWBUF_DATA(buffer), "1234\x03SELECT * FROM sometable");
ss_dfprintf(stderr, "\t..done\nLoad SQL data into the buffer");
ss_info_dassert(1 == GWBUF_IS_SQL(buffer), "Must say buffer is SQL, as it does have marker");
transform = gwbuf_clone_transform(buffer, GWBUF_TYPE_PLAINSQL);

View File

@ -470,7 +470,7 @@ cache_result_t RocksDBStorage::putValue(const char* pKey, const GWBUF* pValue)
ss_dassert(GWBUF_IS_CONTIGUOUS(pValue));
rocksdb::Slice key(pKey, ROCKSDB_KEY_LENGTH);
rocksdb::Slice value(static_cast<const char*>(GWBUF_DATA(pValue)), GWBUF_LENGTH(pValue));
rocksdb::Slice value((char*)GWBUF_DATA(pValue), GWBUF_LENGTH(pValue));
rocksdb::Status status = m_sDb->Put(writeOptions(), key, value);

View File

@ -220,7 +220,7 @@ hint_parser(HINT_SESSION *session, GWBUF *request)
if (buf)
{
len = GWBUF_LENGTH(buf);
ptr = GWBUF_DATA(buf);
ptr = (char*)GWBUF_DATA(buf);
}
}
while (buf);
@ -243,7 +243,7 @@ hint_parser(HINT_SESSION *session, GWBUF *request)
buf = buf->next;
if (buf)
{
ptr = GWBUF_DATA(buf);
ptr = (char*)GWBUF_DATA(buf);
}
else
{

View File

@ -191,7 +191,7 @@ cdc_read_event(DCB* dcb)
case CDC_STATE_HANDLE_REQUEST:
// handle CLOSE command, it shoudl be routed as well and client connection closed after last transmission
if (strncmp(GWBUF_DATA(head), "CLOSE", GWBUF_LENGTH(head)) == 0)
if (strncmp((char*)GWBUF_DATA(head), "CLOSE", GWBUF_LENGTH(head)) == 0)
{
MXS_INFO("%s: Client [%s] has requested CLOSE action",
dcb->service->name, dcb->remote != NULL ? dcb->remote : "");

View File

@ -102,7 +102,7 @@ static bool authenticate_unix_socket(MAXSCALED *protocol, DCB *dcb)
username = gwbuf_alloc(strlen(protocol->username) + 1);
strcpy(GWBUF_DATA(username), protocol->username);
strcpy((char*)GWBUF_DATA(username), protocol->username);
/* Authenticate the user */
if (dcb->authfunc.extract(dcb, username) == 0 &&
@ -261,7 +261,7 @@ static int maxscaled_read_event(DCB* dcb)
{
case MAXSCALED_STATE_LOGIN:
{
maxscaled->username = strndup(GWBUF_DATA(head), GWBUF_LENGTH(head));
maxscaled->username = strndup((char*)GWBUF_DATA(head), GWBUF_LENGTH(head));
maxscaled->state = MAXSCALED_STATE_PASSWD;
dcb_printf(dcb, MAXADMIN_AUTH_PASSWORD_PROMPT);
gwbuf_free(head);
@ -270,7 +270,7 @@ static int maxscaled_read_event(DCB* dcb)
case MAXSCALED_STATE_PASSWD:
{
char *password = strndup(GWBUF_DATA(head), GWBUF_LENGTH(head));
char *password = strndup((char*)GWBUF_DATA(head), GWBUF_LENGTH(head));
if (admin_verify_inet_user(maxscaled->username, password))
{
dcb_printf(dcb, MAXADMIN_AUTH_SUCCESS_REPLY);

View File

@ -181,7 +181,7 @@ static int telnetd_read_event(DCB* dcb)
switch (telnetd->state)
{
case TELNETD_STATE_LOGIN:
telnetd->username = strndup(GWBUF_DATA(head), GWBUF_LENGTH(head));
telnetd->username = strndup((char*)GWBUF_DATA(head), GWBUF_LENGTH(head));
/* Strip the cr/lf from the username */
t = strstr(telnetd->username, "\r\n");
if (t)
@ -194,7 +194,7 @@ static int telnetd_read_event(DCB* dcb)
gwbuf_consume(head, GWBUF_LENGTH(head));
break;
case TELNETD_STATE_PASSWD:
password = strndup(GWBUF_DATA(head), GWBUF_LENGTH(head));
password = strndup((char*)GWBUF_DATA(head), GWBUF_LENGTH(head));
/* Strip the cr/lf from the username */
t = strstr(password, "\r\n");
if (t)

View File

@ -130,7 +130,7 @@ avro_client_do_registration(AVRO_INSTANCE *router, AVRO_CLIENT *client, GWBUF *d
const char reg_uuid[] = "REGISTER UUID=";
const int reg_uuid_len = strlen(reg_uuid);
int data_len = GWBUF_LENGTH(data) - reg_uuid_len;
char *request = GWBUF_DATA(data);
char *request = (char*)GWBUF_DATA(data);
int ret = 0;
if (strstr(request, reg_uuid) != NULL)

View File

@ -1822,7 +1822,7 @@ int
blr_statistics(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue)
{
char result[BLRM_COM_STATISTICS_SIZE + 1] = "";
char *ptr;
uint8_t *ptr;
GWBUF *ret;
unsigned long len;
@ -1858,7 +1858,7 @@ blr_statistics(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue)
int
blr_ping(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue)
{
char *ptr;
uint8_t *ptr;
GWBUF *ret;
if ((ret = gwbuf_alloc(5)) == NULL)

View File

@ -345,7 +345,7 @@ blr_slave_query(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue)
char *ptr;
extern char *strcasestr();
qtext = GWBUF_DATA(queue);
qtext = (char*)GWBUF_DATA(queue);
query_len = extract_field((uint8_t *)qtext, 24) - 1;
qtext += 5; // Skip header and first byte of the payload
query_text = strndup(qtext, query_len);

View File

@ -270,7 +270,7 @@ execute(ROUTER *instance, void *router_session, GWBUF *queue)
/* Extract the characters */
while (queue && (cmdlen < CMDBUFLEN - 1))
{
const char* data = GWBUF_DATA(queue);
const char* data = (char*)GWBUF_DATA(queue);
int len = GWBUF_LENGTH(queue);
int n = MXS_MIN(len, CMDBUFLEN - cmdlen - 1);

View File

@ -291,7 +291,7 @@ execute(ROUTER *instance, void *router_session, GWBUF *queue)
/* Extract the characters */
while (queue && (cmdlen < CMDBUFLEN - 1))
{
const char* data = GWBUF_DATA(queue);
const char* data = (char*)GWBUF_DATA(queue);
int len = GWBUF_LENGTH(queue);
int n = MXS_MIN(len, CMDBUFLEN - cmdlen - 1);

View File

@ -422,7 +422,8 @@ getCapabilities(void)
static int
maxinfo_statistics(INFO_INSTANCE *router, INFO_SESSION *session, GWBUF *queue)
{
char result[1000], *ptr;
char result[1000];
uint8_t *ptr;
GWBUF *ret;
int len;
@ -456,7 +457,7 @@ maxinfo_statistics(INFO_INSTANCE *router, INFO_SESSION *session, GWBUF *queue)
static int
maxinfo_ping(INFO_INSTANCE *router, INFO_SESSION *session, GWBUF *queue)
{
char *ptr;
uint8_t *ptr;
GWBUF *ret;
int len;

View File

@ -327,7 +327,7 @@ bool check_for_multi_stmt(GWBUF *buf, void *protocol, mysql_server_cmd_t packet_
if (proto->client_capabilities & GW_MYSQL_CAPABILITIES_MULTI_STATEMENTS &&
packet_type == MYSQL_COM_QUERY)
{
char *ptr, *data = GWBUF_DATA(buf) + 5;
char *ptr, *data = (char*)GWBUF_DATA(buf) + 5;
/** Payload size without command byte */
int buflen = gw_mysql_get_byte3((uint8_t *)GWBUF_DATA(buf)) - 1;