diff options
author | Yang Tse <yangsita@gmail.com> | 2010-02-26 16:42:33 +0000 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2010-02-26 16:42:33 +0000 |
commit | bcd1c7c2e92d41ab02163a36a1ab9d5a7afd83a9 (patch) | |
tree | 0b98ca5c331ee57703a51747d0f8e975ceaffab7 /lib/warnless.c | |
parent | 87428e07ca17a99fb2409ec39213b7badbe967ea (diff) | |
download | curl-bcd1c7c2e92d41ab02163a36a1ab9d5a7afd83a9.tar.gz |
fix compiler warning
Diffstat (limited to 'lib/warnless.c')
-rw-r--r-- | lib/warnless.c | 72 |
1 files changed, 70 insertions, 2 deletions
diff --git a/lib/warnless.c b/lib/warnless.c index ffbcaa3f1..232ff8027 100644 --- a/lib/warnless.c +++ b/lib/warnless.c @@ -25,6 +25,52 @@ #include "warnless.h" +#define CURL_MASK_SCHAR 0x7F +#define CURL_MASK_UCHAR 0xFF + +#if (SIZEOF_SHORT == 2) +# define CURL_MASK_SSHORT 0x7FFF +# define CURL_MASK_USHORT 0xFFFF +#elif (SIZEOF_SHORT == 4) +# define CURL_MASK_SSHORT 0x7FFFFFFF +# define CURL_MASK_USHORT 0xFFFFFFFF +#elif (SIZEOF_SHORT == 8) +# define CURL_MASK_SSHORT 0x7FFFFFFFFFFFFFFF +# define CURL_MASK_USHORT 0xFFFFFFFFFFFFFFFF +#endif + +#if (SIZEOF_INT == 2) +# define CURL_MASK_SINT 0x7FFF +# define CURL_MASK_UINT 0xFFFF +#elif (SIZEOF_INT == 4) +# define CURL_MASK_SINT 0x7FFFFFFF +# define CURL_MASK_UINT 0xFFFFFFFF +#elif (SIZEOF_INT == 8) +# define CURL_MASK_SINT 0x7FFFFFFFFFFFFFFF +# define CURL_MASK_UINT 0xFFFFFFFFFFFFFFFF +#elif (SIZEOF_INT == 16) +# define CURL_MASK_SINT 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF +# define CURL_MASK_UINT 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF +#endif + +#if (SIZEOF_LONG == 2) +# define CURL_MASK_SLONG 0x7FFFL +# define CURL_MASK_ULONG 0xFFFFUL +#elif (SIZEOF_LONG == 4) +# define CURL_MASK_SLONG 0x7FFFFFFFL +# define CURL_MASK_ULONG 0xFFFFFFFFUL +#elif (SIZEOF_LONG == 8) +# define CURL_MASK_SLONG 0x7FFFFFFFFFFFFFFFL +# define CURL_MASK_ULONG 0xFFFFFFFFFFFFFFFFUL +#elif (SIZEOF_LONG == 16) +# define CURL_MASK_SLONG 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFL +# define CURL_MASK_ULONG 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFUL +#endif + +/* +** unsigned long to unsigned short +*/ + unsigned short curlx_ultous(unsigned long ulnum) { #ifdef __INTEL_COMPILER @@ -32,13 +78,17 @@ unsigned short curlx_ultous(unsigned long ulnum) # pragma warning(disable:810) /* conversion may lose significant bits */ #endif - return (unsigned short)(ulnum & 0xFFFFUL); + return (unsigned short)(ulnum & (unsigned long) CURL_MASK_USHORT); #ifdef __INTEL_COMPILER # pragma warning(pop) #endif } +/* +** unsigned long to unsigned char +*/ + unsigned char curlx_ultouc(unsigned long ulnum) { #ifdef __INTEL_COMPILER @@ -46,7 +96,25 @@ unsigned char curlx_ultouc(unsigned long ulnum) # pragma warning(disable:810) /* conversion may lose significant bits */ #endif - return (unsigned char)(ulnum & 0xFFUL); + return (unsigned char)(ulnum & (unsigned long) CURL_MASK_UCHAR); + +#ifdef __INTEL_COMPILER +# pragma warning(pop) +#endif +} + +/* +** size_t to signed int +*/ + +int curlx_uztosi(size_t uznum) +{ +#ifdef __INTEL_COMPILER +# pragma warning(push) +# pragma warning(disable:810) /* conversion may lose significant bits */ +#endif + + return (int)(uznum & (size_t) CURL_MASK_SINT); #ifdef __INTEL_COMPILER # pragma warning(pop) |