提交 aedb6e24 编写于 作者: J Jon Derrick 提交者: Jens Axboe

block/sed: Use ssize_t on atom parsers to return errors

The short atom parser can return an errno from decoding but does not
currently return the error as a signed value. Convert all of the parsers
to ssize_t.
Signed-off-by: NJon Derrick <jonathan.derrick@intel.com>
Reviewed-by: NScott Bauer <scott.bauer@intel.com>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Signed-off-by: NJens Axboe <axboe@fb.com>
上级 bd1599d9
...@@ -706,8 +706,8 @@ static enum opal_token response_get_token(const struct parsed_resp *resp, ...@@ -706,8 +706,8 @@ static enum opal_token response_get_token(const struct parsed_resp *resp,
return tok->pos[0]; return tok->pos[0];
} }
static size_t response_parse_tiny(struct opal_resp_tok *tok, static ssize_t response_parse_tiny(struct opal_resp_tok *tok,
const u8 *pos) const u8 *pos)
{ {
tok->pos = pos; tok->pos = pos;
tok->len = 1; tok->len = 1;
...@@ -723,8 +723,8 @@ static size_t response_parse_tiny(struct opal_resp_tok *tok, ...@@ -723,8 +723,8 @@ static size_t response_parse_tiny(struct opal_resp_tok *tok,
return tok->len; return tok->len;
} }
static size_t response_parse_short(struct opal_resp_tok *tok, static ssize_t response_parse_short(struct opal_resp_tok *tok,
const u8 *pos) const u8 *pos)
{ {
tok->pos = pos; tok->pos = pos;
tok->len = (pos[0] & SHORT_ATOM_LEN_MASK) + 1; tok->len = (pos[0] & SHORT_ATOM_LEN_MASK) + 1;
...@@ -736,7 +736,7 @@ static size_t response_parse_short(struct opal_resp_tok *tok, ...@@ -736,7 +736,7 @@ static size_t response_parse_short(struct opal_resp_tok *tok,
tok->type = OPAL_DTA_TOKENID_SINT; tok->type = OPAL_DTA_TOKENID_SINT;
} else { } else {
u64 u_integer = 0; u64 u_integer = 0;
int i, b = 0; ssize_t i, b = 0;
tok->type = OPAL_DTA_TOKENID_UINT; tok->type = OPAL_DTA_TOKENID_UINT;
if (tok->len > 9) { if (tok->len > 9) {
...@@ -753,8 +753,8 @@ static size_t response_parse_short(struct opal_resp_tok *tok, ...@@ -753,8 +753,8 @@ static size_t response_parse_short(struct opal_resp_tok *tok,
return tok->len; return tok->len;
} }
static size_t response_parse_medium(struct opal_resp_tok *tok, static ssize_t response_parse_medium(struct opal_resp_tok *tok,
const u8 *pos) const u8 *pos)
{ {
tok->pos = pos; tok->pos = pos;
tok->len = (((pos[0] & MEDIUM_ATOM_LEN_MASK) << 8) | pos[1]) + 2; tok->len = (((pos[0] & MEDIUM_ATOM_LEN_MASK) << 8) | pos[1]) + 2;
...@@ -770,8 +770,8 @@ static size_t response_parse_medium(struct opal_resp_tok *tok, ...@@ -770,8 +770,8 @@ static size_t response_parse_medium(struct opal_resp_tok *tok,
return tok->len; return tok->len;
} }
static size_t response_parse_long(struct opal_resp_tok *tok, static ssize_t response_parse_long(struct opal_resp_tok *tok,
const u8 *pos) const u8 *pos)
{ {
tok->pos = pos; tok->pos = pos;
tok->len = ((pos[1] << 16) | (pos[2] << 8) | pos[3]) + 4; tok->len = ((pos[1] << 16) | (pos[2] << 8) | pos[3]) + 4;
...@@ -787,8 +787,8 @@ static size_t response_parse_long(struct opal_resp_tok *tok, ...@@ -787,8 +787,8 @@ static size_t response_parse_long(struct opal_resp_tok *tok,
return tok->len; return tok->len;
} }
static size_t response_parse_token(struct opal_resp_tok *tok, static ssize_t response_parse_token(struct opal_resp_tok *tok,
const u8 *pos) const u8 *pos)
{ {
tok->pos = pos; tok->pos = pos;
tok->len = 1; tok->len = 1;
...@@ -805,7 +805,7 @@ static int response_parse(const u8 *buf, size_t length, ...@@ -805,7 +805,7 @@ static int response_parse(const u8 *buf, size_t length,
struct opal_resp_tok *iter; struct opal_resp_tok *iter;
int num_entries = 0; int num_entries = 0;
int total; int total;
size_t token_length; ssize_t token_length;
const u8 *pos; const u8 *pos;
if (!buf) if (!buf)
...@@ -851,8 +851,8 @@ static int response_parse(const u8 *buf, size_t length, ...@@ -851,8 +851,8 @@ static int response_parse(const u8 *buf, size_t length,
else /* TOKEN */ else /* TOKEN */
token_length = response_parse_token(iter, pos); token_length = response_parse_token(iter, pos);
if (token_length == -EINVAL) if (token_length < 0)
return -EINVAL; return token_length;
pos += token_length; pos += token_length;
total -= token_length; total -= token_length;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册