Skip to content

Commit dd5f049

Browse files
author
Alex Elder
committed
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>
1 parent 4caf35f commit dd5f049

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

‎include/linux/ceph/decode.h‎

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ static inline int ceph_has_room(void **p, void *end, size_t n)
5252
return end >= *p && n <= end - *p;
5353
}
5454

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; \
5959
} while (0)
6060

6161
#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)
9999
*
100100
* There are two possible failures:
101101
* - 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)
104104
*/
105105
static inline char *ceph_extract_encoded_string(void **p, void *end,
106106
size_t *lenp, gfp_t gfp)
@@ -217,10 +217,10 @@ static inline void ceph_encode_string(void **p, void *end,
217217
*p += len;
218218
}
219219

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; \
224224
} while (0)
225225

226226
#define ceph_encode_64_safe(p, end, v, bad) \
@@ -231,12 +231,17 @@ static inline void ceph_encode_string(void **p, void *end,
231231
#define ceph_encode_32_safe(p, end, v, bad) \
232232
do { \
233233
ceph_encode_need(p, end, sizeof(u32), bad); \
234-
ceph_encode_32(p, v); \
234+
ceph_encode_32(p, v); \
235235
} while (0)
236236
#define ceph_encode_16_safe(p, end, v, bad) \
237237
do { \
238238
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); \
240245
} while (0)
241246

242247
#define ceph_encode_copy_safe(p, end, pv, n, bad) \

0 commit comments

Comments
 (0)