From c1901f7ed0dc43a92e611ff4cfc00ad97425318f Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 4 Dec 2010 05:53:07 +0100 Subject: fix compiler warning: conversion may lose significant bits --- lib/warnless.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'lib/warnless.c') diff --git a/lib/warnless.c b/lib/warnless.c index 3bd23df03..bc29d28df 100644 --- a/lib/warnless.c +++ b/lib/warnless.c @@ -141,7 +141,7 @@ unsigned char curlx_ultouc(unsigned long ulnum) } /* -** size_t to signed int +** unsigned size_t to signed int */ int curlx_uztosi(size_t uznum) @@ -169,6 +169,7 @@ int curlx_sltosi(long slnum) # pragma warning(disable:810) /* conversion may lose significant bits */ #endif + DEBUGASSERT(slnum >= 0); return (int)(slnum & (long) CURL_MASK_SINT); #ifdef __INTEL_COMPILER @@ -187,6 +188,7 @@ unsigned int curlx_sltoui(long slnum) # pragma warning(disable:810) /* conversion may lose significant bits */ #endif + DEBUGASSERT(slnum >= 0); return (unsigned int)(slnum & (long) CURL_MASK_UINT); #ifdef __INTEL_COMPILER @@ -205,6 +207,7 @@ unsigned short curlx_sltous(long slnum) # pragma warning(disable:810) /* conversion may lose significant bits */ #endif + DEBUGASSERT(slnum >= 0); return (unsigned short)(slnum & (long) CURL_MASK_USHORT); #ifdef __INTEL_COMPILER @@ -229,3 +232,22 @@ ssize_t curlx_uztosz(size_t uznum) # pragma warning(pop) #endif } + +/* +** signed curl_off_t to unsigned size_t +*/ + +size_t curlx_sotouz(curl_off_t sonum) +{ +#ifdef __INTEL_COMPILER +# pragma warning(push) +# pragma warning(disable:810) /* conversion may lose significant bits */ +#endif + + DEBUGASSERT(sonum >= 0); + return (size_t)(sonum & (curl_off_t) CURL_MASK_USIZE_T); + +#ifdef __INTEL_COMPILER +# pragma warning(pop) +#endif +} -- cgit v1.2.3