diff options
author | Alex Elder <elder@inktank.com> | 2012-11-01 09:39:27 -0400 |
---|---|---|
committer | Alex Elder <elder@inktank.com> | 2013-01-17 15:09:08 -0500 |
commit | dd5f049dbdf973d9bceebef1fd73647a5ede6732 (patch) | |
tree | 6dc55e8e88ac00c7fb1b150269e90bc0c231dfa5 /include/linux/ceph/decode.h | |
parent | 4caf35f9ecdca1feef1d2e5e223b78e52ffbea87 (diff) |
ceph: define ceph_encode_8_safe()
It's kind of a silly macro, but ceph_encode_8_safe() is the only one
missing from an otherwise pretty complete set. It's not used, but
neither are a couple of the others in this set.
While in there, insert some whitespace to tidy up the alignment of
the line-terminating backslashes in some of the macro definitions.
Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Dan Mick <dan.mick@inktank.com>
Diffstat (limited to 'include/linux/ceph/decode.h')
-rw-r--r-- | include/linux/ceph/decode.h | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/include/linux/ceph/decode.h b/include/linux/ceph/decode.h index 4bbf2db45f46..cd679f2d348b 100644 --- a/include/linux/ceph/decode.h +++ b/include/linux/ceph/decode.h | |||
@@ -52,10 +52,10 @@ static inline int ceph_has_room(void **p, void *end, size_t n) | |||
52 | return end >= *p && n <= end - *p; | 52 | return end >= *p && n <= end - *p; |
53 | } | 53 | } |
54 | 54 | ||
55 | #define ceph_decode_need(p, end, n, bad) \ | 55 | #define ceph_decode_need(p, end, n, bad) \ |
56 | do { \ | 56 | do { \ |
57 | if (!likely(ceph_has_room(p, end, n))) \ | 57 | if (!likely(ceph_has_room(p, end, n))) \ |
58 | goto bad; \ | 58 | goto bad; \ |
59 | } while (0) | 59 | } while (0) |
60 | 60 | ||
61 | #define ceph_decode_64_safe(p, end, v, bad) \ | 61 | #define ceph_decode_64_safe(p, end, v, bad) \ |
@@ -99,8 +99,8 @@ static inline int ceph_has_room(void **p, void *end, size_t n) | |||
99 | * | 99 | * |
100 | * There are two possible failures: | 100 | * There are two possible failures: |
101 | * - converting the string would require accessing memory at or | 101 | * - converting the string would require accessing memory at or |
102 | * beyond the "end" pointer provided (-E | 102 | * beyond the "end" pointer provided (-ERANGE) |
103 | * - memory could not be allocated for the result | 103 | * - memory could not be allocated for the result (-ENOMEM) |
104 | */ | 104 | */ |
105 | static inline char *ceph_extract_encoded_string(void **p, void *end, | 105 | static inline char *ceph_extract_encoded_string(void **p, void *end, |
106 | size_t *lenp, gfp_t gfp) | 106 | size_t *lenp, gfp_t gfp) |
@@ -217,10 +217,10 @@ static inline void ceph_encode_string(void **p, void *end, | |||
217 | *p += len; | 217 | *p += len; |
218 | } | 218 | } |
219 | 219 | ||
220 | #define ceph_encode_need(p, end, n, bad) \ | 220 | #define ceph_encode_need(p, end, n, bad) \ |
221 | do { \ | 221 | do { \ |
222 | if (!likely(ceph_has_room(p, end, n))) \ | 222 | if (!likely(ceph_has_room(p, end, n))) \ |
223 | goto bad; \ | 223 | goto bad; \ |
224 | } while (0) | 224 | } while (0) |
225 | 225 | ||
226 | #define ceph_encode_64_safe(p, end, v, bad) \ | 226 | #define ceph_encode_64_safe(p, end, v, bad) \ |
@@ -231,12 +231,17 @@ static inline void ceph_encode_string(void **p, void *end, | |||
231 | #define ceph_encode_32_safe(p, end, v, bad) \ | 231 | #define ceph_encode_32_safe(p, end, v, bad) \ |
232 | do { \ | 232 | do { \ |
233 | ceph_encode_need(p, end, sizeof(u32), bad); \ | 233 | ceph_encode_need(p, end, sizeof(u32), bad); \ |
234 | ceph_encode_32(p, v); \ | 234 | ceph_encode_32(p, v); \ |
235 | } while (0) | 235 | } while (0) |
236 | #define ceph_encode_16_safe(p, end, v, bad) \ | 236 | #define ceph_encode_16_safe(p, end, v, bad) \ |
237 | do { \ | 237 | do { \ |
238 | ceph_encode_need(p, end, sizeof(u16), bad); \ | 238 | ceph_encode_need(p, end, sizeof(u16), bad); \ |
239 | ceph_encode_16(p, v); \ | 239 | ceph_encode_16(p, v); \ |
240 | } while (0) | ||
241 | #define ceph_encode_8_safe(p, end, v, bad) \ | ||
242 | do { \ | ||
243 | ceph_encode_need(p, end, sizeof(u8), bad); \ | ||
244 | ceph_encode_8(p, v); \ | ||
240 | } while (0) | 245 | } while (0) |
241 | 246 | ||
242 | #define ceph_encode_copy_safe(p, end, pv, n, bad) \ | 247 | #define ceph_encode_copy_safe(p, end, pv, n, bad) \ |