Added casting to eliminate warnings when compiled with win-avr gcc compiler.
This commit is contained in:
+37
-37
@@ -54,11 +54,11 @@ int decode_unsigned16(uint8_t * apdu, uint16_t * value)
|
||||
{
|
||||
if (value) {
|
||||
#if BIG_ENDIAN
|
||||
*value = (uint16_t)(apdu[0] & 0x00ff);
|
||||
*value |= ((uint16_t)((apdu[1] << 8) & 0xff00));
|
||||
*value = (uint16_t)(((uint16_t)apdu[0]) & 0x00ff);
|
||||
*value |= ((uint16_t)((((uint16_t)apdu[1]) << 8) & 0xff00));
|
||||
#else
|
||||
*value = (uint16_t)((apdu[0] << 8) & 0xff00);
|
||||
*value |= ((uint16_t)(apdu[1] & 0x00ff));
|
||||
*value = (uint16_t)((((uint16_t)apdu[0]) << 8) & 0xff00);
|
||||
*value |= ((uint16_t)(((uint16_t)apdu[1]) & 0x00ff));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -85,12 +85,12 @@ int decode_unsigned24(uint8_t * apdu, uint32_t * value)
|
||||
if (value) {
|
||||
#if BIG_ENDIAN
|
||||
*value = (uint32_t)(apdu[0] & 0x000000ff);
|
||||
*value |= ((uint32_t)((apdu[1] << 8) & 0x0000ff00));
|
||||
*value |= ((uint32_t)((apdu[2] << 16) & 0x00ff0000));
|
||||
*value |= ((uint32_t)((((uint32_t)apdu[1]) << 8) & 0x0000ff00));
|
||||
*value |= ((uint32_t)((((uint32_t)apdu[2]) << 16) & 0x00ff0000));
|
||||
#else
|
||||
*value = ((uint32_t)((apdu[0] << 16) & 0x00ff0000));
|
||||
*value |= (uint32_t)((apdu[1] << 8) & 0x0000ff00);
|
||||
*value |= ((uint32_t)(apdu[2] & 0x000000ff));
|
||||
*value = ((uint32_t)((((uint32_t)apdu[0]) << 16) & 0x00ff0000));
|
||||
*value |= (uint32_t)((((uint32_t)apdu[1]) << 8) & 0x0000ff00);
|
||||
*value |= ((uint32_t)(((uint32_t)apdu[2]) & 0x000000ff));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -118,15 +118,15 @@ int decode_unsigned32(uint8_t * apdu, uint32_t * value)
|
||||
{
|
||||
if (value) {
|
||||
#if BIG_ENDIAN
|
||||
*value = (uint32_t)(apdu[0] & 0x000000ff);
|
||||
*value |= ((uint32_t)((apdu[1] << 8) & 0x0000ff00));
|
||||
*value |= ((uint32_t)((apdu[2] << 16) & 0x00ff0000));
|
||||
*value |= ((uint32_t)((apdu[3] << 24) & 0xff000000));
|
||||
*value = (uint32_t)(((uint32_t)apdu[0]) & 0x000000ff);
|
||||
*value |= ((uint32_t)((((uint32_t)apdu[1]) << 8) & 0x0000ff00));
|
||||
*value |= ((uint32_t)((((uint32_t)apdu[2]) << 16) & 0x00ff0000));
|
||||
*value |= ((uint32_t)((((uint32_t)apdu[3]) << 24) & 0xff000000));
|
||||
#else
|
||||
*value = ((uint32_t)((apdu[0] << 24) & 0xff000000));
|
||||
*value |= ((uint32_t)((apdu[1] << 16) & 0x00ff0000));
|
||||
*value |= ((uint32_t)((apdu[2] << 8) & 0x0000ff00));
|
||||
*value |= ((uint32_t)(apdu[3] & 0x000000ff));
|
||||
*value = ((uint32_t)((((uint32_t)apdu[0]) << 24) & 0xff000000));
|
||||
*value |= ((uint32_t)((((uint32_t)apdu[1]) << 16) & 0x00ff0000));
|
||||
*value |= ((uint32_t)((((uint32_t)apdu[2]) << 8) & 0x0000ff00));
|
||||
*value |= ((uint32_t)(((uint32_t)apdu[3]) & 0x000000ff));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -149,14 +149,14 @@ int decode_signed8(uint8_t * apdu, int32_t * value)
|
||||
*value = 0x00FFFFFF;
|
||||
else
|
||||
*value = 0;
|
||||
*value |= ((int32_t)((apdu[0] << 24) & 0xff000000));
|
||||
*value |= ((int32_t)((((int32_t)apdu[0]) << 24) & 0xff000000));
|
||||
#else
|
||||
/* negative - bit 7 is set */
|
||||
if (apdu[0] & 0x80)
|
||||
*value = 0xFFFFFF00;
|
||||
else
|
||||
*value = 0;
|
||||
*value |= ((int32_t)(apdu[0] & 0x000000ff));
|
||||
*value |= ((int32_t)(((int32_t)apdu[0]) & 0x000000ff));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -185,16 +185,16 @@ int decode_signed16(uint8_t * apdu, int32_t * value)
|
||||
*value = 0x0000FFFF;
|
||||
else
|
||||
*value = 0;
|
||||
*value |= ((int32_t)((apdu[0] << 24) & 0xff000000));
|
||||
*value |= ((int32_t)((apdu[1] << 16) & 0x00ff0000));
|
||||
*value |= ((int32_t)((((int32_t)apdu[0]) << 24) & 0xff000000));
|
||||
*value |= ((int32_t)((((int32_t)apdu[1]) << 16) & 0x00ff0000));
|
||||
#else
|
||||
/* negative - bit 7 is set */
|
||||
if (apdu[0] & 0x80)
|
||||
*value = 0xFFFF0000;
|
||||
else
|
||||
*value = 0;
|
||||
*value |= ((int32_t)((apdu[0] << 8) & 0x0000ff00));
|
||||
*value |= ((int32_t)(apdu[1] & 0x000000ff));
|
||||
*value |= ((int32_t)((((int32_t)apdu[0]) << 8) & 0x0000ff00));
|
||||
*value |= ((int32_t)(((int32_t)apdu[1]) & 0x000000ff));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -225,18 +225,18 @@ int decode_signed24(uint8_t * apdu, int32_t * value)
|
||||
*value = 0x000000FF;
|
||||
else
|
||||
*value = 0;
|
||||
*value |= ((uint32_t)((apdu[0] << 8) & 0x0000ff00));
|
||||
*value |= ((uint32_t)((apdu[1] << 16) & 0x00ff0000));
|
||||
*value |= ((uint32_t)((apdu[2] << 24) & 0xff000000));
|
||||
*value |= ((int32_t)((((int32_t)apdu[0]) << 8) & 0x0000ff00));
|
||||
*value |= ((int32_t)((((int32_t)apdu[1]) << 16) & 0x00ff0000));
|
||||
*value |= ((int32_t)((((int32_t)apdu[2]) << 24) & 0xff000000));
|
||||
#else
|
||||
/* negative - bit 7 is set */
|
||||
if (apdu[0] & 0x80)
|
||||
*value = 0xFF000000;
|
||||
else
|
||||
*value = 0;
|
||||
*value |= ((uint32_t)((apdu[0] << 16) & 0x00ff0000));
|
||||
*value |= ((uint32_t)((apdu[1] << 8) & 0x0000ff00));
|
||||
*value |= ((uint32_t)(apdu[2] & 0x000000ff));
|
||||
*value |= ((int32_t)((((int32_t)apdu[0]) << 16) & 0x00ff0000));
|
||||
*value |= ((int32_t)((((int32_t)apdu[1]) << 8) & 0x0000ff00));
|
||||
*value |= ((int32_t)(((int32_t)apdu[2]) & 0x000000ff));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -264,15 +264,15 @@ int decode_signed32(uint8_t * apdu, int32_t * value)
|
||||
{
|
||||
if (value) {
|
||||
#if BIG_ENDIAN
|
||||
*value = (int32_t)(apdu[0] & 0x000000ff);
|
||||
*value |= ((int32_t)((apdu[1] << 8) & 0x0000ff00));
|
||||
*value |= ((int32_t)((apdu[2] << 16) & 0x00ff0000));
|
||||
*value |= ((int32_t)((apdu[3] << 24) & 0xff000000));
|
||||
*value = (int32_t)(((int32_t)apdu[0]) & 0x000000ff);
|
||||
*value |= ((int32_t)((((int32_t)apdu[1]) << 8) & 0x0000ff00));
|
||||
*value |= ((int32_t)((((int32_t)apdu[2]) << 16) & 0x00ff0000));
|
||||
*value |= ((int32_t)((((int32_t)apdu[3]) << 24) & 0xff000000));
|
||||
#else
|
||||
*value = ((int32_t)((apdu[0] << 24) & 0xff000000));
|
||||
*value |= ((int32_t)((apdu[1] << 16) & 0x00ff0000));
|
||||
*value |= ((int32_t)((apdu[2] << 8) & 0x0000ff00));
|
||||
*value |= ((int32_t)(apdu[3] & 0x000000ff));
|
||||
*value = ((int32_t)((((int32_t)apdu[0]) << 24) & 0xff000000));
|
||||
*value |= ((int32_t)((((int32_t)apdu[1]) << 16) & 0x00ff0000));
|
||||
*value |= ((int32_t)((((int32_t)apdu[2]) << 8) & 0x0000ff00));
|
||||
*value |= ((int32_t)(((int32_t)apdu[3]) & 0x000000ff));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user