Skip to content

Commit

Permalink
follow style guide for compose/parse rstatus enum (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevyang authored Jul 29, 2018
1 parent bcd1f4d commit 53c7a87
Show file tree
Hide file tree
Showing 23 changed files with 98 additions and 99 deletions.
2 changes: 1 addition & 1 deletion src/core/admin/admin.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ _admin_read(struct buf_sock *s)
static void
_admin_post_read(struct buf_sock *s)
{
parse_rstatus_t status;
parse_rstatus_e status;

admin_request_reset(&req);

Expand Down
2 changes: 1 addition & 1 deletion src/protocol/admin/compose.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static struct bstring rsp_strings[] = {
};
#undef GET_STRING

static inline compose_rstatus_t
static inline compose_rstatus_e
_check_buf_size(struct buf **buf, uint32_t n)
{
while (n > buf_wsize(*buf)) {
Expand Down
2 changes: 1 addition & 1 deletion src/protocol/admin/compose.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ typedef enum compose_rstatus {
COMPOSE_OK = 0,
COMPOSE_ENOMEM = -1,
COMPOSE_EOVERSIZED = -2,
} compose_rstatus_t;
} compose_rstatus_e;

struct buf;
struct request;
Expand Down
4 changes: 2 additions & 2 deletions src/protocol/admin/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ _is_crlf(struct buf *buf, char *p)
return false;
}

static inline parse_rstatus_t
static inline parse_rstatus_e
_get_req_type(struct request *req, struct bstring *type)
{
ASSERT(req->type == REQ_UNKNOWN);
Expand Down Expand Up @@ -60,7 +60,7 @@ _get_req_type(struct request *req, struct bstring *type)
return PARSE_OK;
}

parse_rstatus_t
parse_rstatus_e
admin_parse_req(struct request *req, struct buf *buf)
{
char *p, *q;
Expand Down
4 changes: 2 additions & 2 deletions src/protocol/admin/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ typedef enum parse_rstatus {
PARSE_EUNFIN = -1,
PARSE_EINVALID = -2,
PARSE_EOTHER = -3,
} parse_rstatus_t;
} parse_rstatus_e;

struct buf;
struct request;

parse_rstatus_t admin_parse_req(struct request *req, struct buf *buf);
parse_rstatus_e admin_parse_req(struct request *req, struct buf *buf);
2 changes: 1 addition & 1 deletion src/protocol/data/memcache/compose.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ compose_teardown(void)
* common functions
*/

static inline compose_rstatus_t
static inline compose_rstatus_e
_check_buf_size(struct buf **buf, uint32_t n)
{
while (n > buf_wsize(*buf)) {
Expand Down
2 changes: 1 addition & 1 deletion src/protocol/data/memcache/compose.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ typedef enum compose_rstatus {
COMPOSE_ENOMEM = -2,
COMPOSE_EINVALID = -3,
COMPOSE_EOTHER = -4,
} compose_rstatus_t;
} compose_rstatus_e;

struct request;
struct response;
Expand Down
86 changes: 43 additions & 43 deletions src/protocol/data/memcache/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ parse_teardown(void)
* common functions
*/
/* CRLF is special and we need to "peek into the future" */
static inline parse_rstatus_t
static inline parse_rstatus_e
_try_crlf(struct buf *buf, char *p)
{
if (*p != CR) {
Expand Down Expand Up @@ -80,7 +80,7 @@ _token_begin(struct bstring *t, char *p)
static inline bool
_token_end(bool *end, struct buf *buf, char *p)
{
parse_rstatus_t status;
parse_rstatus_e status;

status = _try_crlf(buf, p);
if (status == PARSE_OK) {
Expand Down Expand Up @@ -109,11 +109,11 @@ _token_oversize(struct buf *buf, char *p)
}


static parse_rstatus_t
static parse_rstatus_e
_chase_crlf(struct buf *buf)
{
char *p;
parse_rstatus_t status;
parse_rstatus_e status;

for (p = buf->rpos; p < buf->wpos; p++) {
if (_token_oversize(buf, p)) {
Expand Down Expand Up @@ -151,7 +151,7 @@ _chase_crlf(struct buf *buf)
return PARSE_EUNFIN;
}

static inline parse_rstatus_t
static inline parse_rstatus_e
_check_key(struct buf *buf, bool *end, struct bstring *t, char *p)
{
bool complete;
Expand Down Expand Up @@ -181,11 +181,11 @@ _check_key(struct buf *buf, bool *end, struct bstring *t, char *p)
return PARSE_EUNFIN;
}

static parse_rstatus_t
static parse_rstatus_e
_chase_key(struct buf *buf, bool *end, struct bstring *t)
{
char *p;
parse_rstatus_t status;
parse_rstatus_e status;

for (p = buf->rpos; p < buf->wpos; p++) {
if (_token_oversize(buf, p)) {
Expand All @@ -201,7 +201,7 @@ _chase_key(struct buf *buf, bool *end, struct bstring *t)
return PARSE_EUNFIN;
}

static inline parse_rstatus_t
static inline parse_rstatus_e
_check_uint(uint64_t *num, struct buf *buf, bool *end, size_t *len,
char *p, uint64_t max)
{
Expand Down Expand Up @@ -250,11 +250,11 @@ _check_uint(uint64_t *num, struct buf *buf, bool *end, size_t *len,
return PARSE_EUNFIN;
}

static parse_rstatus_t
static parse_rstatus_e
_chase_uint(uint64_t *num, struct buf *buf, bool *end, uint64_t max)
{
char *p;
parse_rstatus_t status;
parse_rstatus_e status;
size_t len = 0;

*num = 0;
Expand All @@ -272,10 +272,10 @@ _chase_uint(uint64_t *num, struct buf *buf, bool *end, uint64_t max)
return PARSE_EUNFIN;
}

static parse_rstatus_t
static parse_rstatus_e
_parse_val(struct bstring *val, struct buf *buf, uint32_t nbyte)
{
parse_rstatus_t status;
parse_rstatus_e status;
uint32_t rsize = buf_rsize(buf);

log_verb("parsing val (string) at %p", buf->rpos);
Expand Down Expand Up @@ -307,7 +307,7 @@ _parse_val(struct bstring *val, struct buf *buf, uint32_t nbyte)
* request specific functions
*/

static inline parse_rstatus_t
static inline parse_rstatus_e
_check_req_type(struct request *req, struct buf *buf, bool *end, struct bstring *t,
char *p)
{
Expand Down Expand Up @@ -430,11 +430,11 @@ _check_req_type(struct request *req, struct buf *buf, bool *end, struct bstring
return PARSE_EUNFIN;
}

static parse_rstatus_t
static parse_rstatus_e
_chase_req_type(struct request *req, struct buf *buf, bool *end)
{
char *p;
parse_rstatus_t status;
parse_rstatus_e status;
struct bstring t;

bstring_init(&t);
Expand All @@ -452,7 +452,7 @@ _chase_req_type(struct request *req, struct buf *buf, bool *end)
return PARSE_EUNFIN;
}

static inline parse_rstatus_t
static inline parse_rstatus_e
_push_key(struct request *req, struct bstring *t)
{
struct bstring *k;
Expand All @@ -471,7 +471,7 @@ _push_key(struct request *req, struct bstring *t)
}


static inline parse_rstatus_t
static inline parse_rstatus_e
_check_noreply(struct buf *buf, bool *end, struct bstring *t, char *p)
{
bool complete;
Expand Down Expand Up @@ -505,7 +505,7 @@ _check_noreply(struct buf *buf, bool *end, struct bstring *t, char *p)
return PARSE_EUNFIN;
}

static parse_rstatus_t
static parse_rstatus_e
_chase_noreply(struct request *req, struct buf *buf, bool *end)
{
char *p;
Expand Down Expand Up @@ -538,10 +538,10 @@ _chase_noreply(struct request *req, struct buf *buf, bool *end)
}


static parse_rstatus_t
static parse_rstatus_e
_subrequest_delete(struct request *req, struct buf *buf, bool *end)
{
parse_rstatus_t status;
parse_rstatus_e status;
struct bstring t;

/* parsing order:
Expand All @@ -562,10 +562,10 @@ _subrequest_delete(struct request *req, struct buf *buf, bool *end)
return _chase_noreply(req, buf, end);
}

static parse_rstatus_t
static parse_rstatus_e
_subrequest_arithmetic(struct request *req, struct buf *buf, bool *end)
{
parse_rstatus_t status;
parse_rstatus_e status;
uint64_t delta;
struct bstring t;

Expand Down Expand Up @@ -606,10 +606,10 @@ _subrequest_arithmetic(struct request *req, struct buf *buf, bool *end)
}


static parse_rstatus_t
static parse_rstatus_e
_subrequest_store(struct request *req, struct buf *buf, bool *end, bool cas)
{
parse_rstatus_t status;
parse_rstatus_e status;
uint64_t n;
struct bstring t;

Expand Down Expand Up @@ -687,10 +687,10 @@ _subrequest_store(struct request *req, struct buf *buf, bool *end, bool cas)
}


static parse_rstatus_t
static parse_rstatus_e
_subrequest_retrieve(struct request *req, struct buf *buf, bool *end)
{
parse_rstatus_t status;
parse_rstatus_e status;
struct bstring t;

while (true) {
Expand All @@ -717,10 +717,10 @@ _subrequest_retrieve(struct request *req, struct buf *buf, bool *end)
}

/* parse the first line("header") according to memcache ASCII protocol */
static parse_rstatus_t
static parse_rstatus_e
_parse_req_hdr(struct request *req, struct buf *buf)
{
parse_rstatus_t status;
parse_rstatus_e status;
bool end = false;

ASSERT(req != NULL);
Expand Down Expand Up @@ -784,10 +784,10 @@ _parse_req_hdr(struct request *req, struct buf *buf)
return status;
}

parse_rstatus_t
parse_rstatus_e
parse_req(struct request *req, struct buf *buf)
{
parse_rstatus_t status = PARSE_OK;
parse_rstatus_e status = PARSE_OK;
char *old_rpos = buf->rpos;
bool leftmost = (buf->rpos == buf->begin);

Expand Down Expand Up @@ -888,7 +888,7 @@ parse_req(struct request *req, struct buf *buf)
* response specific functions
*/

static inline parse_rstatus_t
static inline parse_rstatus_e
_check_rsp_type(struct response *rsp, struct buf *buf, bool *end, struct bstring *t,
char *p)
{
Expand Down Expand Up @@ -1008,11 +1008,11 @@ _check_rsp_type(struct response *rsp, struct buf *buf, bool *end, struct bstring
}


static parse_rstatus_t
static parse_rstatus_e
_chase_rsp_type(struct response *rsp, struct buf *buf, bool *end)
{
char *p;
parse_rstatus_t status;
parse_rstatus_e status;
uint64_t n = 0;
struct bstring t;

Expand Down Expand Up @@ -1045,10 +1045,10 @@ _chase_rsp_type(struct response *rsp, struct buf *buf, bool *end)
return PARSE_EUNFIN;
}

static parse_rstatus_t
static parse_rstatus_e
_subresponse_stat(struct response *rsp, struct buf *buf, bool *end)
{
parse_rstatus_t status;
parse_rstatus_e status;
uint64_t n;
struct bstring t;

Expand Down Expand Up @@ -1078,10 +1078,10 @@ _subresponse_stat(struct response *rsp, struct buf *buf, bool *end)
return status;
}

static parse_rstatus_t
static parse_rstatus_e
_subresponse_value(struct response *rsp, struct buf *buf, bool *end)
{
parse_rstatus_t status;
parse_rstatus_e status;
uint64_t n;
struct bstring t;

Expand Down Expand Up @@ -1134,10 +1134,10 @@ _subresponse_value(struct response *rsp, struct buf *buf, bool *end)
return PARSE_EOTHER;
}

static parse_rstatus_t
static parse_rstatus_e
_subresponse_error(struct response *rsp, struct buf *buf, bool *end)
{
parse_rstatus_t status;
parse_rstatus_e status;
char *p;
struct bstring t;

Expand Down Expand Up @@ -1181,10 +1181,10 @@ _subresponse_error(struct response *rsp, struct buf *buf, bool *end)
}


static parse_rstatus_t
static parse_rstatus_e
_parse_rsp_hdr(struct response *rsp, struct buf *buf)
{
parse_rstatus_t status;
parse_rstatus_e status;
bool end = false;

ASSERT(rsp != NULL);
Expand Down Expand Up @@ -1244,10 +1244,10 @@ _parse_rsp_hdr(struct response *rsp, struct buf *buf)
return status;
}

parse_rstatus_t
parse_rstatus_e
parse_rsp(struct response *rsp, struct buf *buf)
{
parse_rstatus_t status = PARSE_EUNFIN;
parse_rstatus_e status = PARSE_EUNFIN;
char *old_rpos = buf->rpos;

ASSERT(rsp->rstate == RSP_PARSING);
Expand Down
6 changes: 3 additions & 3 deletions src/protocol/data/memcache/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ typedef enum parse_rstatus {
PARSE_EOVERSIZE = -3,
PARSE_EINVALID = -4,
PARSE_EOTHER = -5,
} parse_rstatus_t;
} parse_rstatus_e;

struct request;
struct response;

void parse_setup(parse_req_metrics_st *req, parse_rsp_metrics_st *rsp);
void parse_teardown(void);

parse_rstatus_t parse_req(struct request *req, struct buf *buf);
parse_rstatus_e parse_req(struct request *req, struct buf *buf);

parse_rstatus_t parse_rsp(struct response *rsp, struct buf *buf);
parse_rstatus_e parse_rsp(struct response *rsp, struct buf *buf);
Loading

0 comments on commit 53c7a87

Please sign in to comment.