The compilar was interpreting the number zero '0' as a
signed number not an unsigned number. The left shift behavior
for signed numbers is undefined. The 'u' sufix was added to
tell the compilar that the '0' is an unsigned number.
Change-Id: Ida6c5c5ee2a7ea556755ca55d71858469a0691ac
Signed-off-by: George Nash <george.nash@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/11525
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Larry Sachs <larry.j.sachs@intel.com>
Reviewed-by: jaehyun Cho <jaehyun3.cho@samsung.com>
Reviewed-by: Rick Bell <richard.s.bell@intel.com>
OIC_LOG(ERROR, TAG, "set bits - lower err");
return;
}
OIC_LOG(ERROR, TAG, "set bits - lower err");
return;
}
- else if(~(unsigned)(~0<<n) < v)
+ else if(~(unsigned)(~0u<<n) < v)
{
OIC_LOG(ERROR, TAG, "set bits - upper err");
return;
}
{
OIC_LOG(ERROR, TAG, "set bits - upper err");
return;
}
- *x = (*x & (~(~0 << (p-n+1)))) | (*x & (~0 << (p+1))) | ((v & ~(~0 << n)) << (p-n+1));
+ *x = (*x & (~(~0u << (p-n+1)))) | (*x & (~0u << (p+1))) | ((v & ~(~0u << n)) << (p-n+1));
*/
static uint8_t CAGetBits(uint8_t x, unsigned p, unsigned n)
{
*/
static uint8_t CAGetBits(uint8_t x, unsigned p, unsigned n)
{
- return (x >> (p + 1 - n)) & ~(~0 << n);
+ return (x >> (p + 1 - n)) & ~(~0u << n);
}
CAResult_t CAGenerateVariableForFragmentation(size_t dataLength,
}
CAResult_t CAGenerateVariableForFragmentation(size_t dataLength,