diff --git a/src/box/iproto_constants.c b/src/box/iproto_constants.c index 7a468e6b3241832aa3a2c1bcdbfd60f531a39db8..86391b06a75e0c855a9ae87f9849ed3d774ad54b 100644 --- a/src/box/iproto_constants.c +++ b/src/box/iproto_constants.c @@ -30,7 +30,7 @@ */ #include "iproto_constants.h" -const unsigned char iproto_key_type[IPROTO_KEY_MAX] = +const unsigned char iproto_key_type[iproto_key_MAX] = { /* {{{ header */ /* 0x00 */ MP_UINT, /* IPROTO_REQUEST_TYPE */ @@ -198,7 +198,7 @@ const uint64_t iproto_body_key_map[IPROTO_TYPE_STAT_MAX] = { }; #undef bit -const char *iproto_key_strs[IPROTO_KEY_MAX] = { +const char *iproto_key_strs[iproto_key_MAX] = { "type", /* 0x00 */ "sync", /* 0x01 */ "replica id", /* 0x02 */ diff --git a/src/box/iproto_constants.h b/src/box/iproto_constants.h index 7948c42a08a010b539dc776c588df5540313a363..aca2cf0492275f717ae88765f6056e0216d74501 100644 --- a/src/box/iproto_constants.h +++ b/src/box/iproto_constants.h @@ -185,7 +185,7 @@ enum iproto_key { * 0x7f, and we rely on this in some places by allocating a uint8_t to * hold a msgpack-encoded key value. */ - IPROTO_KEY_MAX + iproto_key_MAX }; /** @@ -224,7 +224,7 @@ iproto_key_bit(unsigned char key) return 1ULL << key; } -extern const unsigned char iproto_key_type[IPROTO_KEY_MAX]; +extern const unsigned char iproto_key_type[iproto_key_MAX]; /** * IPROTO command codes. @@ -427,7 +427,7 @@ static inline const char * iproto_key_name(enum iproto_key key) { extern const char *iproto_key_strs[]; - if (key >= IPROTO_KEY_MAX) + if (key >= iproto_key_MAX) return NULL; return iproto_key_strs[key]; } diff --git a/src/box/xrow.c b/src/box/xrow.c index 72ed0418f16516ed110da90bc3cc4ae51e700caa..586c1ad831585aeb97547c9b0537fa90a0c510e6 100644 --- a/src/box/xrow.c +++ b/src/box/xrow.c @@ -163,7 +163,7 @@ xrow_header_decode(struct xrow_header *header, const char **pos, if (mp_typeof(**pos) != MP_UINT) goto bad_header; uint64_t key = mp_decode_uint(pos); - if (key >= IPROTO_KEY_MAX || + if (key >= iproto_key_MAX || iproto_key_type[key] != mp_typeof(**pos)) goto bad_header; switch (key) { @@ -906,7 +906,7 @@ xrow_decode_dml(struct xrow_header *row, struct request *request, uint64_t key = mp_decode_uint(&data); const char *value = data; mp_next(&data); - if (key >= IPROTO_KEY_MAX || + if (key >= iproto_key_MAX || iproto_key_type[key] != mp_typeof(*value)) goto error; key_map &= ~iproto_key_bit(key); @@ -1144,7 +1144,7 @@ xrow_decode_id(const struct xrow_header *row, struct id_request *request) if (mp_typeof(*p) != MP_UINT) goto error; uint64_t key = mp_decode_uint(&p); - if (key >= IPROTO_KEY_MAX || + if (key >= iproto_key_MAX || iproto_key_type[key] != mp_typeof(*p)) goto error; switch (key) { @@ -1252,7 +1252,7 @@ xrow_decode_synchro(const struct xrow_header *row, struct synchro_request *req) continue; } uint8_t key = mp_decode_uint(&d); - if (key >= IPROTO_KEY_MAX || iproto_key_type[key] != type) { + if (key >= iproto_key_MAX || iproto_key_type[key] != type) { xrow_on_decode_err(row, ER_INVALID_MSGPACK, "request body"); return -1; @@ -1539,7 +1539,7 @@ xrow_decode_watch(const struct xrow_header *row, struct watch_request *request) if (mp_typeof(*data) != MP_UINT) goto error; uint64_t key = mp_decode_uint(&data); - if (key < IPROTO_KEY_MAX && + if (key < iproto_key_MAX && iproto_key_type[key] != MP_NIL && iproto_key_type[key] != mp_typeof(*data)) goto error; @@ -1720,7 +1720,7 @@ xrow_decode_begin(const struct xrow_header *row, struct begin_request *request) if (mp_typeof(*d) != MP_UINT) goto bad_msgpack; uint64_t key = mp_decode_uint(&d); - if (key >= IPROTO_KEY_MAX || + if (key >= iproto_key_MAX || mp_typeof(*d) != iproto_key_type[key]) goto bad_msgpack; switch (key) { diff --git a/test/unit/xrow.cc b/test/unit/xrow.cc index 42ae849d7857fb13b63de044a9eb2afe082880c2..b4f7173c478097cf6843a6c72fd78758cb631366 100644 --- a/test/unit/xrow.cc +++ b/test/unit/xrow.cc @@ -50,7 +50,7 @@ test_iproto_constants() * accessed by an index out of the range * [0, IPROTO_KEY_MAX). */ - for (int i = 0; i < IPROTO_KEY_MAX; ++i) + for (int i = 0; i < iproto_key_MAX; ++i) (void) iproto_key_name((enum iproto_key) i); /* Same for iproto_type. */