diff --git a/include/assoc.h b/include/assoc.h index fc5bb4026a3e245ef751b291766ee836a4075d20..937101ecfa2c9a2836ff0e5ddb270ed566f0275b 100644 --- a/include/assoc.h +++ b/include/assoc.h @@ -69,7 +69,7 @@ struct mh_i64ptr_node_t { /* * Map: (char *) => (void *) */ -static inline int lstrcmp(const void *a, const void *b) +static inline int lstrcmp(const char *a, const char *b) { unsigned int al, bl; @@ -83,7 +83,7 @@ static inline int lstrcmp(const void *a, const void *b) #include <third_party/PMurHash.h> #define mh_name _lstrptr struct mh_lstrptr_node_t { - const void *key; + const char *key; void *val; }; @@ -93,7 +93,7 @@ struct mh_lstrptr_node_t { static inline u32 mh_strptr_hash(const mh_node_t *a, mh_arg_t arg) { (void) arg; - const void *_k = (a->key); + const char *_k = a->key; const u32 l = load_varint32(&_k); return PMurHash32(13, _k, l); } diff --git a/include/box/box.h b/include/box/box.h index 08fa5ca882545f3081d6220e29b5c15302db5185..ff250eec86cdbdd61b17a743dead9fc1ec372393 100644 --- a/include/box/box.h +++ b/include/box/box.h @@ -60,7 +60,7 @@ void box_free(void); * change when entering/leaving read-only mode * (master->slave propagation). */ -typedef void (*box_process_func)(struct port *, u32, const void *, u32); +typedef void (*box_process_func)(struct port *, u32, const char *, u32); /** For read-write operations. */ extern box_process_func box_process; /** For read-only port. */ diff --git a/include/log_io.h b/include/log_io.h index 1d8fdafa205c73adf16ced8322622d6b12baa0ba..58e9f4e7e88d442ae19586e67fb8e17d787eaea2 100644 --- a/include/log_io.h +++ b/include/log_io.h @@ -148,7 +148,7 @@ struct row_v11 { void row_v11_fill(struct row_v11 *row, u64 lsn, u16 tag, u64 cookie, - const void *metadata, size_t metadata_len, const void + const char *metadata, size_t metadata_len, const char *data, size_t data_len); static inline size_t diff --git a/include/pickle.h b/include/pickle.h index ff6e9297c089be3c6dad03c0f191cdad60b290b8..9fc087c1861fbbd3b8463840b373794c3a0b19e0 100644 --- a/include/pickle.h +++ b/include/pickle.h @@ -41,38 +41,38 @@ */ static inline uint32_t -load_u32(const void **data) +load_u32(const char **data) { const uint32_t *b = (const uint32_t *) *data; - *data= b + 1; + *data += sizeof(uint32_t); return *b; } static inline uint32_t -load_varint32(const void **data) +load_varint32(const char **data) { assert(data != NULL && *data != NULL); const uint8_t *b = (const uint8_t *) *data; if (!(b[0] & 0x80)) { - *data = (char *) *data + 1; + *data += 1; return (b[0] & 0x7f); } if (!(b[1] & 0x80)) { - *data = (char *) *data + 2; + *data += 2; return (b[0] & 0x7f) << 7 | (b[1] & 0x7f); } if (!(b[2] & 0x80)) { - *data = (char *) *data + 3; + *data += 3; return (b[0] & 0x7f) << 14 | (b[1] & 0x7f) << 7 | (b[2] & 0x7f); } if (!(b[3] & 0x80)) { - *data = (char *) *data + 4; + *data += 4; return (b[0] & 0x7f) << 21 | (b[1] & 0x7f) << 14 | (b[2] & 0x7f) << 7 | (b[3] & 0x7f); } if (!(b[4] & 0x80)) { - *data = (char *) *data + 5; + *data += 5; return (b[0] & 0x7f) << 28 | (b[1] & 0x7f) << 21 | (b[2] & 0x7f) << 14 | (b[3] & 0x7f) << 7 | (b[4] & 0x7f); } @@ -81,17 +81,17 @@ load_varint32(const void **data) } static inline uint32_t -pick_varint32(const void **data, const void *end) +pick_varint32(const char **data, const char *end) { assert(data != NULL && *data != NULL); const uint8_t *b = (const uint8_t *) *data; - ssize_t size = (const char *) end - (const char * )*data; + ssize_t size = end - *data; if (unlikely(size < 1)) tnt_raise(IllegalParams, "varint is too short (expected 1+ bytes)"); if (!(b[0] & 0x80)) { - *data = (char *) *data + 1; + *data += 1; return (b[0] & 0x7f); } @@ -99,7 +99,7 @@ pick_varint32(const void **data, const void *end) tnt_raise(IllegalParams, "varint is too short (expected 2+ bytes)"); if (!(b[1] & 0x80)) { - *data = (char *) *data + 2; + *data += 2; return (b[0] & 0x7f) << 7 | (b[1] & 0x7f); } @@ -107,7 +107,7 @@ pick_varint32(const void **data, const void *end) tnt_raise(IllegalParams, "BER int is too short (expected 3+ bytes)"); if (!(b[2] & 0x80)) { - *data = (char *) *data + 3; + *data += 3; return (b[0] & 0x7f) << 14 | (b[1] & 0x7f) << 7 | (b[2] & 0x7f); } @@ -115,7 +115,7 @@ pick_varint32(const void **data, const void *end) tnt_raise(IllegalParams, "BER int is too short (expected 4+ bytes)"); if (!(b[3] & 0x80)) { - *data = (char *) *data + 4; + *data += 4; return (b[0] & 0x7f) << 21 | (b[1] & 0x7f) << 14 | (b[2] & 0x7f) << 7 | (b[3] & 0x7f); } @@ -124,7 +124,7 @@ pick_varint32(const void **data, const void *end) tnt_raise(IllegalParams, "BER int is too short (expected 5+ bytes)"); if (!(b[4] & 0x80)) { - *data = (char *) *data + 5; + *data += 5; return (b[0] & 0x7f) << 28 | (b[1] & 0x7f) << 21 | (b[2] & 0x7f) << 14 | (b[3] & 0x7f) << 7 | (b[4] & 0x7f); } @@ -134,13 +134,13 @@ pick_varint32(const void **data, const void *end) #define pick_u(bits) \ static inline uint##bits##_t \ -pick_u##bits(const void **begin, const void *end) \ +pick_u##bits(const char **begin, const char *end) \ { \ - if ((const char *) end - (const char *) *begin < (bits)/8) \ + if (end - *begin < (bits)/8) \ tnt_raise(IllegalParams, \ "packet too short (expected "#bits" bits)");\ uint##bits##_t r = *(uint##bits##_t *)*begin; \ - *begin = (const char *) *begin + (bits)/8; \ + *begin += (bits)/8; \ return r; \ } @@ -149,28 +149,28 @@ pick_u(16) pick_u(32) pick_u(64) -static inline const void * -pick_str(const void **data, const void *end, uint32_t size) +static inline const char * +pick_str(const char **data, const char *end, uint32_t size) { - const void *str = *data; - if ((const char *) str + size > (const char *) end) + const char *str = *data; + if (str + size > end) tnt_raise(IllegalParams, "packet too short (expected a field)"); - *data = (char *) *data + size; + *data += size; return str; } -static inline const void * -pick_field(const void **data, const void *end) +static inline const char * +pick_field(const char **data, const char *end) { - const void *field = *data; + const char *field = *data; uint32_t field_len = pick_varint32(data, end); pick_str(data, end, field_len); return field; } -static inline const void * -pick_field_str(const void **data, const void *end, uint32_t *size) +static inline const char * +pick_field_str(const char **data, const char *end, uint32_t *size) { *size = pick_varint32(data, end); return pick_str(data, end, *size); @@ -178,7 +178,7 @@ pick_field_str(const void **data, const void *end, uint32_t *size) static inline uint32_t -pick_field_u32(const void **data, const void *end) +pick_field_u32(const char **data, const char *end) { uint32_t size = pick_varint32(data, end); if (size != sizeof(uint32_t)) @@ -202,8 +202,8 @@ varint32_sizeof(uint32_t value) } /** The caller must ensure that there is space in the buffer */ -static inline void * -pack_varint32(void *buf, uint32_t value) +static inline char * +pack_varint32(char *buf, uint32_t value) { uint8_t *target = (uint8_t *) buf; if (value >= (1 << 7)) { @@ -219,11 +219,11 @@ pack_varint32(void *buf, uint32_t value) } *(target++) = (uint8_t)((value) & 0x7F); - return target; + return (char *) target; } -static inline void * -pack_lstr(void *buf, const void *str, uint32_t len) +static inline char * +pack_lstr(char *buf, const void *str, uint32_t len) { return (char *) memcpy(pack_varint32(buf, len), str, len) + len; } diff --git a/include/recovery.h b/include/recovery.h index b04993b6a418d51381d2ba9b46a8313515779a1e..aad3a00eab4695375780e000f20bcd453a1b0b27 100644 --- a/include/recovery.h +++ b/include/recovery.h @@ -123,7 +123,7 @@ void recover_existing_wals(struct recovery_state *); void recovery_follow_local(struct recovery_state *r, ev_tstamp wal_dir_rescan_delay); void recovery_finalize(struct recovery_state *r); int wal_write(struct recovery_state *r, i64 lsn, u64 cookie, - u16 op, const void *data, u32 len); + u16 op, const char *data, u32 len); void recovery_setup_panic(struct recovery_state *r, bool on_snap_error, bool on_wal_error); @@ -143,8 +143,8 @@ void recovery_stop_remote(struct recovery_state *r); struct fio_batch; void snapshot_write_row(struct log_io *i, struct fio_batch *batch, - const void *metadata, size_t metadata_size, - const void *data, size_t data_size); + const char *metadata, size_t metadata_size, + const char *data, size_t data_size); void snapshot_save(struct recovery_state *r, void (*loop) (struct log_io *, struct fio_batch *)); diff --git a/src/box/bitset_index.cc b/src/box/bitset_index.cc index b3f85f1c45b9c6c9ae7f57afee7d32b612f4d59b..673dc5f2a4e46724671118170ccee7dde7b8c01f 100644 --- a/src/box/bitset_index.cc +++ b/src/box/bitset_index.cc @@ -182,7 +182,7 @@ BitsetIndex::allocIterator() const } struct tuple * -BitsetIndex::findByKey(const void *key, u32 part_count) const +BitsetIndex::findByKey(const char *key, u32 part_count) const { (void) key; (void) part_count; @@ -219,11 +219,11 @@ BitsetIndex::replace(struct tuple *old_tuple, struct tuple *new_tuple, } if (new_tuple != NULL) { - const void *field = tuple_field(new_tuple, + const char *field = tuple_field(new_tuple, key_def->parts[0].fieldno); assert (field != NULL); size_t bitset_key_size = (size_t) load_varint32(&field); - const void *bitset_key = field; + const char *bitset_key = field; size_t value = tuple_to_value(new_tuple); if (bitset_index_insert(&index, bitset_key, @@ -238,7 +238,7 @@ BitsetIndex::replace(struct tuple *old_tuple, struct tuple *new_tuple, void BitsetIndex::initIterator(struct iterator *iterator, enum iterator_type type, - const void *key, u32 part_count) const + const char *key, u32 part_count) const { assert(iterator->free == bitset_index_iterator_free); struct bitset_index_iterator *it = bitset_index_iterator(iterator); @@ -249,7 +249,7 @@ BitsetIndex::initIterator(struct iterator *iterator, enum iterator_type type, if (type != ITER_ALL) { check_key_parts(key_def, part_count, bitset_index_traits.allows_partial_key); - const void *key2 = key; + const char *key2 = key; bitset_key_size = (size_t) load_varint32(&key2); bitset_key = key2; } diff --git a/src/box/bitset_index.h b/src/box/bitset_index.h index b36909ce7bcffb3082c3b065f47ee06375e5e3b1..4b3c4c4fca71d47d2f49b7fc6727633da6b11caa 100644 --- a/src/box/bitset_index.h +++ b/src/box/bitset_index.h @@ -54,7 +54,7 @@ class BitsetIndex: public Index { virtual struct tuple *min() const; virtual struct tuple *max() const; virtual struct tuple *random(u32 rnd) const; - virtual struct tuple *findByKey(const void *key, u32 part_count) const; + virtual struct tuple *findByKey(const char *key, u32 part_count) const; virtual struct tuple *findByTuple(struct tuple *tuple) const; virtual struct tuple *replace(struct tuple *old_tuple, struct tuple *new_tuple, @@ -63,7 +63,7 @@ class BitsetIndex: public Index { virtual struct iterator *allocIterator() const; virtual void initIterator(struct iterator *iterator, enum iterator_type type, - const void *key, u32 part_count) const; + const char *key, u32 part_count) const; private: struct bitset_index index; }; diff --git a/src/box/box.cc b/src/box/box.cc index 707c72527ee8f3aba30e5af8103f4cda8cf95dfa..ab7af29339876f0b98216dc3dbe6af9f0629683f 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -52,11 +52,11 @@ extern "C" { #include <third_party/base64.h> static void process_replica(struct port *port, - u32 op, const void *reqdata, u32 reqlen); + u32 op, const char *reqdata, u32 reqlen); static void process_ro(struct port *port, - u32 op, const void *reqdata, u32 reqlen); + u32 op, const char *reqdata, u32 reqlen); static void process_rw(struct port *port, - u32 op, const void *reqdata, u32 reqlen); + u32 op, const char *reqdata, u32 reqlen); box_process_func box_process = process_ro; box_process_func box_process_ro = process_ro; @@ -68,7 +68,7 @@ struct box_snap_row { u32 space; u32 tuple_size; u32 data_size; - u8 data[]; + char data[]; } __attribute__((packed)); void @@ -80,7 +80,7 @@ port_send_tuple(struct port *port, struct txn *txn, u32 flags) } static void -process_rw(struct port *port, u32 op, const void *reqdata, u32 reqlen) +process_rw(struct port *port, u32 op, const char *reqdata, u32 reqlen) { struct txn *txn = txn_begin(); @@ -99,7 +99,7 @@ process_rw(struct port *port, u32 op, const void *reqdata, u32 reqlen) } static void -process_replica(struct port *port, u32 op, const void *reqdata, u32 reqlen) +process_replica(struct port *port, u32 op, const char *reqdata, u32 reqlen) { if (!request_is_select(op)) { tnt_raise(ClientError, ER_NONMASTER, @@ -109,7 +109,7 @@ process_replica(struct port *port, u32 op, const void *reqdata, u32 reqlen) } static void -process_ro(struct port *port, u32 op, const void *reqdata, u32 reqlen) +process_ro(struct port *port, u32 op, const char *reqdata, u32 reqlen) { if (!request_is_select(op)) tnt_raise(LoggedError, ER_SECONDARY); @@ -136,7 +136,7 @@ recover_snap_row(const void *data) int base64_buflen = base64_bufsize(row->data_size); char *base64_buf = (char *) malloc(base64_buflen); - int len = base64_encode((const char *) row->data, row->data_size, + int len = base64_encode(row->data, row->data_size, base64_buf, base64_buflen); write(STDERR_FILENO, base64_buf, len); free(base64_buf); @@ -169,16 +169,15 @@ recover_row(void *param __attribute__((unused)), struct tbuf *t) } try { - const void *data = t->data; - const void *end = t->data + t->size; + const char *data = t->data; + const char *end = t->data + t->size; u16 tag = pick_u16(&data, end); (void) pick_u64(&data, end); /* drop cookie */ if (tag == SNAP) { recover_snap_row(data); } else if (tag == XLOG) { u16 op = pick_u16(&data, end); - process_rw(&port_null, op, data, - (const char *) end - (const char *) data); + process_rw(&port_null, op, data, end - data); } else { say_error("unknown row tag: %i", (int)tag); return -1; @@ -376,7 +375,7 @@ snapshot_write_tuple(struct log_io *l, struct fio_batch *batch, header.tuple_size = tuple->field_count; header.data_size = tuple->bsize; - snapshot_write_row(l, batch, (void *) &header, sizeof(header), + snapshot_write_row(l, batch, (const char *) &header, sizeof(header), tuple->data, tuple->bsize); } diff --git a/src/box/box_lua.cc b/src/box/box_lua.cc index a6bcb2bbaeb411aac5eb9ac2b477b22761ecc06c..716478f74bdeaaa99b91404aba319eb81fe4eb41 100644 --- a/src/box/box_lua.cc +++ b/src/box/box_lua.cc @@ -164,12 +164,12 @@ lbox_tuple_slice(struct lua_State *L) if (end <= start) luaL_error(L, "tuple.slice(): start must be less than end"); - const char *field = (const char *) tuple->data; + const char *field = tuple->data; u32 fieldno = 0; u32 stop = end - 1; - while (field < (const char *) tuple->data + tuple->bsize) { - size_t len = load_varint32((const void **) &field); + while (field < tuple->data + tuple->bsize) { + size_t len = load_varint32(&field); if (fieldno >= start) { lua_pushlstring(L, field, len); if (fieldno == stop) @@ -202,8 +202,8 @@ transform_calculate(struct lua_State *L, struct tuple *tuple, size_t lr[2]) { /* calculate size of the new tuple */ - const void *tuple_end = tuple->data + tuple->bsize; - const void *tuple_field = tuple->data; + const char *tuple_end = tuple->data + tuple->bsize; + const char *tuple_field = tuple->data; lr[0] = tuple_range_size(&tuple_field, tuple_end, offset); @@ -233,7 +233,7 @@ transform_calculate(struct lua_State *L, struct tuple *tuple, tuple_range_size(&tuple_field, tuple_end, len); /* calculate last part of the tuple fields */ - lr[1] = (const char *) tuple_end - (const char *) tuple_field; + lr[1] = tuple_end - tuple_field; return lr[0] + mid + lr[1]; } @@ -281,7 +281,7 @@ lbox_tuple_transform(struct lua_State *L) /* construct tuple */ memcpy(dest->data, tuple->data, lr[0]); - void *ptr = dest->data + lr[0]; + char *ptr = dest->data + lr[0]; for (int i = 4; i <= argc; i++) { switch (lua_type(L, i)) { case LUA_TNUMBER: { @@ -330,9 +330,9 @@ tuple_find(struct lua_State *L, struct tuple *tuple, size_t offset, int idx = offset; if (idx >= tuple->field_count) return 0; - const char *field = (const char *) tuple_field(tuple, idx); - while (field < (const char *) tuple->data + tuple->bsize) { - size_t len = load_varint32((const void **) &field); + const char *field = tuple_field(tuple, idx); + while (field < tuple->data + tuple->bsize) { + size_t len = load_varint32(&field); if (len == key_size && (memcmp(field, key, len) == 0)) { lua_pushinteger(L, idx); if (!all) @@ -398,12 +398,12 @@ static int lbox_tuple_unpack(struct lua_State *L) { struct tuple *tuple = lua_checktuple(L, 1); - const void *field = tuple->data; + const char *field = tuple->data; - while (field < (const char *) tuple->data + tuple->bsize) { + while (field < tuple->data + tuple->bsize) { size_t len = load_varint32(&field); - lua_pushlstring(L, (const char *) field, len); - field = (const char *) field + len; + lua_pushlstring(L, field, len); + field = field + len; } assert(lua_gettop(L) == tuple->field_count + 1); return tuple->field_count; @@ -415,13 +415,13 @@ lbox_tuple_totable(struct lua_State *L) struct tuple *tuple = lua_checktuple(L, 1); lua_newtable(L); int index = 1; - const void *field = tuple->data; - while (field < (const char *) tuple->data + tuple->bsize) { + const char *field = tuple->data; + while (field < tuple->data + tuple->bsize) { size_t len = load_varint32(&field); lua_pushnumber(L, index++); - lua_pushlstring(L, (const char *) field, len); + lua_pushlstring(L, field, len); lua_rawset(L, -3); - field = (const char *) field + len; + field += len; } return 1; } @@ -443,9 +443,9 @@ lbox_tuple_index(struct lua_State *L) if (i >= tuple->field_count) luaL_error(L, "%s: index %d is out of bounds (0..%d)", tuplelib_name, i, tuple->field_count-1); - const void *field = tuple_field(tuple, i); + const char *field = tuple_field(tuple, i); u32 len = load_varint32(&field); - lua_pushlstring(L, (const char *) field, len); + lua_pushlstring(L, field, len); return 1; } /* If we got a string, try to find a method for it. */ @@ -471,7 +471,7 @@ lbox_pushtuple(struct lua_State *L, struct tuple *tuple) { if (tuple) { struct tuple **ptr = (struct tuple **) - lua_newuserdata(L, sizeof(void *)); + lua_newuserdata(L, sizeof(*ptr)); luaL_getmetatable(L, tuplelib_name); lua_setmetatable(L, -2); *ptr = tuple; @@ -491,22 +491,22 @@ lbox_tuple_next(struct lua_State *L) { struct tuple *tuple = lua_checktuple(L, 1); int argc = lua_gettop(L) - 1; - const void *field = NULL; + const char *field = NULL; size_t len; if (argc == 0 || (argc == 1 && lua_type(L, 2) == LUA_TNIL)) field = tuple->data; else if (argc == 1 && lua_islightuserdata(L, 2)) - field = lua_touserdata(L, 2); + field = (char *) lua_touserdata(L, 2); else luaL_error(L, "tuple.next(): bad arguments"); (void)field; - assert(field >= (const void *) tuple->data); - if (field < (const char *) tuple->data + tuple->bsize) { + assert(field >= tuple->data); + if (field < tuple->data + tuple->bsize) { len = load_varint32(&field); - lua_pushlightuserdata(L, (char *) field + len); - lua_pushlstring(L, (char *) field, len); + lua_pushlightuserdata(L, (void *) (field + len)); + lua_pushlstring(L, field, len); return 2; } lua_pushnil(L); @@ -579,7 +579,7 @@ lbox_checkiterator(struct lua_State *L, int i) static void lbox_pushiterator(struct lua_State *L, Index *index, struct iterator *it, enum iterator_type type, - const void *key, size_t size, int part_count) + const char *key, size_t size, int part_count) { struct lbox_iterator_holder { struct iterator *it; @@ -587,7 +587,7 @@ lbox_pushiterator(struct lua_State *L, Index *index, }; struct lbox_iterator_holder *holder = (struct lbox_iterator_holder *) - lua_newuserdata(L, sizeof(void *) + size); + lua_newuserdata(L, sizeof(*holder) + size); luaL_getmetatable(L, iteratorlib_name); lua_setmetatable(L, -2); @@ -725,8 +725,7 @@ void append_key_part(struct lua_State *L, int i, str = luaL_checklstring(L, i, &size); } char varint_buf[sizeof(u32) + 1]; - size_t pack_len = ((const char *) pack_varint32(varint_buf, size) - - (const char *) varint_buf); + size_t pack_len = pack_varint32(varint_buf, size) - varint_buf; tbuf_append(tbuf, varint_buf, pack_len); tbuf_append(tbuf, str, size); } @@ -768,7 +767,7 @@ lbox_create_iterator(struct lua_State *L) /* Create a new iterator. */ enum iterator_type type = ITER_ALL; u32 field_count = 0; - const void *key = NULL; + const char *key = NULL; u32 key_size = 0; if (argc == 1 || (argc == 2 && lua_type(L, 2) == LUA_TNIL)) { /* @@ -899,7 +898,7 @@ lbox_index_count(struct lua_State *L) /* preparing single or multi-part key */ size_t allocated_size = palloc_allocated(fiber->gc_pool); - const void *key; + const char *key; u32 key_part_count; if (argc == 1 && lua_type(L, 2) == LUA_TUSERDATA) { /* Searching by tuple. */ @@ -1065,7 +1064,7 @@ lua_table_to_tuple(struct lua_State *L, int index) * the tuple is leaked. */ tuple->field_count = field_count; - void *pos = tuple->data; + char *pos = tuple->data; /* Second go: store data in the tuple. */ @@ -1260,7 +1259,7 @@ lbox_process(lua_State *L) { u32 op = lua_tointeger(L, 1); /* Get the first arg. */ size_t sz; - const void *req = luaL_checklstring(L, 2, &sz); /* Second arg. */ + const char *req = luaL_checklstring(L, 2, &sz); /* Second arg. */ if (op == CALL) { /* * We should not be doing a CALL from within a CALL. @@ -1363,8 +1362,8 @@ lbox_call_loadproc(struct lua_State *L) void box_lua_execute(struct request *request, struct port *port) { - const void **reqpos = &request->data; - const void *reqend = (const char *) request->data + request->len; + const char **reqpos = &request->data; + const char *reqend = request->data + request->len; lua_State *L = lua_newthread(root_L); int coro_ref = luaL_ref(root_L, LUA_REGISTRYINDEX); /* Request flags: not used. */ @@ -1381,15 +1380,14 @@ box_lua_execute(struct request *request, struct port *port) u32 field_len; /* proc name */ - const void *field = pick_field_str(reqpos, reqend, &field_len); - box_lua_find(L, (const char *) field, - ((const char *) field + field_len)); + const char *field = pick_field_str(reqpos, reqend, &field_len); + box_lua_find(L, field, field + field_len); /* Push the rest of args (a tuple). */ u32 nargs = pick_u32(reqpos, reqend); luaL_checkstack(L, nargs, "call: out of stack"); for (int i = 0; i < nargs; i++) { field = pick_field_str(reqpos, reqend, &field_len); - lua_pushlstring(L, (const char *) field, field_len); + lua_pushlstring(L, field, field_len); } lua_call(L, nargs, LUA_MULTRET); /* Send results of the called procedure to the client. */ @@ -1419,7 +1417,7 @@ static void luaL_addvarint32(luaL_Buffer *b, u32 value) { char buf[sizeof(u32)+1]; - char *bufend = (char *) pack_varint32(buf, value); + char *bufend = pack_varint32(buf, value); luaL_addlstring(b, buf, bufend - buf); } @@ -1696,7 +1694,7 @@ lbox_pack(struct lua_State *L) } const char * -box_unpack_response(struct lua_State *L, const void *s, const void *end) +box_unpack_response(struct lua_State *L, const char *s, const char *end) { u32 tuple_count = pick_u32(&s, end); @@ -1711,10 +1709,10 @@ box_unpack_response(struct lua_State *L, const void *s, const void *end) t->field_count = field_count; memcpy(t->data, s, bsize); - s = (const char *) s + bsize; + s = s + bsize; lbox_pushtuple(L, t); } - return (const char *) s; + return s; } @@ -1727,7 +1725,7 @@ lbox_unpack(struct lua_State *L) size_t str_size = 0; const char *str = luaL_checklstring(L, 2, &str_size); - const char *end = (const char *) str + str_size; + const char *end = str + str_size; const char *s = str; int save_stacksize = lua_gettop(L); @@ -1768,7 +1766,7 @@ lbox_unpack(struct lua_State *L) break; case 'w': /* pick_varint32 throws exception on error. */ - u32buf = pick_varint32((const void **) &s, end); + u32buf = pick_varint32(&s, end); lua_pushnumber(L, u32buf); break; @@ -1780,9 +1778,9 @@ lbox_unpack(struct lua_State *L) case 'P': case 'p': /* pick_varint32 throws exception on error. */ - u32buf = pick_varint32((const void **) &s, end); + u32buf = pick_varint32(&s, end); CHECK_SIZE(s + u32buf - 1); - lua_pushlstring(L, (const char *) s, u32buf); + lua_pushlstring(L, s, u32buf); s += u32buf; break; case '=': @@ -1809,7 +1807,7 @@ lbox_unpack(struct lua_State *L) u32buf = *(u32 *) s; /* opcode */ - charbuf = *(char *) (s + 4); + charbuf = *(s + 4); charbuf = opcode_to_format(charbuf); if (charbuf != *f) { luaL_error(L, "box.unpack('%s'): " diff --git a/src/box/hash_index.cc b/src/box/hash_index.cc index d2ad735c7cd21ebd6e707a38a0b8cd267d057a8c..a18d4d99fc597c9b1981262fb9003129d8803348 100644 --- a/src/box/hash_index.cc +++ b/src/box/hash_index.cc @@ -153,7 +153,7 @@ class Hash32Index: public HashIndex { random(u32 rnd) const; virtual struct tuple * - findByKey(const void *key, u32 part_count) const; + findByKey(const char *key, u32 part_count) const; virtual struct tuple * replace(struct tuple *old_tuple, struct tuple *new_tuple, @@ -164,7 +164,7 @@ class Hash32Index: public HashIndex { void initIterator(struct iterator *iterator, enum iterator_type type, - const void *key, u32 part_count) const; + const char *key, u32 part_count) const; virtual void reserve(u32 n_tuples); @@ -184,7 +184,7 @@ class Hash64Index: public HashIndex { random(u32 rnd) const; virtual struct tuple * - findByKey(const void *key, u32 part_count) const; + findByKey(const char *key, u32 part_count) const; virtual struct tuple * replace(struct tuple *old_tuple, struct tuple *new_tuple, @@ -195,7 +195,7 @@ class Hash64Index: public HashIndex { void initIterator(struct iterator *iterator, enum iterator_type type, - const void *key, u32 part_count) const; + const char *key, u32 part_count) const; virtual void reserve(u32 n_tuples); @@ -215,7 +215,7 @@ class HashStrIndex: public HashIndex { random(u32 rnd) const; virtual struct tuple * - findByKey(const void *key, u32 part_count) const; + findByKey(const char *key, u32 part_count) const; virtual struct tuple * replace(struct tuple *old_tuple, struct tuple *new_tuple, @@ -226,7 +226,7 @@ class HashStrIndex: public HashIndex { void initIterator(struct iterator *iterator, enum iterator_type type, - const void *key, u32 part_count) const; + const char *key, u32 part_count) const; virtual void reserve(u32 n_tuples); @@ -319,7 +319,7 @@ HashIndex::findByTuple(struct tuple *tuple) const tnt_raise(IllegalParams, "tuple must have all indexed fields"); /* Hash index currently is always single-part. */ - void *field = tuple_field(tuple, key_def->parts[0].fieldno); + const char *field = tuple_field(tuple, key_def->parts[0].fieldno); return findByKey(field, 1); } @@ -328,7 +328,7 @@ HashIndex::findByTuple(struct tuple *tuple) const /* {{{ Hash32Index ************************************************/ static inline struct mh_i32ptr_node_t -int32_key_to_node(const void *key) +int32_key_to_node(const char *key) { u32 key_size = load_varint32(&key); if (key_size != 4) @@ -340,7 +340,7 @@ int32_key_to_node(const void *key) static inline struct mh_i32ptr_node_t int32_tuple_to_node(struct tuple *tuple, struct key_def *key_def) { - void *field = tuple_field(tuple, key_def->parts[0].fieldno); + const char *field = tuple_field(tuple, key_def->parts[0].fieldno); struct mh_i32ptr_node_t node = int32_key_to_node(field); node.val = tuple; return node; @@ -381,7 +381,7 @@ Hash32Index::random(u32 rnd) const } struct tuple * -Hash32Index::findByKey(const void *key, u32 part_count) const +Hash32Index::findByKey(const char *key, u32 part_count) const { assert(key_def->is_unique); check_key_parts(key_def, part_count, false); @@ -465,7 +465,7 @@ Hash32Index::allocIterator() const void Hash32Index::initIterator(struct iterator *ptr, enum iterator_type type, - const void *key, u32 part_count) const + const char *key, u32 part_count) const { assert(ptr->free == hash_iterator_free); struct hash_i32_iterator *it = (struct hash_i32_iterator *) ptr; @@ -505,7 +505,7 @@ Hash32Index::initIterator(struct iterator *ptr, enum iterator_type type, /* {{{ Hash64Index ************************************************/ static inline struct mh_i64ptr_node_t -int64_key_to_node(const void *key) +int64_key_to_node(const char *key) { u32 key_size = load_varint32(&key); if (key_size != 8) @@ -517,7 +517,7 @@ int64_key_to_node(const void *key) static inline struct mh_i64ptr_node_t int64_tuple_to_node(struct tuple *tuple, struct key_def *key_def) { - void *field = tuple_field(tuple, key_def->parts[0].fieldno); + const char *field = tuple_field(tuple, key_def->parts[0].fieldno); struct mh_i64ptr_node_t node = int64_key_to_node(field); node.val = tuple; return node; @@ -556,7 +556,7 @@ Hash64Index::random(u32 rnd) const } struct tuple * -Hash64Index::findByKey(const void *key, u32 part_count) const +Hash64Index::findByKey(const char *key, u32 part_count) const { assert(key_def->is_unique); check_key_parts(key_def, part_count, false); @@ -643,7 +643,7 @@ Hash64Index::allocIterator() const void Hash64Index::initIterator(struct iterator *ptr, enum iterator_type type, - const void *key, u32 part_count) const + const char *key, u32 part_count) const { assert(ptr->free == hash_iterator_free); struct hash_i64_iterator *it = (struct hash_i64_iterator *) ptr; @@ -685,7 +685,7 @@ Hash64Index::initIterator(struct iterator *ptr, enum iterator_type type, static inline struct mh_lstrptr_node_t lstrptr_tuple_to_node(struct tuple *tuple, struct key_def *key_def) { - void *field = tuple_field(tuple, key_def->parts[0].fieldno); + const char *field = tuple_field(tuple, key_def->parts[0].fieldno); if (field == NULL) tnt_raise(ClientError, ER_NO_SUCH_FIELD, key_def->parts[0].fieldno); @@ -728,7 +728,7 @@ HashStrIndex::random(u32 rnd) const } struct tuple * -HashStrIndex::findByKey(const void *key, u32 part_count) const +HashStrIndex::findByKey(const char *key, u32 part_count) const { assert(key_def->is_unique); check_key_parts(key_def, part_count, false); @@ -739,9 +739,9 @@ HashStrIndex::findByKey(const void *key, u32 part_count) const if (k != mh_end(str_hash)) ret = (struct tuple *) mh_lstrptr_node(str_hash, k)->val; #ifdef DEBUG - u32 key_size = load_varint32((const void **) &key); + u32 key_size = load_varint32(&key); say_debug("HashStrIndex find(self:%p, key:(%i)'%.*s') = %p", - self, key_size, key_size, (u8 *)key, ret); + self, key_size, key_size, key, ret); #endif return ret; } @@ -811,7 +811,7 @@ HashStrIndex::allocIterator() const void HashStrIndex::initIterator(struct iterator *ptr, enum iterator_type type, - const void *key, u32 part_count) const + const char *key, u32 part_count) const { (void) part_count; diff --git a/src/box/hash_index.h b/src/box/hash_index.h index df0c5f8e23f02543682d29b05fcc16552150dbb6..e6ce4423b710e799dd40d88e7bbca70ca4f5e57b 100644 --- a/src/box/hash_index.h +++ b/src/box/hash_index.h @@ -47,7 +47,7 @@ class HashIndex: public Index { virtual struct tuple *min() const; virtual struct tuple *max() const; virtual struct tuple *random(u32 rnd) const = 0; - virtual struct tuple *findByKey(const void *key, u32 part_count) const = 0; + virtual struct tuple *findByKey(const char *key, u32 part_count) const = 0; virtual struct tuple *findByTuple(struct tuple *tuple) const; virtual struct tuple *replace(struct tuple *old_tuple, struct tuple *new_tuple, @@ -56,7 +56,7 @@ class HashIndex: public Index { virtual struct iterator *allocIterator() const = 0; virtual void initIterator(struct iterator *iterator, enum iterator_type type, - const void *key, u32 part_count) const = 0; + const char *key, u32 part_count) const = 0; virtual void reserve(u32 n_tuples) = 0; }; diff --git a/src/box/index.h b/src/box/index.h index 06af3f83e06919e81e84ab077413123095bbe6b6..8935ce9e8a3f41816e27a19ec044c84682c01f0f 100644 --- a/src/box/index.h +++ b/src/box/index.h @@ -203,7 +203,7 @@ class Index: public Object { virtual struct tuple *min() const = 0; virtual struct tuple *max() const = 0; virtual struct tuple *random(u32 rnd) const = 0; - virtual struct tuple *findByKey(const void *key, u32 part_count) const = 0; + virtual struct tuple *findByKey(const char *key, u32 part_count) const = 0; virtual struct tuple *findByTuple(struct tuple *tuple) const = 0; virtual struct tuple *replace(struct tuple *old_tuple, struct tuple *new_tuple, @@ -215,7 +215,7 @@ class Index: public Object { virtual struct iterator *allocIterator() const = 0; virtual void initIterator(struct iterator *iterator, enum iterator_type type, - const void *key, u32 part_count) const = 0; + const char *key, u32 part_count) const = 0; inline struct iterator *position() { diff --git a/src/box/request.cc b/src/box/request.cc index cdd68c0005a124b095c0877c69ffb1aa602bdea0..33831578a90374e8069d687d399df4fc8dbb8990 100644 --- a/src/box/request.cc +++ b/src/box/request.cc @@ -41,11 +41,11 @@ STRS(requests, REQUESTS); STRS(update_op_codes, UPDATE_OP_CODES); -static const void * -read_key(const void **reqpos, const void *reqend, u32 *key_part_count) +static const char * +read_key(const char **reqpos, const char *reqend, u32 *key_part_count) { *key_part_count = pick_u32(reqpos, reqend); - const void *key = *key_part_count ? *reqpos : NULL; + const char *key = *key_part_count ? *reqpos : NULL; /* Advance remaining fields of a key */ for (u32 i = 0; i < *key_part_count; i++) pick_field(reqpos, reqend); @@ -53,7 +53,7 @@ read_key(const void **reqpos, const void *reqend, u32 *key_part_count) } static struct space * -read_space(const void **reqpos, const void *reqend) +read_space(const char **reqpos, const char *reqend) { u32 space_no = pick_u32(reqpos, reqend); return space_find(space_no); @@ -71,8 +71,8 @@ static void execute_replace(struct request *request, struct txn *txn) { txn_add_redo(txn, request->type, request->data, request->len); - const void **reqpos = &request->data; - const void *reqend = (const char *) request->data + request->len; + const char **reqpos = &request->data; + const char *reqend = request->data + request->len; struct space *sp = read_space(reqpos, reqend); request->flags |= (pick_u32(reqpos, reqend) & BOX_ALLOWED_REQUEST_FLAGS); @@ -81,7 +81,7 @@ execute_replace(struct request *request, struct txn *txn) if (field_count == 0) tnt_raise(IllegalParams, "tuple field count is 0"); - size_t tuple_len = (const char *) reqend - (const char *) *reqpos; + size_t tuple_len = reqend - *reqpos; if (tuple_len != valid_tuple(*reqpos, reqend, field_count)) tnt_raise(IllegalParams, "incorrect tuple length"); @@ -165,7 +165,7 @@ execute_replace(struct request *request, struct txn *txn) /** Argument of SET operation. */ struct op_set_arg { u32 length; - const void *value; + const char *value; }; /** Argument of ADD, AND, XOR, OR operations. */ @@ -181,7 +181,7 @@ struct op_arith_arg { struct op_splice_arg { i32 offset; /** splice position */ i32 cut_length; /** cut this many bytes. */ - const void *paste; /** paste what? */ + const char *paste; /** paste what? */ i32 paste_length; /** paste this many bytes. */ /** Offset of the tail in the old field */ @@ -200,7 +200,7 @@ struct update_field; struct update_op; typedef void (*init_op_func)(struct rope *rope, struct update_op *op); -typedef void (*do_op_func)(union update_op_arg *arg, const void *in, void *out); +typedef void (*do_op_func)(union update_op_arg *arg, const char *in, char *out); /** A set of functions and properties to initialize and do an op. */ struct update_op_meta { @@ -229,9 +229,9 @@ struct update_field { /** UPDATE operations against the first field in the range. */ struct op_list ops; /** Points at start of field *data* in the old tuple. */ - const void *old; + const char *old; /** End of the old field. */ - const void *tail; + const char *tail; /** * Length of the "tail" in the old tuple from end * of old data to the beginning of the field in the @@ -242,11 +242,11 @@ struct update_field { static void update_field_init(struct update_field *field, - const void *old, u32 old_len, u32 tail_len) + const char *old, u32 old_len, u32 tail_len) { STAILQ_INIT(&field->ops); field->old = old; - field->tail = (char *) old + old_len; + field->tail = old + old_len; field->tail_len = tail_len; } @@ -254,8 +254,7 @@ static inline u32 update_field_len(struct update_field *f) { struct update_op *last = STAILQ_LAST(&f->ops, update_op, next); - return last ? last->new_field_len - : (const char *) f->tail - (const char *) f->old; + return last ? last->new_field_len : f->tail - f->old; } static inline void @@ -276,14 +275,14 @@ op_adjust_field_no(struct update_op *op, u32 field_max) static void -do_update_op_set(struct op_set_arg *arg, const void *in __attribute__((unused)), - void *out) +do_update_op_set(struct op_set_arg *arg, const char *in __attribute__((unused)), + char *out) { memcpy(out, arg->value, arg->length); } static void -do_update_op_add(struct op_arith_arg *arg, const void *in, void *out) +do_update_op_add(struct op_arith_arg *arg, const char *in, char *out) { if (arg->val_size == sizeof(i32)) *(i32 *)out = *(i32 *)in + arg->i32_val; @@ -292,7 +291,7 @@ do_update_op_add(struct op_arith_arg *arg, const void *in, void *out) } static void -do_update_op_subtract(struct op_arith_arg *arg, const void *in, void *out) +do_update_op_subtract(struct op_arith_arg *arg, const char *in, char *out) { if (arg->val_size == sizeof(i32)) *(i32 *)out = *(i32 *)in - arg->i32_val; @@ -301,7 +300,7 @@ do_update_op_subtract(struct op_arith_arg *arg, const void *in, void *out) } static void -do_update_op_and(struct op_arith_arg *arg, const void *in, void *out) +do_update_op_and(struct op_arith_arg *arg, const char *in, char *out) { if (arg->val_size == sizeof(i32)) *(i32 *)out = *(i32 *)in & arg->i32_val; @@ -310,7 +309,7 @@ do_update_op_and(struct op_arith_arg *arg, const void *in, void *out) } static void -do_update_op_xor(struct op_arith_arg *arg, const void *in, void *out) +do_update_op_xor(struct op_arith_arg *arg, const char *in, char *out) { if (arg->val_size == sizeof(i32)) *(i32 *)out = *(i32 *)in ^ arg->i32_val; @@ -319,7 +318,7 @@ do_update_op_xor(struct op_arith_arg *arg, const void *in, void *out) } static void -do_update_op_or(struct op_arith_arg *arg, const void *in, void *out) +do_update_op_or(struct op_arith_arg *arg, const char *in, char *out) { if (arg->val_size == sizeof(i32)) *(i32 *)out = *(i32 *)in | arg->i32_val; @@ -328,19 +327,19 @@ do_update_op_or(struct op_arith_arg *arg, const void *in, void *out) } static void -do_update_op_splice(struct op_splice_arg *arg, const void *in, void *out) +do_update_op_splice(struct op_splice_arg *arg, const char *in, char *out) { memcpy(out, in, arg->offset); /* copy field head. */ - out = (char *) out + arg->offset; + out = out + arg->offset; memcpy(out, arg->paste, arg->paste_length); /* copy the paste */ - out = (char *) out + arg->paste_length; - memcpy(out, (const char *) in + arg->tail_offset, arg->tail_length); /* copy tail */ + out = out + arg->paste_length; + memcpy(out, in + arg->tail_offset, arg->tail_length); /* copy tail */ } static void do_update_op_insert(struct op_set_arg *arg, - const void *in __attribute__((unused)), - void *out) + const char *in __attribute__((unused)), + char *out) { memcpy(out, arg->value, arg->length); } @@ -433,8 +432,8 @@ init_update_op_splice(struct rope *rope, struct update_op *op) u32 field_len = update_field_len(field); struct op_splice_arg *arg = &op->arg.splice; - const void *value = op->arg.set.value; - const void *end = (const char *) value + op->arg.set.length; + const char *value = op->arg.set.value; + const char *end = value + op->arg.set.length; /* Read the offset. */ arg->offset = pick_field_u32(&value, end); @@ -511,14 +510,13 @@ update_field_split(void *data, size_t size __attribute__((unused)), palloc(fiber->gc_pool, sizeof(struct update_field)); assert(offset > 0 && prev->tail_len > 0); - const void *field = prev->tail; - const void *end = (const char *) field + prev->tail_len; + const char *field = prev->tail; + const char *end = field + prev->tail_len; prev->tail_len = tuple_range_size(&field, end, offset - 1); u32 field_len = load_varint32(&field); - update_field_init(next, field, field_len, (const char *) end - - (const char *) field - field_len); + update_field_init(next, field, field_len, end - field - field_len); return next; } @@ -538,11 +536,11 @@ update_create_rope(struct update_op *op, struct update_op *op_end, struct update_field *first = (struct update_field *) palloc(fiber->gc_pool, sizeof(struct update_field)); - const void *field = tuple->data; - const void *end = tuple->data + tuple->bsize; + const char *field = tuple->data; + const char *end = tuple->data + tuple->bsize; u32 field_len = load_varint32(&field); update_field_init(first, field, field_len, - (const char *) end - (const char *) field - field_len); + end - field - field_len); rope_append(rope, first, tuple->field_count); @@ -577,7 +575,7 @@ update_calc_new_tuple_length(struct rope *rope) static void do_update_ops(struct rope *rope, struct tuple *new_tuple) { - char *new_data = (char *) new_tuple->data; + char *new_data = new_tuple->data; char *new_data_end = new_data + new_tuple->bsize; new_tuple->field_count = 0; @@ -593,11 +591,11 @@ do_update_ops(struct rope *rope, struct tuple *new_tuple) u32 field_count = rope_leaf_size(node); u32 field_len = update_field_len(field); - new_data = (char *) pack_varint32(new_data, field_len); + new_data = pack_varint32(new_data, field_len); - const void *old_field = field->old; - void *new_field = (STAILQ_EMPTY(&field->ops) ? - (void*) old_field : new_data); + const char *old_field = field->old; + char *new_field = (STAILQ_EMPTY(&field->ops) ? + (char *) old_field : new_data); struct update_op *op; STAILQ_FOREACH(op, &field->ops, next) { /* @@ -622,7 +620,7 @@ do_update_ops(struct rope *rope, struct tuple *new_tuple) * palloc a *new* buffer of sufficient * size. */ - new_field = palloc(fiber->gc_pool, + new_field = (char *) palloc(fiber->gc_pool, op->new_field_len); } op->meta->do_op(&op->arg, old_field, new_field); @@ -646,7 +644,7 @@ do_update_ops(struct rope *rope, struct tuple *new_tuple) } static struct update_op * -update_read_ops(const void **reqpos, const void *reqend, u32 op_cnt) +update_read_ops(const char **reqpos, const char *reqend, u32 op_cnt) { if (op_cnt > BOX_UPDATE_OP_CNT_MAX) tnt_raise(IllegalParams, "too many operations for update"); @@ -678,15 +676,15 @@ static void execute_update(struct request *request, struct txn *txn) { txn_add_redo(txn, request->type, request->data, request->len); - const void **reqpos = &request->data; - const void *reqend = (const char *) request->data + request->len; + const char **reqpos = &request->data; + const char *reqend = request->data + request->len; struct space *sp = read_space(reqpos, reqend); request->flags |= (pick_u32(reqpos, reqend) & BOX_ALLOWED_REQUEST_FLAGS); /* Parse UPDATE request. */ /** Search key and key part count. */ u32 key_part_count; - const void *key = read_key(reqpos, reqend, &key_part_count); + const char *key = read_key(reqpos, reqend, &key_part_count); Index *pk = space_index(sp, 0); /* Try to find the tuple by primary key. */ @@ -720,8 +718,8 @@ execute_update(struct request *request, struct txn *txn) static void execute_select(struct request *request, struct port *port) { - const void **reqpos = &request->data; - const void *reqend = (const char *) request->data + request->len; + const char **reqpos = &request->data; + const char *reqend = request->data + request->len; struct space *sp = read_space(reqpos, reqend); u32 index_no = pick_u32(reqpos, reqend); Index *index = index_find(sp, index_no); @@ -743,7 +741,7 @@ execute_select(struct request *request, struct port *port) /* read key */ u32 key_part_count; - const void *key = read_key(reqpos, reqend, &key_part_count); + const char *key = read_key(reqpos, reqend, &key_part_count); struct iterator *it = index->position(); index->initIterator(it, ITER_EQ, key, key_part_count); @@ -770,8 +768,8 @@ execute_delete(struct request *request, struct txn *txn) { u32 type = request->type; txn_add_redo(txn, type, request->data, request->len); - const void **reqpos = &request->data; - const void *reqend = (const char *) request->data + request->len; + const char **reqpos = &request->data; + const char *reqend = request->data + request->len; struct space *sp = read_space(reqpos, reqend); if (type == DELETE) { request->flags |= pick_u32(reqpos, reqend) & @@ -779,7 +777,7 @@ execute_delete(struct request *request, struct txn *txn) } /* read key */ u32 key_part_count; - const void *key = read_key(reqpos, reqend, &key_part_count); + const char *key = read_key(reqpos, reqend, &key_part_count); /* Try to find tuple by primary key */ Index *pk = space_index(sp, 0); struct tuple *old_tuple = pk->findByKey(key, key_part_count); @@ -811,7 +809,7 @@ request_name(u32 type) } struct request * -request_create(u32 type, const void *data, u32 len) +request_create(u32 type, const char *data, u32 len) { if (request_check_type(type)) { say_error("Unsupported request = %" PRIi32 "", type); diff --git a/src/box/request.h b/src/box/request.h index 952dbaa5cd8a714c465ca214db7c53427f09fe69..e2a1c1020ddf353786b1a111bed0e27a074f21db 100644 --- a/src/box/request.h +++ b/src/box/request.h @@ -103,11 +103,11 @@ struct request { u32 type; u32 flags; - const void *data; + const char *data; u32 len; }; -struct request *request_create(u32 type, const void *data, u32 len); +struct request *request_create(u32 type, const char *data, u32 len); void request_execute(struct request *request, struct txn *txn, struct port *port); diff --git a/src/box/space.cc b/src/box/space.cc index 7b531bccff49a62c341910762c5899b14fe2ea78..16a91536e349e6fc3aa24de4a5d5d8f1af7c9713 100644 --- a/src/box/space.cc +++ b/src/box/space.cc @@ -175,10 +175,10 @@ space_validate_tuple(struct space *sp, struct tuple *new_tuple) "tuple field count must match space cardinality"); /* Sweep through the tuple and check the field sizes. */ - const u8 *data = new_tuple->data; + const char *data = new_tuple->data; for (u32 f = 0; f < sp->max_fieldno; ++f) { /* Get the size of the current field and advance. */ - u32 len = load_varint32((const void **) &data); + u32 len = load_varint32(&data); data += len; /* * Check fixed size fields (NUM and NUM64) and diff --git a/src/box/tree_index.cc b/src/box/tree_index.cc index 04a45e0a4fbd768b63553b88458463057ad1ba5e..7ba2fabd215c63ec58366f5b17feacf3a1432a3f 100644 --- a/src/box/tree_index.cc +++ b/src/box/tree_index.cc @@ -126,7 +126,7 @@ struct sparse_str { union { - u8 data[7]; + char data[7]; u32 offset; }; u8 length; @@ -186,7 +186,7 @@ struct fixed_node { */ struct key_data { - const u8 *data; + const char *data; u32 part_count; union sparse_part parts[]; }; @@ -306,15 +306,15 @@ fold_with_sparse_parts(struct key_def *key_def, struct tuple *tuple, union spars { assert (tuple->field_count >= key_def->max_fieldno); - const u8 *part_data = tuple->data; + const char *part_data = tuple->data; memset(parts, 0, sizeof(parts[0]) * key_def->part_count); for (u32 field = 0; field < key_def->max_fieldno; ++field) { assert(field < tuple->field_count); - const u8 *data = part_data; - u32 len = load_varint32((const void**) &data); + const char *data = part_data; + u32 len = load_varint32(&data); u32 part = key_def->cmp_order[field]; if (part != BOX_FIELD_MAX) { @@ -347,15 +347,15 @@ fold_with_sparse_parts(struct key_def *key_def, struct tuple *tuple, union spars static void fold_with_key_parts(struct key_def *key_def, struct key_data *key_data) { - const u8 *part_data = key_data->data; + const char *part_data = key_data->data; union sparse_part* parts = key_data->parts; memset(parts, 0, sizeof(parts[0]) * key_def->part_count); u32 part_count = MIN(key_def->part_count, key_data->part_count); for (u32 part = 0; part < part_count; ++part) { - const u8 *data = part_data; - u32 len = load_varint32((const void**) &data); + const char *data = part_data; + u32 len = load_varint32(&data); if (key_def->parts[part].type == NUM) { if (len != sizeof parts[part].num32) @@ -383,13 +383,13 @@ fold_with_key_parts(struct key_def *key_def, struct key_data *key_data) static u32 fold_with_dense_offset(struct key_def *key_def, struct tuple *tuple) { - const u8 *tuple_data = tuple->data; + const char *tuple_data = tuple->data; for (u32 field = 0; field < key_def->max_fieldno; ++field) { assert(field < tuple->field_count); - const u8 *data = tuple_data; - u32 len = load_varint32((const void**) &data); + const char *data = tuple_data; + u32 len = load_varint32(&data); u32 part = key_def->cmp_order[field]; if (part != BOX_FIELD_MAX) { @@ -408,13 +408,13 @@ fold_with_dense_offset(struct key_def *key_def, struct tuple *tuple) static u32 fold_with_num32_value(struct key_def *key_def, struct tuple *tuple) { - const u8 *tuple_data = tuple->data; + const char *tuple_data = tuple->data; for (u32 field = 0; field < key_def->max_fieldno; ++field) { assert(field < tuple->field_count); - const u8 *data = tuple_data; - u32 len = load_varint32((const void**) &data); + const char *data = tuple_data; + u32 len = load_varint32(&data); u32 part = key_def->cmp_order[field]; if (part != BOX_FIELD_MAX) { @@ -435,8 +435,8 @@ fold_with_num32_value(struct key_def *key_def, struct tuple *tuple) */ static int sparse_part_compare(enum field_data_type type, - const u8 *data_a, union sparse_part part_a, - const u8 *data_b, union sparse_part part_b) + const char *data_a, union sparse_part part_a, + const char *data_b, union sparse_part part_b) { if (type == NUM) { return u32_cmp(part_a.num32, part_b.num32); @@ -444,19 +444,19 @@ sparse_part_compare(enum field_data_type type, return u64_cmp(part_a.num64, part_b.num64); } else { int cmp; - const u8 *ad, *bd; + const char *ad, *bd; u32 al = part_a.str.length; u32 bl = part_b.str.length; if (al == BIG_LENGTH) { ad = data_a + part_a.str.offset; - al = load_varint32((const void **) &ad); + al = load_varint32(&ad); } else { assert(al <= sizeof(part_a.str.data)); ad = part_a.str.data; } if (bl == BIG_LENGTH) { bd = data_b + part_b.str.offset; - bl = load_varint32((const void **) &bd); + bl = load_varint32(&bd); } else { assert(bl <= sizeof(part_b.str.data)); bd = part_b.str.data; @@ -519,8 +519,8 @@ sparse_key_node_compare(struct key_def *key_def, */ static int dense_part_compare(enum field_data_type type, - const u8 *ad, u32 al, - const u8 *bd, u32 bl) + const char *ad, u32 al, + const char *bd, u32 bl) { if (type == NUM) { u32 an, bn; @@ -563,11 +563,11 @@ dense_node_compare(struct key_def *key_def, u32 first_field, off_a[0] = offset_a; off_b[0] = offset_b; if (part_count > 1) { - u8 *ad = tuple_a->data + offset_a; - u8 *bd = tuple_b->data + offset_b; + const char *ad = tuple_a->data + offset_a; + const char *bd = tuple_b->data + offset_b; for (u32 i = 1; i < part_count; ++i) { - u32 al = load_varint32((const void**) &ad); - u32 bl = load_varint32((const void**) &bd); + u32 al = load_varint32(&ad); + u32 bl = load_varint32(&bd); ad += al; bd += bl; off_a[i] = ad - tuple_a->data; @@ -578,10 +578,10 @@ dense_node_compare(struct key_def *key_def, u32 first_field, /* Compare key parts. */ for (u32 part = 0; part < part_count; ++part) { u32 field = key_def->parts[part].fieldno; - u8 *ad = tuple_a->data + off_a[field - first_field]; - u8 *bd = tuple_b->data + off_b[field - first_field]; - u32 al = load_varint32((const void **) &ad); - u32 bl = load_varint32((const void **) &bd); + const char *ad = tuple_a->data + off_a[field - first_field]; + const char *bd = tuple_b->data + off_b[field - first_field]; + u32 al = load_varint32(&ad); + u32 bl = load_varint32(&bd); int r = dense_part_compare(key_def->parts[part].type, ad, al, bd, bl); if (r) { @@ -605,11 +605,11 @@ linear_node_compare(struct key_def *key_def, assert(first_field + part_count <= tuple_b->field_count); /* Compare key parts. */ - const u8 *ad = tuple_a->data + offset_a; - const u8 *bd = tuple_b->data + offset_b; + const char *ad = tuple_a->data + offset_a; + const char *bd = tuple_b->data + offset_b; for (u32 part = 0; part < part_count; ++part) { - u32 al = load_varint32((const void**) &ad); - u32 bl = load_varint32((const void**) &bd); + u32 al = load_varint32(&ad); + u32 bl = load_varint32(&bd); int r = dense_part_compare(key_def->parts[part].type, ad, al, bd, bl); if (r) { @@ -626,8 +626,8 @@ linear_node_compare(struct key_def *key_def, */ static int dense_key_part_compare(enum field_data_type type, - const u8 *data_a, union sparse_part part_a, - const u8 *bd, u32 bl) + const char *data_a, union sparse_part part_a, + const char *bd, u32 bl) { if (type == NUM) { u32 an, bn; @@ -643,11 +643,11 @@ dense_key_part_compare(enum field_data_type type, return u64_cmp(an, bn); } else { int cmp; - const u8 *ad; + const char *ad; u32 al = part_a.str.length; if (al == BIG_LENGTH) { ad = data_a + part_a.str.offset; - al = load_varint32((const void **) &ad); + al = load_varint32(&ad); } else { assert(al <= sizeof(part_a.str.data)); ad = part_a.str.data; @@ -679,9 +679,9 @@ dense_key_node_compare(struct key_def *key_def, /* Find field offsets. */ off[0] = offset; if (part_count > 1) { - const u8 *data = tuple->data + offset; + const char *data = tuple->data + offset; for (u32 i = 1; i < part_count; ++i) { - u32 len = load_varint32((const void**) &data); + u32 len = load_varint32(&data); data += len; off[i] = data - tuple->data; } @@ -692,8 +692,8 @@ dense_key_node_compare(struct key_def *key_def, part_count = key_data->part_count; for (u32 part = 0; part < part_count; ++part) { u32 field = key_def->parts[part].fieldno; - const u8 *bd = tuple->data + off[field - first_field]; - u32 bl = load_varint32((const void **) &bd); + const char *bd = tuple->data + off[field - first_field]; + u32 bl = load_varint32(&bd); int r = dense_key_part_compare(key_def->parts[part].type, key_data->data, key_data->parts[part], @@ -721,9 +721,9 @@ linear_key_node_compare(struct key_def *key_def, /* Compare key parts. */ if (part_count > key_data->part_count) part_count = key_data->part_count; - u8 *bd = tuple->data + offset; + const char *bd = tuple->data + offset; for (u32 part = 0; part < part_count; ++part) { - u32 bl = load_varint32((const void **) &bd); + u32 bl = load_varint32(&bd); int r = dense_key_part_compare(key_def->parts[part].type, key_data->data, key_data->parts[part], @@ -1012,7 +1012,7 @@ TreeIndex::random(u32 rnd) const } struct tuple * -TreeIndex::findByKey(const void *key, u32 part_count) const +TreeIndex::findByKey(const char *key, u32 part_count) const { assert(key_def->is_unique); check_key_parts(key_def, part_count, false); @@ -1021,7 +1021,7 @@ TreeIndex::findByKey(const void *key, u32 part_count) const alloca(sizeof(struct key_data) + _SIZEOF_SPARSE_PARTS(part_count)); - key_data->data = (const u8 *) key; + key_data->data = key; key_data->part_count = part_count; fold_with_key_parts(key_def, key_data); @@ -1101,7 +1101,7 @@ TreeIndex::allocIterator() const void TreeIndex::initIterator(struct iterator *iterator, enum iterator_type type, - const void *key, u32 part_count) const + const char *key, u32 part_count) const { struct tree_iterator *it = tree_iterator(iterator); @@ -1116,7 +1116,7 @@ TreeIndex::initIterator(struct iterator *iterator, enum iterator_type type, type = iterator_type_is_reverse(type) ? ITER_LE : ITER_GE; key = NULL; } - it->key_data.data = (const u8 *) key; + it->key_data.data = key; it->key_data.part_count = part_count; fold_with_key_parts(key_def, &it->key_data); @@ -1185,7 +1185,7 @@ TreeIndex::buildNext(struct tuple *tuple) } } - void *node = ((u8 *) tree.members + tree.size * node_size); + void *node = ((char *) tree.members + tree.size * node_size); fold(node, tuple); tree.size++; } @@ -1232,7 +1232,7 @@ TreeIndex::build(Index *pk) struct tuple *tuple; for (u32 i = 0; (tuple = it->next(it)) != NULL; ++i) { - void *node = ((u8 *) nodes + i * node_size); + void *node = ((char *) nodes + i * node_size); fold(node, tuple); } diff --git a/src/box/tree_index.h b/src/box/tree_index.h index 58b0829dca1ad27c29c25ff953326c5a40f5dac7..33ed75887991e7d5e5776a6aa8f8b460d07f18c9 100644 --- a/src/box/tree_index.h +++ b/src/box/tree_index.h @@ -53,7 +53,7 @@ class TreeIndex: public Index { virtual struct tuple *min() const; virtual struct tuple *max() const; virtual struct tuple *random(u32 rnd) const; - virtual struct tuple *findByKey(const void *key, u32 part_count) const; + virtual struct tuple *findByKey(const char *key, u32 part_count) const; virtual struct tuple *findByTuple(struct tuple *tuple) const; virtual struct tuple *replace(struct tuple *old_tuple, struct tuple *new_tuple, @@ -62,7 +62,7 @@ class TreeIndex: public Index { virtual struct iterator *allocIterator() const; virtual void initIterator(struct iterator *iterator, enum iterator_type type, - const void *key, u32 part_count) const; + const char *key, u32 part_count) const; // protected: /* Needed by iterators */ diff --git a/src/box/tuple.cc b/src/box/tuple.cc index 2e42bf0ac0d5b68d80eac1bae67c7bfc7ab08929..fe6c65fbe16b82b2e34c571aabf68dba8d13a091 100644 --- a/src/box/tuple.cc +++ b/src/box/tuple.cc @@ -76,11 +76,11 @@ tuple_ref(struct tuple *tuple, int count) } /** Get the next field from a tuple */ -static void * -next_field(const void *f) +static const char * +next_field(const char *f) { u32 size = load_varint32(&f); - return (u8 *)f + size; + return f + size; } /** @@ -88,10 +88,10 @@ next_field(const void *f) * * @returns field data if field exists or NULL */ -void * +const char * tuple_field(struct tuple *tuple, u32 i) { - void *field = tuple->data; + const char *field = tuple->data; if (i >= tuple->field_count) return NULL; @@ -104,7 +104,7 @@ tuple_field(struct tuple *tuple, u32 i) /** print field to tbuf */ static void -print_field(struct tbuf *buf, const void *f) +print_field(struct tbuf *buf, const char *f) { uint32_t size = load_varint32(&f); switch (size) { @@ -125,7 +125,7 @@ print_field(struct tbuf *buf, const void *f) } else { tbuf_printf(buf, "\\x%02X", *(u8 *)f); } - f = (char *) f + 1; + f++; } tbuf_printf(buf, "'"); break; @@ -137,7 +137,7 @@ print_field(struct tbuf *buf, const void *f) * key: { value, value, value } */ void -tuple_print(struct tbuf *buf, u32 field_count, const void *f) +tuple_print(struct tbuf *buf, u32 field_count, const char *f) { if (field_count == 0) { tbuf_printf(buf, "'': {}"); diff --git a/src/box/tuple.h b/src/box/tuple.h index d3bc4c58e3d2322939f4b654febe97f7cd270499..cf55551ef84129193b16501f28b110472404f6d8 100644 --- a/src/box/tuple.h +++ b/src/box/tuple.h @@ -52,7 +52,7 @@ struct tuple * into a contiguous byte array. Each field is prefixed * with BER-packed field length. */ - u8 data[0]; + char data[0]; } __attribute__((packed)); /** Allocate a tuple @@ -76,7 +76,7 @@ tuple_ref(struct tuple *tuple, int count); * * @returns field data if the field exists, or NULL */ -void * +const char * tuple_field(struct tuple *tuple, u32 i); /** @@ -84,7 +84,7 @@ tuple_field(struct tuple *tuple, u32 i); * key: { value, value, value } */ void -tuple_print(struct tbuf *buf, u32 field_count, const void *f); +tuple_print(struct tbuf *buf, u32 field_count, const char *f); /** Tuple length when adding to iov. */ static inline size_t tuple_len(struct tuple *tuple) @@ -101,18 +101,18 @@ void tuple_free(struct tuple *tuple); * @returns size of fields data including size of varint data */ static inline size_t -tuple_range_size(const void **begin, const void *end, size_t count) +tuple_range_size(const char **begin, const char *end, size_t count) { - const char *start = (const char *) *begin; + const char *start = *begin; while (*begin < end && count-- > 0) { size_t len = load_varint32(begin); - *begin = (const char *) *begin + len; + *begin += len; } - return (const char*) *begin - start; + return *begin - start; } static inline uint32_t -valid_tuple(const void *data, const void *end, uint32_t field_count) +valid_tuple(const char *data, const char *end, uint32_t field_count) { return tuple_range_size(&data, end, field_count); } diff --git a/src/box/txn.cc b/src/box/txn.cc index cc51ab86366e4d3a6a059d767ab0588f1eae9440..6bfaaf278524a5c1af0d555ac512b2baee43f1b1 100644 --- a/src/box/txn.cc +++ b/src/box/txn.cc @@ -36,7 +36,7 @@ #include "request.h" /* for request_name */ void -txn_add_redo(struct txn *txn, u16 op, const void *data, u32 len) +txn_add_redo(struct txn *txn, u16 op, const char *data, u32 len) { txn->op = op; txn->data = data; diff --git a/src/box/txn.h b/src/box/txn.h index 8e08a0cbdd758a42410474e2bdc7d014eebd0f29..eee411172bddcfcace6047c326229e2a3c9cc84a 100644 --- a/src/box/txn.h +++ b/src/box/txn.h @@ -40,7 +40,7 @@ struct txn { struct tuple *new_tuple; /* Redo info: binary packet */ - const void *data; + const char *data; u32 len; u16 op; }; @@ -49,7 +49,7 @@ struct txn *txn_begin(); void txn_commit(struct txn *txn); void txn_finish(struct txn *txn); void txn_rollback(struct txn *txn); -void txn_add_redo(struct txn *txn, u16 op, const void *data, u32 len); +void txn_add_redo(struct txn *txn, u16 op, const char *data, u32 len); void txn_replace(struct txn *txn, struct space *space, struct tuple *old_tuple, struct tuple *new_tuple, enum dup_replace_mode mode); diff --git a/src/iproto.cc b/src/iproto.cc index 3bb365bfaca9b32447e4368759a285f4b3858013..50fb27c9b872e8324d7a48bc22229f4b8ed593ff 100644 --- a/src/iproto.cc +++ b/src/iproto.cc @@ -73,7 +73,7 @@ struct iproto_reply_header { const uint32_t msg_ping = 0xff00; static inline struct iproto_header * -iproto(const void *pos) +iproto(const char *pos) { return (struct iproto_header *) pos; } @@ -759,7 +759,7 @@ iproto_reply(struct port_iproto *port, box_process_func callback, return iproto_reply_ping(out, header); /* Make request body point to iproto data */ - void *body = (char *) &header[1]; + char *body = (char *) &header[1]; port_iproto_init(port, out, header); try { callback((struct port *) port, header->msg_code, diff --git a/src/log_io.cc b/src/log_io.cc index ba2d662ba2ab3315b5fcb65494206e433096f142..fdecb1840de8bde4357ef22c15040ce837ebb72f 100644 --- a/src/log_io.cc +++ b/src/log_io.cc @@ -54,7 +54,7 @@ header_v11_sign(struct header_v11 *header) void row_v11_fill(struct row_v11 *row, u64 lsn, u16 tag, u64 cookie, - const void *metadata, size_t metadata_len, const void + const char *metadata, size_t metadata_len, const char *data, size_t data_len) { row->marker = row_marker_v11; diff --git a/src/memcached-grammar.cc b/src/memcached-grammar.cc index 7b177d3c14b5a3a5e3ceb7c872416ea7281db76a..976e699bbdb00396cd578d0cc53b4ad898d9c0c8 100644 --- a/src/memcached-grammar.cc +++ b/src/memcached-grammar.cc @@ -48,7 +48,7 @@ memcached_dispatch(struct ev_io *coio, struct iobuf *iobuf) char *p, *pe; char *fstart; struct tbuf *keys = tbuf_new(fiber->gc_pool); - const void *key; + const char *key; bool append, show_cas; int incr_sign; u64 cas, incr; @@ -146,7 +146,7 @@ case 5: goto st0; goto tr15; tr15: -#line 222 "src/memcached-grammar.rl" +#line 223 "src/memcached-grammar.rl" { fstart = p; for (; p < pe && *p != ' ' && *p != '\r' && *p != '\n'; p++); @@ -176,7 +176,7 @@ case 7: goto tr17; goto st0; tr17: -#line 221 "src/memcached-grammar.rl" +#line 222 "src/memcached-grammar.rl" { fstart = p; } goto st8; st8: @@ -190,7 +190,7 @@ case 8: goto st8; goto st0; tr18: -#line 244 "src/memcached-grammar.rl" +#line 245 "src/memcached-grammar.rl" {flags = natoq(fstart, p);} goto st9; st9: @@ -204,7 +204,7 @@ case 9: goto tr21; goto st0; tr21: -#line 221 "src/memcached-grammar.rl" +#line 222 "src/memcached-grammar.rl" { fstart = p; } goto st10; st10: @@ -218,7 +218,7 @@ case 10: goto st10; goto st0; tr22: -#line 237 "src/memcached-grammar.rl" +#line 238 "src/memcached-grammar.rl" { exptime = natoq(fstart, p); if (exptime > 0 && exptime <= 60*60*24*30) @@ -236,7 +236,7 @@ case 11: goto tr25; goto st0; tr25: -#line 221 "src/memcached-grammar.rl" +#line 222 "src/memcached-grammar.rl" { fstart = p; } goto st12; st12: @@ -253,11 +253,11 @@ case 12: goto st12; goto st0; tr26: -#line 245 "src/memcached-grammar.rl" +#line 246 "src/memcached-grammar.rl" {bytes = natoq(fstart, p);} -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 250 "src/memcached-grammar.rl" +#line 251 "src/memcached-grammar.rl" { size_t parsed = p - in->pos; while (ibuf_size(in) - parsed < bytes + 2) { @@ -280,7 +280,7 @@ case 12: goto exit; } } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; @@ -297,9 +297,9 @@ case 12: } goto st197; tr30: -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 250 "src/memcached-grammar.rl" +#line 251 "src/memcached-grammar.rl" { size_t parsed = p - in->pos; while (ibuf_size(in) - parsed < bytes + 2) { @@ -322,7 +322,7 @@ case 12: goto exit; } } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; @@ -339,11 +339,11 @@ case 12: } goto st197; tr39: -#line 281 "src/memcached-grammar.rl" +#line 282 "src/memcached-grammar.rl" { noreply = true; } -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 250 "src/memcached-grammar.rl" +#line 251 "src/memcached-grammar.rl" { size_t parsed = p - in->pos; while (ibuf_size(in) - parsed < bytes + 2) { @@ -366,7 +366,7 @@ case 12: goto exit; } } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; @@ -383,11 +383,11 @@ case 12: } goto st197; tr58: -#line 245 "src/memcached-grammar.rl" +#line 246 "src/memcached-grammar.rl" {bytes = natoq(fstart, p);} -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 250 "src/memcached-grammar.rl" +#line 251 "src/memcached-grammar.rl" { size_t parsed = p - in->pos; while (ibuf_size(in) - parsed < bytes + 2) { @@ -410,7 +410,7 @@ case 12: goto exit; } } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; @@ -419,7 +419,7 @@ case 12: #line 97 "src/memcached-grammar.rl" { struct tbuf *b; - const void *value; + const char *value; u32 value_len; key = tbuf_read_field(keys); @@ -445,9 +445,9 @@ case 12: } goto st197; tr62: -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 250 "src/memcached-grammar.rl" +#line 251 "src/memcached-grammar.rl" { size_t parsed = p - in->pos; while (ibuf_size(in) - parsed < bytes + 2) { @@ -470,7 +470,7 @@ case 12: goto exit; } } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; @@ -479,7 +479,7 @@ case 12: #line 97 "src/memcached-grammar.rl" { struct tbuf *b; - const void *value; + const char *value; u32 value_len; key = tbuf_read_field(keys); @@ -505,11 +505,11 @@ case 12: } goto st197; tr71: -#line 281 "src/memcached-grammar.rl" +#line 282 "src/memcached-grammar.rl" { noreply = true; } -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 250 "src/memcached-grammar.rl" +#line 251 "src/memcached-grammar.rl" { size_t parsed = p - in->pos; while (ibuf_size(in) - parsed < bytes + 2) { @@ -532,7 +532,7 @@ case 12: goto exit; } } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; @@ -541,7 +541,7 @@ case 12: #line 97 "src/memcached-grammar.rl" { struct tbuf *b; - const void *value; + const char *value; u32 value_len; key = tbuf_read_field(keys); @@ -567,11 +567,11 @@ case 12: } goto st197; tr91: -#line 246 "src/memcached-grammar.rl" +#line 247 "src/memcached-grammar.rl" {cas = natoq(fstart, p);} -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 250 "src/memcached-grammar.rl" +#line 251 "src/memcached-grammar.rl" { size_t parsed = p - in->pos; while (ibuf_size(in) - parsed < bytes + 2) { @@ -594,7 +594,7 @@ case 12: goto exit; } } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; @@ -613,9 +613,9 @@ case 12: } goto st197; tr95: -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 250 "src/memcached-grammar.rl" +#line 251 "src/memcached-grammar.rl" { size_t parsed = p - in->pos; while (ibuf_size(in) - parsed < bytes + 2) { @@ -638,7 +638,7 @@ case 12: goto exit; } } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; @@ -657,11 +657,11 @@ case 12: } goto st197; tr105: -#line 281 "src/memcached-grammar.rl" +#line 282 "src/memcached-grammar.rl" { noreply = true; } -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 250 "src/memcached-grammar.rl" +#line 251 "src/memcached-grammar.rl" { size_t parsed = p - in->pos; while (ibuf_size(in) - parsed < bytes + 2) { @@ -684,7 +684,7 @@ case 12: goto exit; } } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; @@ -703,11 +703,11 @@ case 12: } goto st197; tr118: -#line 247 "src/memcached-grammar.rl" +#line 248 "src/memcached-grammar.rl" {incr = natoq(fstart, p);} -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; @@ -717,7 +717,7 @@ case 12: { struct meta *m; struct tbuf *b; - const void *field; + const char *field; u32 value_len; u64 value; @@ -731,7 +731,8 @@ case 12: value_len = load_varint32(&field); if (is_numeric(field, value_len)) { - value = natoq((char *) field, (char *) field + value_len); + value = natoq((const char *) field, + (const char *) field + value_len); if (incr_sign > 0) { value += incr; @@ -769,9 +770,9 @@ case 12: } goto st197; tr122: -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; @@ -781,7 +782,7 @@ case 12: { struct meta *m; struct tbuf *b; - const void *field; + const char *field; u32 value_len; u64 value; @@ -795,7 +796,8 @@ case 12: value_len = load_varint32(&field); if (is_numeric(field, value_len)) { - value = natoq((char *) field, (char *) field + value_len); + value = natoq((const char *) field, + (const char *) field + value_len); if (incr_sign > 0) { value += incr; @@ -833,11 +835,11 @@ case 12: } goto st197; tr132: -#line 281 "src/memcached-grammar.rl" +#line 282 "src/memcached-grammar.rl" { noreply = true; } -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; @@ -847,7 +849,7 @@ case 12: { struct meta *m; struct tbuf *b; - const void *field; + const char *field; u32 value_len; u64 value; @@ -861,7 +863,8 @@ case 12: value_len = load_varint32(&field); if (is_numeric(field, value_len)) { - value = natoq((char *) field, (char *) field + value_len); + value = natoq((const char *) field, + (const char *) field + value_len); if (incr_sign > 0) { value += incr; @@ -899,15 +902,15 @@ case 12: } goto st197; tr141: -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; in->pos = p; } -#line 178 "src/memcached-grammar.rl" +#line 179 "src/memcached-grammar.rl" { key = tbuf_read_field(keys); struct tuple *tuple = find(key); @@ -915,7 +918,7 @@ case 12: obuf_dup(out, "NOT_FOUND\r\n", 11); } else { try { - remove(key); + memcached_delete(key); obuf_dup(out, "DELETED\r\n", 9); } catch (const ClientError& e) { @@ -927,21 +930,21 @@ case 12: } goto st197; tr146: -#line 237 "src/memcached-grammar.rl" +#line 238 "src/memcached-grammar.rl" { exptime = natoq(fstart, p); if (exptime > 0 && exptime <= 60*60*24*30) exptime = exptime + ev_now(); } -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; in->pos = p; } -#line 178 "src/memcached-grammar.rl" +#line 179 "src/memcached-grammar.rl" { key = tbuf_read_field(keys); struct tuple *tuple = find(key); @@ -949,7 +952,7 @@ case 12: obuf_dup(out, "NOT_FOUND\r\n", 11); } else { try { - remove(key); + memcached_delete(key); obuf_dup(out, "DELETED\r\n", 9); } catch (const ClientError& e) { @@ -961,17 +964,17 @@ case 12: } goto st197; tr157: -#line 281 "src/memcached-grammar.rl" +#line 282 "src/memcached-grammar.rl" { noreply = true; } -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; in->pos = p; } -#line 178 "src/memcached-grammar.rl" +#line 179 "src/memcached-grammar.rl" { key = tbuf_read_field(keys); struct tuple *tuple = find(key); @@ -979,7 +982,7 @@ case 12: obuf_dup(out, "NOT_FOUND\r\n", 11); } else { try { - remove(key); + memcached_delete(key); obuf_dup(out, "DELETED\r\n", 9); } catch (const ClientError& e) { @@ -991,15 +994,15 @@ case 12: } goto st197; tr169: -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; in->pos = p; } -#line 207 "src/memcached-grammar.rl" +#line 208 "src/memcached-grammar.rl" { struct fiber *f = fiber_new("flush_all", flush_all); fiber_call(f, flush_delay); @@ -1007,17 +1010,17 @@ case 12: } goto st197; tr174: -#line 248 "src/memcached-grammar.rl" +#line 249 "src/memcached-grammar.rl" {flush_delay = natoq(fstart, p);} -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; in->pos = p; } -#line 207 "src/memcached-grammar.rl" +#line 208 "src/memcached-grammar.rl" { struct fiber *f = fiber_new("flush_all", flush_all); fiber_call(f, flush_delay); @@ -1025,17 +1028,17 @@ case 12: } goto st197; tr185: -#line 281 "src/memcached-grammar.rl" +#line 282 "src/memcached-grammar.rl" { noreply = true; } -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; in->pos = p; } -#line 207 "src/memcached-grammar.rl" +#line 208 "src/memcached-grammar.rl" { struct fiber *f = fiber_new("flush_all", flush_all); fiber_call(f, flush_delay); @@ -1043,15 +1046,15 @@ case 12: } goto st197; tr195: -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; in->pos = p; } -#line 196 "src/memcached-grammar.rl" +#line 197 "src/memcached-grammar.rl" { try { memcached_get(out, keys_count, keys, show_cas); @@ -1064,25 +1067,25 @@ case 12: } goto st197; tr213: -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; in->pos = p; } -#line 217 "src/memcached-grammar.rl" +#line 218 "src/memcached-grammar.rl" { return -1; } goto st197; tr233: -#line 245 "src/memcached-grammar.rl" +#line 246 "src/memcached-grammar.rl" {bytes = natoq(fstart, p);} -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 250 "src/memcached-grammar.rl" +#line 251 "src/memcached-grammar.rl" { size_t parsed = p - in->pos; while (ibuf_size(in) - parsed < bytes + 2) { @@ -1105,7 +1108,7 @@ case 12: goto exit; } } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; @@ -1122,9 +1125,9 @@ case 12: } goto st197; tr237: -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 250 "src/memcached-grammar.rl" +#line 251 "src/memcached-grammar.rl" { size_t parsed = p - in->pos; while (ibuf_size(in) - parsed < bytes + 2) { @@ -1147,7 +1150,7 @@ case 12: goto exit; } } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; @@ -1164,11 +1167,11 @@ case 12: } goto st197; tr246: -#line 281 "src/memcached-grammar.rl" +#line 282 "src/memcached-grammar.rl" { noreply = true; } -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 250 "src/memcached-grammar.rl" +#line 251 "src/memcached-grammar.rl" { size_t parsed = p - in->pos; while (ibuf_size(in) - parsed < bytes + 2) { @@ -1191,7 +1194,7 @@ case 12: goto exit; } } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; @@ -1208,11 +1211,11 @@ case 12: } goto st197; tr263: -#line 245 "src/memcached-grammar.rl" +#line 246 "src/memcached-grammar.rl" {bytes = natoq(fstart, p);} -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 250 "src/memcached-grammar.rl" +#line 251 "src/memcached-grammar.rl" { size_t parsed = p - in->pos; while (ibuf_size(in) - parsed < bytes + 2) { @@ -1235,7 +1238,7 @@ case 12: goto exit; } } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; @@ -1248,9 +1251,9 @@ case 12: } goto st197; tr267: -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 250 "src/memcached-grammar.rl" +#line 251 "src/memcached-grammar.rl" { size_t parsed = p - in->pos; while (ibuf_size(in) - parsed < bytes + 2) { @@ -1273,7 +1276,7 @@ case 12: goto exit; } } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; @@ -1286,11 +1289,11 @@ case 12: } goto st197; tr276: -#line 281 "src/memcached-grammar.rl" +#line 282 "src/memcached-grammar.rl" { noreply = true; } -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 250 "src/memcached-grammar.rl" +#line 251 "src/memcached-grammar.rl" { size_t parsed = p - in->pos; while (ibuf_size(in) - parsed < bytes + 2) { @@ -1313,7 +1316,7 @@ case 12: goto exit; } } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; @@ -1326,15 +1329,15 @@ case 12: } goto st197; tr281: -#line 279 "src/memcached-grammar.rl" +#line 280 "src/memcached-grammar.rl" { p++; } -#line 273 "src/memcached-grammar.rl" +#line 274 "src/memcached-grammar.rl" { done = true; stats.bytes_read += p - in->pos; in->pos = p; } -#line 213 "src/memcached-grammar.rl" +#line 214 "src/memcached-grammar.rl" { print_stats(out); } @@ -1343,33 +1346,33 @@ case 12: if ( ++p == pe ) goto _test_eof197; case 197: -#line 1347 "src/memcached-grammar.cc" +#line 1350 "src/memcached-grammar.cc" goto st0; tr27: -#line 245 "src/memcached-grammar.rl" +#line 246 "src/memcached-grammar.rl" {bytes = natoq(fstart, p);} goto st13; tr40: -#line 281 "src/memcached-grammar.rl" +#line 282 "src/memcached-grammar.rl" { noreply = true; } goto st13; st13: if ( ++p == pe ) goto _test_eof13; case 13: -#line 1361 "src/memcached-grammar.cc" +#line 1364 "src/memcached-grammar.cc" if ( (*p) == 10 ) goto tr30; goto st0; tr28: -#line 245 "src/memcached-grammar.rl" +#line 246 "src/memcached-grammar.rl" {bytes = natoq(fstart, p);} goto st14; st14: if ( ++p == pe ) goto _test_eof14; case 14: -#line 1373 "src/memcached-grammar.cc" +#line 1376 "src/memcached-grammar.cc" switch( (*p) ) { case 32: goto st14; case 78: goto st15; @@ -1483,18 +1486,18 @@ case 26: goto tr45; goto st0; tr45: -#line 287 "src/memcached-grammar.rl" +#line 288 "src/memcached-grammar.rl" {append = true; } goto st27; tr209: -#line 288 "src/memcached-grammar.rl" +#line 289 "src/memcached-grammar.rl" {append = false;} goto st27; st27: if ( ++p == pe ) goto _test_eof27; case 27: -#line 1498 "src/memcached-grammar.cc" +#line 1501 "src/memcached-grammar.cc" switch( (*p) ) { case 13: goto st0; case 32: goto st27; @@ -1503,7 +1506,7 @@ case 27: goto st0; goto tr46; tr46: -#line 222 "src/memcached-grammar.rl" +#line 223 "src/memcached-grammar.rl" { fstart = p; for (; p < pe && *p != ' ' && *p != '\r' && *p != '\n'; p++); @@ -1519,7 +1522,7 @@ case 27: if ( ++p == pe ) goto _test_eof28; case 28: -#line 1523 "src/memcached-grammar.cc" +#line 1526 "src/memcached-grammar.cc" if ( (*p) == 32 ) goto st29; goto st0; @@ -1533,49 +1536,49 @@ case 29: goto tr49; goto st0; tr49: -#line 221 "src/memcached-grammar.rl" +#line 222 "src/memcached-grammar.rl" { fstart = p; } goto st30; st30: if ( ++p == pe ) goto _test_eof30; case 30: -#line 1544 "src/memcached-grammar.cc" +#line 1547 "src/memcached-grammar.cc" if ( (*p) == 32 ) goto tr50; if ( 48 <= (*p) && (*p) <= 57 ) goto st30; goto st0; tr50: -#line 244 "src/memcached-grammar.rl" +#line 245 "src/memcached-grammar.rl" {flags = natoq(fstart, p);} goto st31; st31: if ( ++p == pe ) goto _test_eof31; case 31: -#line 1558 "src/memcached-grammar.cc" +#line 1561 "src/memcached-grammar.cc" if ( (*p) == 32 ) goto st31; if ( 48 <= (*p) && (*p) <= 57 ) goto tr53; goto st0; tr53: -#line 221 "src/memcached-grammar.rl" +#line 222 "src/memcached-grammar.rl" { fstart = p; } goto st32; st32: if ( ++p == pe ) goto _test_eof32; case 32: -#line 1572 "src/memcached-grammar.cc" +#line 1575 "src/memcached-grammar.cc" if ( (*p) == 32 ) goto tr54; if ( 48 <= (*p) && (*p) <= 57 ) goto st32; goto st0; tr54: -#line 237 "src/memcached-grammar.rl" +#line 238 "src/memcached-grammar.rl" { exptime = natoq(fstart, p); if (exptime > 0 && exptime <= 60*60*24*30) @@ -1586,21 +1589,21 @@ case 32: if ( ++p == pe ) goto _test_eof33; case 33: -#line 1590 "src/memcached-grammar.cc" +#line 1593 "src/memcached-grammar.cc" if ( (*p) == 32 ) goto st33; if ( 48 <= (*p) && (*p) <= 57 ) goto tr57; goto st0; tr57: -#line 221 "src/memcached-grammar.rl" +#line 222 "src/memcached-grammar.rl" { fstart = p; } goto st34; st34: if ( ++p == pe ) goto _test_eof34; case 34: -#line 1604 "src/memcached-grammar.cc" +#line 1607 "src/memcached-grammar.cc" switch( (*p) ) { case 10: goto tr58; case 13: goto tr59; @@ -1610,30 +1613,30 @@ case 34: goto st34; goto st0; tr59: -#line 245 "src/memcached-grammar.rl" +#line 246 "src/memcached-grammar.rl" {bytes = natoq(fstart, p);} goto st35; tr72: -#line 281 "src/memcached-grammar.rl" +#line 282 "src/memcached-grammar.rl" { noreply = true; } goto st35; st35: if ( ++p == pe ) goto _test_eof35; case 35: -#line 1625 "src/memcached-grammar.cc" +#line 1628 "src/memcached-grammar.cc" if ( (*p) == 10 ) goto tr62; goto st0; tr60: -#line 245 "src/memcached-grammar.rl" +#line 246 "src/memcached-grammar.rl" {bytes = natoq(fstart, p);} goto st36; st36: if ( ++p == pe ) goto _test_eof36; case 36: -#line 1637 "src/memcached-grammar.cc" +#line 1640 "src/memcached-grammar.cc" switch( (*p) ) { case 32: goto st36; case 78: goto st37; @@ -1740,7 +1743,7 @@ case 47: goto st0; goto tr76; tr76: -#line 222 "src/memcached-grammar.rl" +#line 223 "src/memcached-grammar.rl" { fstart = p; for (; p < pe && *p != ' ' && *p != '\r' && *p != '\n'; p++); @@ -1756,7 +1759,7 @@ case 47: if ( ++p == pe ) goto _test_eof48; case 48: -#line 1760 "src/memcached-grammar.cc" +#line 1763 "src/memcached-grammar.cc" if ( (*p) == 32 ) goto st49; goto st0; @@ -1770,49 +1773,49 @@ case 49: goto tr78; goto st0; tr78: -#line 221 "src/memcached-grammar.rl" +#line 222 "src/memcached-grammar.rl" { fstart = p; } goto st50; st50: if ( ++p == pe ) goto _test_eof50; case 50: -#line 1781 "src/memcached-grammar.cc" +#line 1784 "src/memcached-grammar.cc" if ( (*p) == 32 ) goto tr79; if ( 48 <= (*p) && (*p) <= 57 ) goto st50; goto st0; tr79: -#line 244 "src/memcached-grammar.rl" +#line 245 "src/memcached-grammar.rl" {flags = natoq(fstart, p);} goto st51; st51: if ( ++p == pe ) goto _test_eof51; case 51: -#line 1795 "src/memcached-grammar.cc" +#line 1798 "src/memcached-grammar.cc" if ( (*p) == 32 ) goto st51; if ( 48 <= (*p) && (*p) <= 57 ) goto tr82; goto st0; tr82: -#line 221 "src/memcached-grammar.rl" +#line 222 "src/memcached-grammar.rl" { fstart = p; } goto st52; st52: if ( ++p == pe ) goto _test_eof52; case 52: -#line 1809 "src/memcached-grammar.cc" +#line 1812 "src/memcached-grammar.cc" if ( (*p) == 32 ) goto tr83; if ( 48 <= (*p) && (*p) <= 57 ) goto st52; goto st0; tr83: -#line 237 "src/memcached-grammar.rl" +#line 238 "src/memcached-grammar.rl" { exptime = natoq(fstart, p); if (exptime > 0 && exptime <= 60*60*24*30) @@ -1823,49 +1826,49 @@ case 52: if ( ++p == pe ) goto _test_eof53; case 53: -#line 1827 "src/memcached-grammar.cc" +#line 1830 "src/memcached-grammar.cc" if ( (*p) == 32 ) goto st53; if ( 48 <= (*p) && (*p) <= 57 ) goto tr86; goto st0; tr86: -#line 221 "src/memcached-grammar.rl" +#line 222 "src/memcached-grammar.rl" { fstart = p; } goto st54; st54: if ( ++p == pe ) goto _test_eof54; case 54: -#line 1841 "src/memcached-grammar.cc" +#line 1844 "src/memcached-grammar.cc" if ( (*p) == 32 ) goto tr87; if ( 48 <= (*p) && (*p) <= 57 ) goto st54; goto st0; tr87: -#line 245 "src/memcached-grammar.rl" +#line 246 "src/memcached-grammar.rl" {bytes = natoq(fstart, p);} goto st55; st55: if ( ++p == pe ) goto _test_eof55; case 55: -#line 1855 "src/memcached-grammar.cc" +#line 1858 "src/memcached-grammar.cc" if ( (*p) == 32 ) goto st55; if ( 48 <= (*p) && (*p) <= 57 ) goto tr90; goto st0; tr90: -#line 221 "src/memcached-grammar.rl" +#line 222 "src/memcached-grammar.rl" { fstart = p; } goto st56; st56: if ( ++p == pe ) goto _test_eof56; case 56: -#line 1869 "src/memcached-grammar.cc" +#line 1872 "src/memcached-grammar.cc" switch( (*p) ) { case 10: goto tr91; case 13: goto tr92; @@ -1875,30 +1878,30 @@ case 56: goto st56; goto st0; tr106: -#line 281 "src/memcached-grammar.rl" +#line 282 "src/memcached-grammar.rl" { noreply = true; } goto st57; tr92: -#line 246 "src/memcached-grammar.rl" +#line 247 "src/memcached-grammar.rl" {cas = natoq(fstart, p);} goto st57; st57: if ( ++p == pe ) goto _test_eof57; case 57: -#line 1890 "src/memcached-grammar.cc" +#line 1893 "src/memcached-grammar.cc" if ( (*p) == 10 ) goto tr95; goto st0; tr93: -#line 246 "src/memcached-grammar.rl" +#line 247 "src/memcached-grammar.rl" {cas = natoq(fstart, p);} goto st58; st58: if ( ++p == pe ) goto _test_eof58; case 58: -#line 1902 "src/memcached-grammar.cc" +#line 1905 "src/memcached-grammar.cc" switch( (*p) ) { case 10: goto tr95; case 13: goto st57; @@ -1972,14 +1975,14 @@ case 65: } goto st0; tr107: -#line 281 "src/memcached-grammar.rl" +#line 282 "src/memcached-grammar.rl" { noreply = true; } goto st66; st66: if ( ++p == pe ) goto _test_eof66; case 66: -#line 1983 "src/memcached-grammar.cc" +#line 1986 "src/memcached-grammar.cc" switch( (*p) ) { case 10: goto tr95; case 13: goto st57; @@ -2023,18 +2026,18 @@ case 70: goto tr113; goto st0; tr113: -#line 296 "src/memcached-grammar.rl" +#line 297 "src/memcached-grammar.rl" {incr_sign = -1;} goto st71; tr202: -#line 295 "src/memcached-grammar.rl" +#line 296 "src/memcached-grammar.rl" {incr_sign = 1; } goto st71; st71: if ( ++p == pe ) goto _test_eof71; case 71: -#line 2038 "src/memcached-grammar.cc" +#line 2041 "src/memcached-grammar.cc" switch( (*p) ) { case 13: goto st0; case 32: goto st71; @@ -2043,7 +2046,7 @@ case 71: goto st0; goto tr114; tr114: -#line 222 "src/memcached-grammar.rl" +#line 223 "src/memcached-grammar.rl" { fstart = p; for (; p < pe && *p != ' ' && *p != '\r' && *p != '\n'; p++); @@ -2059,7 +2062,7 @@ case 71: if ( ++p == pe ) goto _test_eof72; case 72: -#line 2063 "src/memcached-grammar.cc" +#line 2066 "src/memcached-grammar.cc" if ( (*p) == 32 ) goto st73; goto st0; @@ -2073,14 +2076,14 @@ case 73: goto tr117; goto st0; tr117: -#line 221 "src/memcached-grammar.rl" +#line 222 "src/memcached-grammar.rl" { fstart = p; } goto st74; st74: if ( ++p == pe ) goto _test_eof74; case 74: -#line 2084 "src/memcached-grammar.cc" +#line 2087 "src/memcached-grammar.cc" switch( (*p) ) { case 10: goto tr118; case 13: goto tr119; @@ -2090,30 +2093,30 @@ case 74: goto st74; goto st0; tr133: -#line 281 "src/memcached-grammar.rl" +#line 282 "src/memcached-grammar.rl" { noreply = true; } goto st75; tr119: -#line 247 "src/memcached-grammar.rl" +#line 248 "src/memcached-grammar.rl" {incr = natoq(fstart, p);} goto st75; st75: if ( ++p == pe ) goto _test_eof75; case 75: -#line 2105 "src/memcached-grammar.cc" +#line 2108 "src/memcached-grammar.cc" if ( (*p) == 10 ) goto tr122; goto st0; tr120: -#line 247 "src/memcached-grammar.rl" +#line 248 "src/memcached-grammar.rl" {incr = natoq(fstart, p);} goto st76; st76: if ( ++p == pe ) goto _test_eof76; case 76: -#line 2117 "src/memcached-grammar.cc" +#line 2120 "src/memcached-grammar.cc" switch( (*p) ) { case 10: goto tr122; case 13: goto st75; @@ -2187,14 +2190,14 @@ case 83: } goto st0; tr134: -#line 281 "src/memcached-grammar.rl" +#line 282 "src/memcached-grammar.rl" { noreply = true; } goto st84; st84: if ( ++p == pe ) goto _test_eof84; case 84: -#line 2198 "src/memcached-grammar.cc" +#line 2201 "src/memcached-grammar.cc" switch( (*p) ) { case 10: goto tr122; case 13: goto st75; @@ -2247,7 +2250,7 @@ case 89: goto st0; goto tr140; tr140: -#line 222 "src/memcached-grammar.rl" +#line 223 "src/memcached-grammar.rl" { fstart = p; for (; p < pe && *p != ' ' && *p != '\r' && *p != '\n'; p++); @@ -2263,7 +2266,7 @@ case 89: if ( ++p == pe ) goto _test_eof90; case 90: -#line 2267 "src/memcached-grammar.cc" +#line 2270 "src/memcached-grammar.cc" switch( (*p) ) { case 10: goto tr141; case 13: goto st91; @@ -2271,7 +2274,7 @@ case 90: } goto st0; tr147: -#line 237 "src/memcached-grammar.rl" +#line 238 "src/memcached-grammar.rl" { exptime = natoq(fstart, p); if (exptime > 0 && exptime <= 60*60*24*30) @@ -2279,14 +2282,14 @@ case 90: } goto st91; tr158: -#line 281 "src/memcached-grammar.rl" +#line 282 "src/memcached-grammar.rl" { noreply = true; } goto st91; st91: if ( ++p == pe ) goto _test_eof91; case 91: -#line 2290 "src/memcached-grammar.cc" +#line 2293 "src/memcached-grammar.cc" if ( (*p) == 10 ) goto tr141; goto st0; @@ -2305,14 +2308,14 @@ case 92: goto tr144; goto st0; tr144: -#line 221 "src/memcached-grammar.rl" +#line 222 "src/memcached-grammar.rl" { fstart = p; } goto st93; st93: if ( ++p == pe ) goto _test_eof93; case 93: -#line 2316 "src/memcached-grammar.cc" +#line 2319 "src/memcached-grammar.cc" switch( (*p) ) { case 10: goto tr146; case 13: goto tr147; @@ -2322,7 +2325,7 @@ case 93: goto st93; goto st0; tr148: -#line 237 "src/memcached-grammar.rl" +#line 238 "src/memcached-grammar.rl" { exptime = natoq(fstart, p); if (exptime > 0 && exptime <= 60*60*24*30) @@ -2333,7 +2336,7 @@ case 93: if ( ++p == pe ) goto _test_eof94; case 94: -#line 2337 "src/memcached-grammar.cc" +#line 2340 "src/memcached-grammar.cc" switch( (*p) ) { case 10: goto tr141; case 13: goto st91; @@ -2407,14 +2410,14 @@ case 101: } goto st0; tr159: -#line 281 "src/memcached-grammar.rl" +#line 282 "src/memcached-grammar.rl" { noreply = true; } goto st102; st102: if ( ++p == pe ) goto _test_eof102; case 102: -#line 2418 "src/memcached-grammar.cc" +#line 2421 "src/memcached-grammar.cc" switch( (*p) ) { case 10: goto tr141; case 13: goto st91; @@ -2502,18 +2505,18 @@ case 111: } goto st0; tr186: -#line 281 "src/memcached-grammar.rl" +#line 282 "src/memcached-grammar.rl" { noreply = true; } goto st112; tr175: -#line 248 "src/memcached-grammar.rl" +#line 249 "src/memcached-grammar.rl" {flush_delay = natoq(fstart, p);} goto st112; st112: if ( ++p == pe ) goto _test_eof112; case 112: -#line 2517 "src/memcached-grammar.cc" +#line 2520 "src/memcached-grammar.cc" if ( (*p) == 10 ) goto tr169; goto st0; @@ -2532,14 +2535,14 @@ case 113: goto tr172; goto st0; tr172: -#line 221 "src/memcached-grammar.rl" +#line 222 "src/memcached-grammar.rl" { fstart = p; } goto st114; st114: if ( ++p == pe ) goto _test_eof114; case 114: -#line 2543 "src/memcached-grammar.cc" +#line 2546 "src/memcached-grammar.cc" switch( (*p) ) { case 10: goto tr174; case 13: goto tr175; @@ -2549,14 +2552,14 @@ case 114: goto st114; goto st0; tr176: -#line 248 "src/memcached-grammar.rl" +#line 249 "src/memcached-grammar.rl" {flush_delay = natoq(fstart, p);} goto st115; st115: if ( ++p == pe ) goto _test_eof115; case 115: -#line 2560 "src/memcached-grammar.cc" +#line 2563 "src/memcached-grammar.cc" switch( (*p) ) { case 10: goto tr169; case 13: goto st112; @@ -2630,14 +2633,14 @@ case 122: } goto st0; tr187: -#line 281 "src/memcached-grammar.rl" +#line 282 "src/memcached-grammar.rl" { noreply = true; } goto st123; st123: if ( ++p == pe ) goto _test_eof123; case 123: -#line 2641 "src/memcached-grammar.cc" +#line 2644 "src/memcached-grammar.cc" switch( (*p) ) { case 10: goto tr169; case 13: goto st112; @@ -2673,18 +2676,18 @@ case 126: } goto st0; tr191: -#line 292 "src/memcached-grammar.rl" +#line 293 "src/memcached-grammar.rl" {show_cas = false;} goto st127; tr198: -#line 293 "src/memcached-grammar.rl" +#line 294 "src/memcached-grammar.rl" {show_cas = true;} goto st127; st127: if ( ++p == pe ) goto _test_eof127; case 127: -#line 2688 "src/memcached-grammar.cc" +#line 2691 "src/memcached-grammar.cc" switch( (*p) ) { case 13: goto st0; case 32: goto st127; @@ -2693,7 +2696,7 @@ case 127: goto st0; goto tr193; tr193: -#line 222 "src/memcached-grammar.rl" +#line 223 "src/memcached-grammar.rl" { fstart = p; for (; p < pe && *p != ' ' && *p != '\r' && *p != '\n'; p++); @@ -2709,7 +2712,7 @@ case 127: if ( ++p == pe ) goto _test_eof128; case 128: -#line 2713 "src/memcached-grammar.cc" +#line 2716 "src/memcached-grammar.cc" switch( (*p) ) { case 10: goto tr195; case 13: goto st129; @@ -2952,7 +2955,7 @@ case 155: goto st0; goto tr222; tr222: -#line 222 "src/memcached-grammar.rl" +#line 223 "src/memcached-grammar.rl" { fstart = p; for (; p < pe && *p != ' ' && *p != '\r' && *p != '\n'; p++); @@ -2968,7 +2971,7 @@ case 155: if ( ++p == pe ) goto _test_eof156; case 156: -#line 2972 "src/memcached-grammar.cc" +#line 2975 "src/memcached-grammar.cc" if ( (*p) == 32 ) goto st157; goto st0; @@ -2982,49 +2985,49 @@ case 157: goto tr224; goto st0; tr224: -#line 221 "src/memcached-grammar.rl" +#line 222 "src/memcached-grammar.rl" { fstart = p; } goto st158; st158: if ( ++p == pe ) goto _test_eof158; case 158: -#line 2993 "src/memcached-grammar.cc" +#line 2996 "src/memcached-grammar.cc" if ( (*p) == 32 ) goto tr225; if ( 48 <= (*p) && (*p) <= 57 ) goto st158; goto st0; tr225: -#line 244 "src/memcached-grammar.rl" +#line 245 "src/memcached-grammar.rl" {flags = natoq(fstart, p);} goto st159; st159: if ( ++p == pe ) goto _test_eof159; case 159: -#line 3007 "src/memcached-grammar.cc" +#line 3010 "src/memcached-grammar.cc" if ( (*p) == 32 ) goto st159; if ( 48 <= (*p) && (*p) <= 57 ) goto tr228; goto st0; tr228: -#line 221 "src/memcached-grammar.rl" +#line 222 "src/memcached-grammar.rl" { fstart = p; } goto st160; st160: if ( ++p == pe ) goto _test_eof160; case 160: -#line 3021 "src/memcached-grammar.cc" +#line 3024 "src/memcached-grammar.cc" if ( (*p) == 32 ) goto tr229; if ( 48 <= (*p) && (*p) <= 57 ) goto st160; goto st0; tr229: -#line 237 "src/memcached-grammar.rl" +#line 238 "src/memcached-grammar.rl" { exptime = natoq(fstart, p); if (exptime > 0 && exptime <= 60*60*24*30) @@ -3035,21 +3038,21 @@ case 160: if ( ++p == pe ) goto _test_eof161; case 161: -#line 3039 "src/memcached-grammar.cc" +#line 3042 "src/memcached-grammar.cc" if ( (*p) == 32 ) goto st161; if ( 48 <= (*p) && (*p) <= 57 ) goto tr232; goto st0; tr232: -#line 221 "src/memcached-grammar.rl" +#line 222 "src/memcached-grammar.rl" { fstart = p; } goto st162; st162: if ( ++p == pe ) goto _test_eof162; case 162: -#line 3053 "src/memcached-grammar.cc" +#line 3056 "src/memcached-grammar.cc" switch( (*p) ) { case 10: goto tr233; case 13: goto tr234; @@ -3059,30 +3062,30 @@ case 162: goto st162; goto st0; tr234: -#line 245 "src/memcached-grammar.rl" +#line 246 "src/memcached-grammar.rl" {bytes = natoq(fstart, p);} goto st163; tr247: -#line 281 "src/memcached-grammar.rl" +#line 282 "src/memcached-grammar.rl" { noreply = true; } goto st163; st163: if ( ++p == pe ) goto _test_eof163; case 163: -#line 3074 "src/memcached-grammar.cc" +#line 3077 "src/memcached-grammar.cc" if ( (*p) == 10 ) goto tr237; goto st0; tr235: -#line 245 "src/memcached-grammar.rl" +#line 246 "src/memcached-grammar.rl" {bytes = natoq(fstart, p);} goto st164; st164: if ( ++p == pe ) goto _test_eof164; case 164: -#line 3086 "src/memcached-grammar.cc" +#line 3089 "src/memcached-grammar.cc" switch( (*p) ) { case 32: goto st164; case 78: goto st165; @@ -3191,7 +3194,7 @@ case 175: goto st0; goto tr252; tr252: -#line 222 "src/memcached-grammar.rl" +#line 223 "src/memcached-grammar.rl" { fstart = p; for (; p < pe && *p != ' ' && *p != '\r' && *p != '\n'; p++); @@ -3207,7 +3210,7 @@ case 175: if ( ++p == pe ) goto _test_eof176; case 176: -#line 3211 "src/memcached-grammar.cc" +#line 3214 "src/memcached-grammar.cc" if ( (*p) == 32 ) goto st177; goto st0; @@ -3221,49 +3224,49 @@ case 177: goto tr254; goto st0; tr254: -#line 221 "src/memcached-grammar.rl" +#line 222 "src/memcached-grammar.rl" { fstart = p; } goto st178; st178: if ( ++p == pe ) goto _test_eof178; case 178: -#line 3232 "src/memcached-grammar.cc" +#line 3235 "src/memcached-grammar.cc" if ( (*p) == 32 ) goto tr255; if ( 48 <= (*p) && (*p) <= 57 ) goto st178; goto st0; tr255: -#line 244 "src/memcached-grammar.rl" +#line 245 "src/memcached-grammar.rl" {flags = natoq(fstart, p);} goto st179; st179: if ( ++p == pe ) goto _test_eof179; case 179: -#line 3246 "src/memcached-grammar.cc" +#line 3249 "src/memcached-grammar.cc" if ( (*p) == 32 ) goto st179; if ( 48 <= (*p) && (*p) <= 57 ) goto tr258; goto st0; tr258: -#line 221 "src/memcached-grammar.rl" +#line 222 "src/memcached-grammar.rl" { fstart = p; } goto st180; st180: if ( ++p == pe ) goto _test_eof180; case 180: -#line 3260 "src/memcached-grammar.cc" +#line 3263 "src/memcached-grammar.cc" if ( (*p) == 32 ) goto tr259; if ( 48 <= (*p) && (*p) <= 57 ) goto st180; goto st0; tr259: -#line 237 "src/memcached-grammar.rl" +#line 238 "src/memcached-grammar.rl" { exptime = natoq(fstart, p); if (exptime > 0 && exptime <= 60*60*24*30) @@ -3274,21 +3277,21 @@ case 180: if ( ++p == pe ) goto _test_eof181; case 181: -#line 3278 "src/memcached-grammar.cc" +#line 3281 "src/memcached-grammar.cc" if ( (*p) == 32 ) goto st181; if ( 48 <= (*p) && (*p) <= 57 ) goto tr262; goto st0; tr262: -#line 221 "src/memcached-grammar.rl" +#line 222 "src/memcached-grammar.rl" { fstart = p; } goto st182; st182: if ( ++p == pe ) goto _test_eof182; case 182: -#line 3292 "src/memcached-grammar.cc" +#line 3295 "src/memcached-grammar.cc" switch( (*p) ) { case 10: goto tr263; case 13: goto tr264; @@ -3298,30 +3301,30 @@ case 182: goto st182; goto st0; tr264: -#line 245 "src/memcached-grammar.rl" +#line 246 "src/memcached-grammar.rl" {bytes = natoq(fstart, p);} goto st183; tr277: -#line 281 "src/memcached-grammar.rl" +#line 282 "src/memcached-grammar.rl" { noreply = true; } goto st183; st183: if ( ++p == pe ) goto _test_eof183; case 183: -#line 3313 "src/memcached-grammar.cc" +#line 3316 "src/memcached-grammar.cc" if ( (*p) == 10 ) goto tr267; goto st0; tr265: -#line 245 "src/memcached-grammar.rl" +#line 246 "src/memcached-grammar.rl" {bytes = natoq(fstart, p);} goto st184; st184: if ( ++p == pe ) goto _test_eof184; case 184: -#line 3325 "src/memcached-grammar.cc" +#line 3328 "src/memcached-grammar.cc" switch( (*p) ) { case 32: goto st184; case 78: goto st185; @@ -3636,7 +3639,7 @@ case 196: _out: {} } -#line 306 "src/memcached-grammar.rl" +#line 307 "src/memcached-grammar.rl" if (!done) { diff --git a/src/memcached-grammar.rl b/src/memcached-grammar.rl index d015f8a85ff5ad2eb018755ba2644c5f5ef99181..2ecd2804826673dc658a3342924512df5d5c2c8a 100644 --- a/src/memcached-grammar.rl +++ b/src/memcached-grammar.rl @@ -39,7 +39,7 @@ memcached_dispatch(struct ev_io *coio, struct iobuf *iobuf) char *p, *pe; char *fstart; struct tbuf *keys = tbuf_new(fiber->gc_pool); - const void *key; + const char *key; bool append, show_cas; int incr_sign; u64 cas, incr; @@ -96,7 +96,7 @@ memcached_dispatch(struct ev_io *coio, struct iobuf *iobuf) action append_prepend { struct tbuf *b; - const void *value; + const char *value; u32 value_len; key = tbuf_read_field(keys); @@ -124,7 +124,7 @@ memcached_dispatch(struct ev_io *coio, struct iobuf *iobuf) action incr_decr { struct meta *m; struct tbuf *b; - const void *field; + const char *field; u32 value_len; u64 value; @@ -183,7 +183,7 @@ memcached_dispatch(struct ev_io *coio, struct iobuf *iobuf) obuf_dup(out, "NOT_FOUND\r\n", 11); } else { try { - remove(key); + memcached_delete(key); obuf_dup(out, "DELETED\r\n", 9); } catch (const ClientError& e) { diff --git a/src/memcached.cc b/src/memcached.cc index 39d66a745a1256471817ad8e2ea5f0e228c9a7e4..bf70358349280bb2cd8c6091b3954a033930ad46 100644 --- a/src/memcached.cc +++ b/src/memcached.cc @@ -84,18 +84,18 @@ natoq(const char *start, const char *end) } void -tbuf_append_field(struct tbuf *b, const void *f) +tbuf_append_field(struct tbuf *b, const char *f) { - const void *begin = f; + const char *begin = f; u32 size = load_varint32(&f); - tbuf_append(b, begin, (const char *) f - (const char *) begin + size); + tbuf_append(b, begin, f - begin + size); } void -tbuf_store_field(struct tbuf *b, const void *field, u32 len) +tbuf_store_field(struct tbuf *b, const char *field, u32 len) { char buf[sizeof(u32)+1]; - char *bufend = (char *) pack_varint32(buf, len); + char *bufend = pack_varint32(buf, len); tbuf_append(b, buf, bufend - buf); tbuf_append(b, field, len); } @@ -104,22 +104,22 @@ tbuf_store_field(struct tbuf *b, const void *field, u32 len) * Check that we have a valid field and return it. * Advances the buffer to point after the field as a side effect. */ -const void * +const char * tbuf_read_field(struct tbuf *buf) { - const void *field = buf->data; - u32 field_len = pick_varint32((const void **) &buf->data, + const char *field = buf->data; + u32 field_len = pick_varint32((const char **) &buf->data, buf->data + buf->size); - if ((char *) buf->data + field_len > (char *) field + buf->size) + if (buf->data + field_len > field + buf->size) tnt_raise(IllegalParams, "packet too short (expected a field)"); buf->data += field_len; - buf->size -= (const char *) buf->data - (const char *) field; - buf->capacity -= (const char *) buf->data - (const char *) field; + buf->size -= buf->data - field; + buf->capacity -= buf->data - field; return field; } static void -store(const void *key, u32 exptime, u32 flags, u32 bytes, const char *data) +store(const char *key, u32 exptime, u32 flags, u32 bytes, const char *data) { u32 box_flags = 0; u32 field_count = 4; @@ -137,7 +137,7 @@ store(const void *key, u32 exptime, u32 flags, u32 bytes, const char *data) m.exptime = exptime; m.flags = flags; m.cas = cas++; - tbuf_store_field(req, &m, sizeof(m)); + tbuf_store_field(req, (const char *) &m, sizeof(m)); char b[43]; sprintf(b, " %" PRIu32 " %" PRIu32 "\r\n", flags, bytes); @@ -156,7 +156,7 @@ store(const void *key, u32 exptime, u32 flags, u32 bytes, const char *data) } static void -remove(const void *key) +memcached_delete(const char *key) { u32 key_len = 1; u32 box_flags = 0; @@ -171,7 +171,7 @@ remove(const void *key) } static struct tuple * -find(const void *key) +find(const char *key) { return memcached_index->findByKey(key, 1); } @@ -179,8 +179,8 @@ find(const void *key) static struct meta * meta(struct tuple *tuple) { - void *field = tuple_field(tuple, 1); - return (struct meta *) ((char *) field + 1); + const char *field = tuple_field(tuple, 1); + return (struct meta *) (field + 1); } static bool @@ -191,10 +191,10 @@ expired(struct tuple *tuple) } static bool -is_numeric(const void *field, u32 value_len) +is_numeric(const char *field, u32 value_len) { for (int i = 0; i < value_len; i++) - if (*((u8 *)field + i) < '0' || '9' < *((u8 *)field + i)) + if (*(field + i) < '0' || '9' < *(field + i)) return false; return true; } @@ -269,15 +269,15 @@ void memcached_get(struct obuf *out, size_t keys_count, struct tbuf *keys, while (keys_count-- > 0) { struct tuple *tuple; const struct meta *m; - const void *field; - const void *value; - const void *suffix; + const char *field; + const char *value; + const char *suffix; u32 key_len; u32 value_len; u32 suffix_len; u32 _l; - const void *key = tbuf_read_field(keys); + const char *key = tbuf_read_field(keys); tuple = find(key); key_len = load_varint32(&key); @@ -291,17 +291,17 @@ void memcached_get(struct obuf *out, size_t keys_count, struct tbuf *keys, /* skip key */ _l = load_varint32(&field); - field = (const char *) field + _l; + field = field + _l; /* metainfo */ _l = load_varint32(&field); m = (const struct meta *) field; - field = (const char *) field + _l; + field = field + _l; /* suffix */ suffix_len = load_varint32(&field); suffix = field; - field = (const char *) field + suffix_len; + field = field + suffix_len; /* value */ value_len = load_varint32(&field); @@ -538,7 +538,7 @@ memcached_delete_expired_keys(struct tbuf *keys_to_delete) while (keys_to_delete->size > 0) { try { - remove(tbuf_read_field(keys_to_delete)); + memcached_delete(tbuf_read_field(keys_to_delete)); expired_keys++; } catch (const ClientError& e) { diff --git a/src/recovery.cc b/src/recovery.cc index 3f684ee966a87cd34f6f3d6d05a5b4f5a757e6e7..ae63cf09451121be4d42d57098a905eb55c341f3 100644 --- a/src/recovery.cc +++ b/src/recovery.cc @@ -1104,7 +1104,7 @@ wal_writer_thread(void *worker_args) */ int wal_write(struct recovery_state *r, i64 lsn, u64 cookie, - u16 op, const void *row, u32 row_len) + u16 op, const char *row, u32 row_len) { say_debug("wal_write lsn=%" PRIi64, lsn); ERROR_INJECT_RETURN(ERRINJ_WAL_IO); @@ -1120,8 +1120,8 @@ wal_write(struct recovery_state *r, i64 lsn, u64 cookie, req->fiber = fiber; req->res = -1; - row_v11_fill(&req->row, lsn, XLOG, cookie, &op, sizeof(op), - row, row_len); + row_v11_fill(&req->row, lsn, XLOG, cookie, (const char *) &op, + sizeof(op), row, row_len); (void) tt_pthread_mutex_lock(&writer->mutex); @@ -1155,8 +1155,8 @@ snap_write_batch(struct fio_batch *batch, int fd) void snapshot_write_row(struct log_io *l, struct fio_batch *batch, - const void *metadata, size_t metadata_len, - const void *data, size_t data_len) + const char *metadata, size_t metadata_len, + const char *data, size_t data_len) { static int rows; static int bytes; diff --git a/src/replication.cc b/src/replication.cc index 50241c361bc3690c0f2afe71f1239fec76ed2e7c..f57a1eb86f6e43d1ddc98c6195439ee8695fa6da 100644 --- a/src/replication.cc +++ b/src/replication.cc @@ -559,7 +559,7 @@ static int replication_relay_send_row(void *param, struct tbuf *t) { int client_sock = (int) (intptr_t) param; - u8 *data = (u8 *) t->data; + const char *data = t->data; ssize_t bytes, len = t->size; while (len > 0) { bytes = write(client_sock, data, len); diff --git a/src/tbuf.c b/src/tbuf.c index 28f6a65dbad030c94a787d0651ae9c0f9860bd41..605b3cf44ab4dec662d560468a92857ed3158c0c 100644 --- a/src/tbuf.c +++ b/src/tbuf.c @@ -81,12 +81,12 @@ tbuf_ensure_resize(struct tbuf *e, size_t required) while (new_capacity < e->size + required) new_capacity *= 2; - void *p = palloc(e->pool, new_capacity); + char *p = (char *) palloc(e->pool, new_capacity); poison(p, new_capacity); memcpy(p, e->data, e->size); poison(e->data, e->size); - e->data = (char *) p; + e->data = p; e->capacity = new_capacity; tbuf_assert(e); } @@ -109,7 +109,7 @@ tbuf_split(struct tbuf *orig, size_t at) head->pool = orig->pool; head->data = orig->data; head->size = head->capacity = at; - orig->data = (char *) orig->data + at; + orig->data += at; orig->capacity -= at; orig->size -= at; return head; @@ -121,7 +121,7 @@ tbuf_peek(struct tbuf *b, size_t count) void *p = b->data; tbuf_assert(b); if (count <= b->size) { - b->data = (char *) b->data + count; + b->data += count; b->size -= count; b->capacity -= count; return p; @@ -159,7 +159,7 @@ tbuf_vprintf(struct tbuf *b, const char *format, va_list ap) va_copy(ap_copy, ap); tbuf_assert(b); - printed_len = vsnprintf(((char *)b->data) + b->size, free_len, format, ap); + printed_len = vsnprintf(b->data + b->size, free_len, format, ap); /* * if buffer too short, resize buffer and @@ -168,7 +168,7 @@ tbuf_vprintf(struct tbuf *b, const char *format, va_list ap) if (free_len <= printed_len) { tbuf_ensure(b, printed_len + 1); free_len = b->capacity - b->size - 1; - printed_len = vsnprintf(((char *)b->data) + b->size, free_len, format, ap_copy); + printed_len = vsnprintf(b->data + b->size, free_len, format, ap_copy); } b->size += printed_len;