Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+17 -12
+17 -12
include/linux/ceph/decode.h
··· 52 52 return end >= *p && n <= end - *p; 53 53 } 54 54 55 - #define ceph_decode_need(p, end, n, bad) \ 56 - do { \ 57 - if (!likely(ceph_has_room(p, end, n))) \ 58 - goto bad; \ 55 + #define ceph_decode_need(p, end, n, bad) \ 56 + do { \ 57 + if (!likely(ceph_has_room(p, end, n))) \ 58 + goto bad; \ 59 59 } while (0) 60 60 61 61 #define ceph_decode_64_safe(p, end, v, bad) \ ··· 99 99 * 100 100 * There are two possible failures: 101 101 * - converting the string would require accessing memory at or 102 - * beyond the "end" pointer provided (-E 103 - * - memory could not be allocated for the result 102 + * beyond the "end" pointer provided (-ERANGE) 103 + * - memory could not be allocated for the result (-ENOMEM) 104 104 */ 105 105 static inline char *ceph_extract_encoded_string(void **p, void *end, 106 106 size_t *lenp, gfp_t gfp) ··· 217 217 *p += len; 218 218 } 219 219 220 - #define ceph_encode_need(p, end, n, bad) \ 221 - do { \ 222 - if (!likely(ceph_has_room(p, end, n))) \ 223 - goto bad; \ 220 + #define ceph_encode_need(p, end, n, bad) \ 221 + do { \ 222 + if (!likely(ceph_has_room(p, end, n))) \ 223 + goto bad; \ 224 224 } while (0) 225 225 226 226 #define ceph_encode_64_safe(p, end, v, bad) \ ··· 231 231 #define ceph_encode_32_safe(p, end, v, bad) \ 232 232 do { \ 233 233 ceph_encode_need(p, end, sizeof(u32), bad); \ 234 - ceph_encode_32(p, v); \ 234 + ceph_encode_32(p, v); \ 235 235 } while (0) 236 236 #define ceph_encode_16_safe(p, end, v, bad) \ 237 237 do { \ 238 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 245 } while (0) 241 246 242 247 #define ceph_encode_copy_safe(p, end, pv, n, bad) \