@@ -976,7 +976,7 @@ static HAPError HAPTLVReaderDecodeScalar(
976976 HAPTLVAppendToLog (tlvType , debugDescription , format_ , value_ , stringBuilder , nestingLevel );
977977 }
978978 return kHAPError_None ;
979- #define PROCESS_INTEGER_FORMAT (formatName , typeName , printfFormat , printfTypeName ) \
979+ #define PROCESS_INTEGER_FORMAT (formatName , typeName , printfFormat , printfTypeName , intermediateTypeName ) \
980980 do { \
981981 const formatName* fmt = format_; \
982982 typeName* value = HAPNonnullVoid(value_); \
@@ -992,7 +992,7 @@ static HAPError HAPTLVReaderDecodeScalar(
992992 return kHAPError_InvalidData; \
993993 } \
994994 for (size_t i = 0; i < numBytes; i++) { \
995- *value |= (typeName)(((const uint8_t*) bytes)[i] << (i * CHAR_BIT)); \
995+ *value |= (typeName)(((intermediateTypeName)(( const uint8_t*) bytes)[i]) << (i * CHAR_BIT)); \
996996 } \
997997 if (*value < fmt->constraints.minimumValue || *value > fmt->constraints.maximumValue) { \
998998 HAPLogTLV( \
@@ -1010,35 +1010,35 @@ static HAPError HAPTLVReaderDecodeScalar(
10101010 HAPTLVAppendToLog(tlvType, debugDescription, format_, value_, stringBuilder, nestingLevel); \
10111011 } while (0)
10121012 case kHAPTLVFormatType_UInt8 : {
1013- PROCESS_INTEGER_FORMAT (HAPUInt8TLVFormat , uint8_t , "u" , unsigned int );
1013+ PROCESS_INTEGER_FORMAT (HAPUInt8TLVFormat , uint8_t , "u" , unsigned int , uint8_t );
10141014 }
10151015 return kHAPError_None ;
10161016 case kHAPTLVFormatType_UInt16 : {
1017- PROCESS_INTEGER_FORMAT (HAPUInt16TLVFormat , uint16_t , "u" , unsigned int );
1017+ PROCESS_INTEGER_FORMAT (HAPUInt16TLVFormat , uint16_t , "u" , unsigned int , uint16_t );
10181018 }
10191019 return kHAPError_None ;
10201020 case kHAPTLVFormatType_UInt32 : {
1021- PROCESS_INTEGER_FORMAT (HAPUInt32TLVFormat , uint32_t , "lu" , unsigned long );
1021+ PROCESS_INTEGER_FORMAT (HAPUInt32TLVFormat , uint32_t , "lu" , unsigned long , uint32_t );
10221022 }
10231023 return kHAPError_None ;
10241024 case kHAPTLVFormatType_UInt64 : {
1025- PROCESS_INTEGER_FORMAT (HAPUInt64TLVFormat , uint64_t , "llu" , unsigned long long);
1025+ PROCESS_INTEGER_FORMAT (HAPUInt64TLVFormat , uint64_t , "llu" , unsigned long long, uint64_t );
10261026 }
10271027 return kHAPError_None ;
10281028 case kHAPTLVFormatType_Int8 : {
1029- PROCESS_INTEGER_FORMAT (HAPInt8TLVFormat , int8_t , "d" , int );
1029+ PROCESS_INTEGER_FORMAT (HAPInt8TLVFormat , int8_t , "d" , int , uint8_t );
10301030 }
10311031 return kHAPError_None ;
10321032 case kHAPTLVFormatType_Int16 : {
1033- PROCESS_INTEGER_FORMAT (HAPInt16TLVFormat , int16_t , "d" , int );
1033+ PROCESS_INTEGER_FORMAT (HAPInt16TLVFormat , int16_t , "d" , int , uint16_t );
10341034 }
10351035 return kHAPError_None ;
10361036 case kHAPTLVFormatType_Int32 : {
1037- PROCESS_INTEGER_FORMAT (HAPInt32TLVFormat , int32_t , "ld" , long );
1037+ PROCESS_INTEGER_FORMAT (HAPInt32TLVFormat , int32_t , "ld" , long , uint32_t );
10381038 }
10391039 return kHAPError_None ;
10401040 case kHAPTLVFormatType_Int64 : {
1041- PROCESS_INTEGER_FORMAT (HAPInt64TLVFormat , int64_t , "lld" , long long );
1041+ PROCESS_INTEGER_FORMAT (HAPInt64TLVFormat , int64_t , "lld" , long long , uint64_t );
10421042 }
10431043 return kHAPError_None ;
10441044#undef PROCESS_INTEGER_FORMAT
0 commit comments