diff mbox

[1/2] libceph: add signed type limits

Message ID 517456CA.7040408@inktank.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alex Elder April 21, 2013, 9:14 p.m. UTC
(Sorry, the subject line didn't match the content.
Please ignore the previous one--this is the right
patch.)


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>
---
 include/linux/ceph/decode.h |   18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

Comments

Josh Durgin April 22, 2013, 10:55 p.m. UTC | #1
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>

On 04/21/2013 02:14 PM, Alex Elder wrote:
> (Sorry, the subject line didn't match the content.
> Please ignore the previous one--this is the right
> patch.)
>
>
> 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>
> ---
>   include/linux/ceph/decode.h |   18 ++++++++++++++----
>   1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/ceph/decode.h b/include/linux/ceph/decode.h
> index 689f1df..9575a52 100644
> --- a/include/linux/ceph/decode.h
> +++ b/include/linux/ceph/decode.h
> @@ -10,10 +10,20 @@
>
>   /* This seemed to be the easiest place to define these */
>
> -#define	U8_MAX	((u8)  (~0U))
> -#define	U16_MAX	((u16) (~0U))
> -#define	U32_MAX	((u32) (~0U))
> -#define	U64_MAX	((u64) (~0ULL))
> +#define	U8_MAX	((u8)(~0U))
> +#define	U16_MAX	((u16)(~0U))
> +#define	U32_MAX	((u32)(~0U))
> +#define	U64_MAX	((u64)(~0ULL))
> +
> +#define	S8_MAX	((s8)(U8_MAX >> 1))
> +#define	S16_MAX	((s16)(U16_MAX >> 1))
> +#define	S32_MAX	((s32)(U32_MAX >> 1))
> +#define	S64_MAX	((s64)(U64_MAX >> 1LL))
> +
> +#define	S8_MIN	((s8)(-S8_MAX - 1))
> +#define	S16_MIN	((s16)(-S16_MAX - 1))
> +#define	S32_MIN	((s32)(-S32_MAX - 1))
> +#define	S64_MIN	((s64)(-S64_MAX - 1LL))
>
>   /*
>    * in all cases,
>

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/linux/ceph/decode.h b/include/linux/ceph/decode.h
index 689f1df..9575a52 100644
--- a/include/linux/ceph/decode.h
+++ b/include/linux/ceph/decode.h
@@ -10,10 +10,20 @@ 

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

-#define	U8_MAX	((u8)  (~0U))
-#define	U16_MAX	((u16) (~0U))
-#define	U32_MAX	((u32) (~0U))
-#define	U64_MAX	((u64) (~0ULL))
+#define	U8_MAX	((u8)(~0U))
+#define	U16_MAX	((u16)(~0U))
+#define	U32_MAX	((u32)(~0U))
+#define	U64_MAX	((u64)(~0ULL))
+
+#define	S8_MAX	((s8)(U8_MAX >> 1))
+#define	S16_MAX	((s16)(U16_MAX >> 1))
+#define	S32_MAX	((s32)(U32_MAX >> 1))
+#define	S64_MAX	((s64)(U64_MAX >> 1LL))
+
+#define	S8_MIN	((s8)(-S8_MAX - 1))
+#define	S16_MIN	((s16)(-S16_MAX - 1))
+#define	S32_MIN	((s32)(-S32_MAX - 1))
+#define	S64_MIN	((s64)(-S64_MAX - 1LL))

 /*
  * in all cases,