mirror of
https://frontier.innolan.net/rainlance/c-ares.git
synced 2025-10-06 03:19:37 +00:00
warnings: fix some 'conversion may lose significant bits' compiler warnings
This commit is contained in:
@ -39,6 +39,19 @@
|
||||
|
||||
#include "ares_nowarn.h"
|
||||
|
||||
#if (SIZEOF_SHORT == 2)
|
||||
# define CARES_MASK_SSHORT 0x7FFF
|
||||
# define CARES_MASK_USHORT 0xFFFF
|
||||
#elif (SIZEOF_SHORT == 4)
|
||||
# define CARES_MASK_SSHORT 0x7FFFFFFF
|
||||
# define CARES_MASK_USHORT 0xFFFFFFFF
|
||||
#elif (SIZEOF_SHORT == 8)
|
||||
# define CARES_MASK_SSHORT 0x7FFFFFFFFFFFFFFF
|
||||
# define CARES_MASK_USHORT 0xFFFFFFFFFFFFFFFF
|
||||
#else
|
||||
# error "SIZEOF_SHORT not defined"
|
||||
#endif
|
||||
|
||||
#if (SIZEOF_INT == 2)
|
||||
# define CARES_MASK_SINT 0x7FFF
|
||||
# define CARES_MASK_UINT 0xFFFF
|
||||
@ -71,6 +84,43 @@ int aresx_uztosi(size_t uznum)
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
** unsigned size_t to signed short
|
||||
*/
|
||||
|
||||
short aresx_uztoss(size_t uznum)
|
||||
{
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:810) /* conversion may lose significant bits */
|
||||
#endif
|
||||
|
||||
return (short)(uznum & (size_t) CARES_MASK_SSHORT);
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
** signed int to signed short
|
||||
*/
|
||||
|
||||
short aresx_sitoss(int sinum)
|
||||
{
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:810) /* conversion may lose significant bits */
|
||||
#endif
|
||||
|
||||
DEBUGASSERT(sinum >= 0);
|
||||
return (short)(sinum & (int) CARES_MASK_SSHORT);
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
** signed long to signed int
|
||||
*/
|
||||
|
Reference in New Issue
Block a user