From 265aacaf15daa8f98987b8c7bd2f49ba853394da Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Thu, 24 Nov 2016 13:31:29 +0200 Subject: [PATCH] GWBUF_DATA(...) explicitly returns uint8_t* --- include/maxscale/buffer.h | 2 +- server/core/buffer.c | 6 +++--- server/core/dcb.c | 4 ++-- server/core/test/testbuffer.c | 4 ++-- .../filter/cache/storage/storage_rocksdb/rocksdbstorage.cc | 2 +- server/modules/filter/hintfilter/hintparser.c | 4 ++-- server/modules/protocol/CDC/cdc.c | 2 +- server/modules/protocol/maxscaled/maxscaled.c | 6 +++--- server/modules/protocol/telnetd/telnetd.c | 4 ++-- server/modules/routing/avro/avro_client.c | 2 +- server/modules/routing/binlog/blr.c | 4 ++-- server/modules/routing/binlog/blr_slave.c | 2 +- server/modules/routing/cli/cli.c | 2 +- server/modules/routing/debugcli/debugcli.c | 2 +- server/modules/routing/maxinfo/maxinfo.c | 5 +++-- .../routing/readwritesplit/rwsplit_tmp_table_multi.c | 2 +- 16 files changed, 27 insertions(+), 26 deletions(-) diff --git a/include/maxscale/buffer.h b/include/maxscale/buffer.h index 3e9995faf..d303ce5d9 100644 --- a/include/maxscale/buffer.h +++ b/include/maxscale/buffer.h @@ -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) diff --git a/server/core/buffer.c b/server/core/buffer.c index e91e79b58..ff753c1f7 100644 --- a/server/core/buffer.c +++ b/server/core/buffer.c @@ -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) { diff --git a/server/core/dcb.c b/server/core/dcb.c index 35ceee80d..cc76a3a89 100644 --- a/server/core/dcb.c +++ b/server/core/dcb.c @@ -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); } diff --git a/server/core/test/testbuffer.c b/server/core/test/testbuffer.c index 119bd464d..ac645f1cd 100644 --- a/server/core/test/testbuffer.c +++ b/server/core/test/testbuffer.c @@ -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); diff --git a/server/modules/filter/cache/storage/storage_rocksdb/rocksdbstorage.cc b/server/modules/filter/cache/storage/storage_rocksdb/rocksdbstorage.cc index 2de463818..d09c45d1d 100644 --- a/server/modules/filter/cache/storage/storage_rocksdb/rocksdbstorage.cc +++ b/server/modules/filter/cache/storage/storage_rocksdb/rocksdbstorage.cc @@ -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(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); diff --git a/server/modules/filter/hintfilter/hintparser.c b/server/modules/filter/hintfilter/hintparser.c index 1f3dbe79f..0db3498fd 100644 --- a/server/modules/filter/hintfilter/hintparser.c +++ b/server/modules/filter/hintfilter/hintparser.c @@ -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 { diff --git a/server/modules/protocol/CDC/cdc.c b/server/modules/protocol/CDC/cdc.c index e4612780e..05031ed84 100644 --- a/server/modules/protocol/CDC/cdc.c +++ b/server/modules/protocol/CDC/cdc.c @@ -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 : ""); diff --git a/server/modules/protocol/maxscaled/maxscaled.c b/server/modules/protocol/maxscaled/maxscaled.c index d3a7a7eeb..60d809e81 100644 --- a/server/modules/protocol/maxscaled/maxscaled.c +++ b/server/modules/protocol/maxscaled/maxscaled.c @@ -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); diff --git a/server/modules/protocol/telnetd/telnetd.c b/server/modules/protocol/telnetd/telnetd.c index df802bf8e..a855d12d8 100644 --- a/server/modules/protocol/telnetd/telnetd.c +++ b/server/modules/protocol/telnetd/telnetd.c @@ -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) diff --git a/server/modules/routing/avro/avro_client.c b/server/modules/routing/avro/avro_client.c index 1caa06221..fc1341e0a 100644 --- a/server/modules/routing/avro/avro_client.c +++ b/server/modules/routing/avro/avro_client.c @@ -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) diff --git a/server/modules/routing/binlog/blr.c b/server/modules/routing/binlog/blr.c index 8f131f0ad..25b4db681 100644 --- a/server/modules/routing/binlog/blr.c +++ b/server/modules/routing/binlog/blr.c @@ -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) diff --git a/server/modules/routing/binlog/blr_slave.c b/server/modules/routing/binlog/blr_slave.c index 7a3219ab6..96a7ba1f7 100644 --- a/server/modules/routing/binlog/blr_slave.c +++ b/server/modules/routing/binlog/blr_slave.c @@ -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); diff --git a/server/modules/routing/cli/cli.c b/server/modules/routing/cli/cli.c index 478a2dcdf..61e6a21f8 100644 --- a/server/modules/routing/cli/cli.c +++ b/server/modules/routing/cli/cli.c @@ -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); diff --git a/server/modules/routing/debugcli/debugcli.c b/server/modules/routing/debugcli/debugcli.c index 1f86c82fc..6660c00bc 100644 --- a/server/modules/routing/debugcli/debugcli.c +++ b/server/modules/routing/debugcli/debugcli.c @@ -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); diff --git a/server/modules/routing/maxinfo/maxinfo.c b/server/modules/routing/maxinfo/maxinfo.c index 05eaa8d4d..3115899d8 100644 --- a/server/modules/routing/maxinfo/maxinfo.c +++ b/server/modules/routing/maxinfo/maxinfo.c @@ -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; diff --git a/server/modules/routing/readwritesplit/rwsplit_tmp_table_multi.c b/server/modules/routing/readwritesplit/rwsplit_tmp_table_multi.c index b6b43cb23..8eaa689ea 100644 --- a/server/modules/routing/readwritesplit/rwsplit_tmp_table_multi.c +++ b/server/modules/routing/readwritesplit/rwsplit_tmp_table_multi.c @@ -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;