Skip to content

Commit b587398

Browse files
Alex ElderSage Weil
authored andcommitted
libceph: add signed type limits
Flesh out the limits defined in <linux/ceph/decode.h> to include the maximum and minimum values for signed type S8, S16, S32, and S64. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
1 parent a9e8ba2 commit b587398

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

‎include/linux/ceph/decode.h‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,20 @@
1010

1111
/* This seemed to be the easiest place to define these */
1212

13-
#define U8_MAX ((u8) (~0U))
14-
#define U16_MAX ((u16) (~0U))
15-
#define U32_MAX ((u32) (~0U))
16-
#define U64_MAX ((u64) (~0ULL))
13+
#define U8_MAX ((u8)(~0U))
14+
#define U16_MAX ((u16)(~0U))
15+
#define U32_MAX ((u32)(~0U))
16+
#define U64_MAX ((u64)(~0ULL))
17+
18+
#define S8_MAX ((s8)(U8_MAX >> 1))
19+
#define S16_MAX ((s16)(U16_MAX >> 1))
20+
#define S32_MAX ((s32)(U32_MAX >> 1))
21+
#define S64_MAX ((s64)(U64_MAX >> 1LL))
22+
23+
#define S8_MIN ((s8)(-S8_MAX - 1))
24+
#define S16_MIN ((s16)(-S16_MAX - 1))
25+
#define S32_MIN ((s32)(-S32_MAX - 1))
26+
#define S64_MIN ((s64)(-S64_MAX - 1LL))
1727

1828
/*
1929
* in all cases,

0 commit comments

Comments
 (0)