MXS-2495 Cleanup GWBUF interface

All GWBUF macros that address a single link in a chain are now
simple wrappers for equivalent gwbuf_link-functions.

Next step is to drop the macros and replace their use with calls
to the functions.
This commit is contained in:
Johan Wikman
2019-05-16 14:33:01 +03:00
parent d1affba34d
commit 0f714e9ad4
4 changed files with 46 additions and 24 deletions

View File

@ -39,6 +39,12 @@
#include <maxscale/buffer.hh>
#include <maxscale/hint.h>
/*< Return the byte at offset byte from the start of the unconsumed portion of the buffer */
#define GWBUF_DATA_CHAR(b, byte) (GWBUF_LENGTH(b) < ((byte) + 1) ? -1 : *(((char*)(b)->start) + 4))
/*< Check that the data in a buffer has the SQL marker*/
#define GWBUF_IS_SQL(b) (0x03 == GWBUF_DATA_CHAR(b, 4))
/**
* Generate predefined test data
*

View File

@ -593,7 +593,7 @@ void test_large_packets()
{
GWBUF* buffer = gwbuf_append(create_buffer(0x00ffffff), create_buffer(i));
mxb_assert(gwbuf_length(buffer) == 0xffffffUL + i + 8);
GWBUF_RTRIM(buffer->next, 1)
GWBUF_RTRIM(buffer->next, 1);
GWBUF* complete = modutil_get_complete_packets(&buffer);
mxb_assert_message(buffer, "Incomplete buffer is not NULL");
mxb_assert_message(complete, "The complete buffer is not NULL");

View File

@ -729,7 +729,7 @@ static inline bool collecting_resultset(MySQLProtocol* proto, uint64_t capabilit
*/
static inline bool not_ok_packet(const GWBUF* buffer)
{
uint8_t* data = GWBUF_DATA(buffer);
const uint8_t* data = GWBUF_DATA(buffer);
return data[4] != MYSQL_REPLY_OK
|| // Should be more than 7 bytes of payload