This commit is contained in:
iceman1001 2023-07-23 22:32:59 +02:00
parent a761c9765a
commit 7473bebdbd

View file

@ -161,27 +161,39 @@ uint64_t bytes_to_num(uint8_t *src, size_t len) {
}
uint16_t MemLeToUint2byte(const uint8_t *data) {
return (data[1] << 8) + data[0];
return (uint16_t)(
(data[1] << 8) + data[0]
);
}
uint32_t MemLeToUint3byte(const uint8_t *data) {
return (data[2] << 16) + (data[1] << 8) + data[0];
return (uint32_t)(
(data[2] << 16) + (data[1] << 8) + data[0]
);
}
uint32_t MemLeToUint4byte(const uint8_t *data) {
return (data[3] << 24) + (data[2] << 16) + (data[1] << 8) + data[0];
return (uint32_t)(
(data[3] << 24) + (data[2] << 16) + (data[1] << 8) + data[0]
);
}
uint16_t MemBeToUint2byte(const uint8_t *data) {
return (data[0] << 8) + data[1];
return (uint16_t)(
(data[0] << 8) + data[1]
);
}
uint32_t MemBeToUint3byte(const uint8_t *data) {
return (data[0] << 16) + (data[1] << 8) + data[2];
return (uint32_t)(
(data[0] << 16) + (data[1] << 8) + data[2]
);
}
uint32_t MemBeToUint4byte(const uint8_t *data) {
return (data[0] << 24) + (data[1] << 16) + (data[2] << 8) + data[3];
return (uint32_t)(
(data[0] << 24) + (data[1] << 16) + (data[2] << 8) + data[3]
);
}
void Uint2byteToMemLe(uint8_t *data, uint16_t value) {