summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGurucharan Shetty <gshetty@nicira.com>2016-02-05 17:53:14 -0800
committerJarno Rajahalme <jarno@ovn.org>2016-02-05 17:53:14 -0800
commit8408840fb9a6ddf46693aee7baa3407259ee0f31 (patch)
tree6fedd7a2d9cbb6e98a27bba9efe44de3b908037a
parent000a3ab1bb037474a1d3966f67f5d28ced7cae93 (diff)
downloadopenvswitch-8408840fb9a6ddf46693aee7baa3407259ee0f31.tar.gz
type-props: Avoid a MSVC warning.
Currently, MSVC complains when you have a macro of the form TYPE_MAXIMUM(uint64_t) because a part of macro becomes ~(uint64_t)0 << 64 with a warning: C4293: '<<' : shift count negative or too big, undefined behavior. This commit makes changes to the macro to prevent that warning. Suggested-by: Ben Pfaff <blp@nicira.com> Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Signed-off-by: Jarno Rajahalme <jarno@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
-rw-r--r--lib/type-props.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/type-props.h b/lib/type-props.h
index 8c83ea6fc..3c908a736 100644
--- a/lib/type-props.h
+++ b/lib/type-props.h
@@ -23,10 +23,10 @@
#define TYPE_IS_SIGNED(TYPE) ((TYPE) 1 > (TYPE) -1)
#define TYPE_VALUE_BITS(TYPE) (sizeof(TYPE) * CHAR_BIT - TYPE_IS_SIGNED(TYPE))
#define TYPE_MINIMUM(TYPE) (TYPE_IS_SIGNED(TYPE) \
- ? ~(TYPE)0 << TYPE_VALUE_BITS(TYPE) \
+ ? ~(TYPE)0 << (sizeof(TYPE) * 8 - 1) \
: 0)
#define TYPE_MAXIMUM(TYPE) (TYPE_IS_SIGNED(TYPE) \
- ? ~(~(TYPE)0 << TYPE_VALUE_BITS(TYPE)) \
+ ? ~(~(TYPE)0 << (sizeof(TYPE) * 8 - 1)) \
: (TYPE)-1)
/* Number of decimal digits required to format an integer of the given TYPE.