diff options
author | Jon Derrick <jonathan.derrick@intel.com> | 2017-02-21 13:59:13 -0500 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2017-02-22 13:54:49 -0500 |
commit | aedb6e2411baf242fd0faf95bd3ff0dc62ee1fa5 (patch) | |
tree | 2f9a2f46bb43de6b6182c22e797817ae5b78dd4d /block/sed-opal.c | |
parent | bd1599d931ca735c1081f11aa4d49006350709f1 (diff) |
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: Jon Derrick <jonathan.derrick@intel.com>
Reviewed-by: Scott Bauer <scott.bauer@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block/sed-opal.c')
-rw-r--r-- | block/sed-opal.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/block/sed-opal.c b/block/sed-opal.c index d1c52ba4d62d..4675fd8eed7b 100644 --- a/block/sed-opal.c +++ b/block/sed-opal.c | |||
@@ -706,8 +706,8 @@ static enum opal_token response_get_token(const struct parsed_resp *resp, | |||
706 | return tok->pos[0]; | 706 | return tok->pos[0]; |
707 | } | 707 | } |
708 | 708 | ||
709 | static size_t response_parse_tiny(struct opal_resp_tok *tok, | 709 | static ssize_t response_parse_tiny(struct opal_resp_tok *tok, |
710 | const u8 *pos) | 710 | const u8 *pos) |
711 | { | 711 | { |
712 | tok->pos = pos; | 712 | tok->pos = pos; |
713 | tok->len = 1; | 713 | tok->len = 1; |
@@ -723,8 +723,8 @@ static size_t response_parse_tiny(struct opal_resp_tok *tok, | |||
723 | return tok->len; | 723 | return tok->len; |
724 | } | 724 | } |
725 | 725 | ||
726 | static size_t response_parse_short(struct opal_resp_tok *tok, | 726 | static ssize_t response_parse_short(struct opal_resp_tok *tok, |
727 | const u8 *pos) | 727 | const u8 *pos) |
728 | { | 728 | { |
729 | tok->pos = pos; | 729 | tok->pos = pos; |
730 | tok->len = (pos[0] & SHORT_ATOM_LEN_MASK) + 1; | 730 | 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 | tok->type = OPAL_DTA_TOKENID_SINT; | 736 | tok->type = OPAL_DTA_TOKENID_SINT; |
737 | } else { | 737 | } else { |
738 | u64 u_integer = 0; | 738 | u64 u_integer = 0; |
739 | int i, b = 0; | 739 | ssize_t i, b = 0; |
740 | 740 | ||
741 | tok->type = OPAL_DTA_TOKENID_UINT; | 741 | tok->type = OPAL_DTA_TOKENID_UINT; |
742 | if (tok->len > 9) { | 742 | if (tok->len > 9) { |
@@ -753,8 +753,8 @@ static size_t response_parse_short(struct opal_resp_tok *tok, | |||
753 | return tok->len; | 753 | return tok->len; |
754 | } | 754 | } |
755 | 755 | ||
756 | static size_t response_parse_medium(struct opal_resp_tok *tok, | 756 | static ssize_t response_parse_medium(struct opal_resp_tok *tok, |
757 | const u8 *pos) | 757 | const u8 *pos) |
758 | { | 758 | { |
759 | tok->pos = pos; | 759 | tok->pos = pos; |
760 | tok->len = (((pos[0] & MEDIUM_ATOM_LEN_MASK) << 8) | pos[1]) + 2; | 760 | 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 | return tok->len; | 770 | return tok->len; |
771 | } | 771 | } |
772 | 772 | ||
773 | static size_t response_parse_long(struct opal_resp_tok *tok, | 773 | static ssize_t response_parse_long(struct opal_resp_tok *tok, |
774 | const u8 *pos) | 774 | const u8 *pos) |
775 | { | 775 | { |
776 | tok->pos = pos; | 776 | tok->pos = pos; |
777 | tok->len = ((pos[1] << 16) | (pos[2] << 8) | pos[3]) + 4; | 777 | 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 | return tok->len; | 787 | return tok->len; |
788 | } | 788 | } |
789 | 789 | ||
790 | static size_t response_parse_token(struct opal_resp_tok *tok, | 790 | static ssize_t response_parse_token(struct opal_resp_tok *tok, |
791 | const u8 *pos) | 791 | const u8 *pos) |
792 | { | 792 | { |
793 | tok->pos = pos; | 793 | tok->pos = pos; |
794 | tok->len = 1; | 794 | tok->len = 1; |
@@ -805,7 +805,7 @@ static int response_parse(const u8 *buf, size_t length, | |||
805 | struct opal_resp_tok *iter; | 805 | struct opal_resp_tok *iter; |
806 | int num_entries = 0; | 806 | int num_entries = 0; |
807 | int total; | 807 | int total; |
808 | size_t token_length; | 808 | ssize_t token_length; |
809 | const u8 *pos; | 809 | const u8 *pos; |
810 | 810 | ||
811 | if (!buf) | 811 | if (!buf) |
@@ -851,8 +851,8 @@ static int response_parse(const u8 *buf, size_t length, | |||
851 | else /* TOKEN */ | 851 | else /* TOKEN */ |
852 | token_length = response_parse_token(iter, pos); | 852 | token_length = response_parse_token(iter, pos); |
853 | 853 | ||
854 | if (token_length == -EINVAL) | 854 | if (token_length < 0) |
855 | return -EINVAL; | 855 | return token_length; |
856 | 856 | ||
857 | pos += token_length; | 857 | pos += token_length; |
858 | total -= token_length; | 858 | total -= token_length; |