tool/btstack_event_generator: avoid cast of composite expression to wider/different type

This commit is contained in:
Matthias Ringwald 2024-04-17 16:53:00 +02:00
parent f9aa0bbcf0
commit e52cfa762f
2 changed files with 8 additions and 8 deletions

View File

@ -13794,8 +13794,8 @@ static inline const uint8_t * gattservice_subevent_bass_client_notify_receive_st
* @note: btstack_type 3
*/
static inline uint32_t gattservice_subevent_bass_client_notify_receive_state_subgroup_get_language_code(const uint8_t * event){
uint16_t offset = 16u + event[15];
return little_endian_read_24(event, (int)(int16_t) offset);
uint8_t offset = 16u + event[15];
return little_endian_read_24(event, (int)(int8_t) offset);
}
/**
* @brief Get field ccids_num from event GATTSERVICE_SUBEVENT_BASS_CLIENT_NOTIFY_RECEIVE_STATE_SUBGROUP
@ -13849,8 +13849,8 @@ static inline const uint8_t * gattservice_subevent_bass_client_notify_receive_st
* @note: btstack_type 2
*/
static inline uint16_t gattservice_subevent_bass_client_notify_receive_state_subgroup_get_extended_metadata_type(const uint8_t * event){
uint16_t offset = 16u + event[15] + 3u + 1u + event[16u + event[15] + 3u] + 1u + 1u + event[16u + event[15] + 3u + 1u + event[16u + event[15] + 3u] + 1u];
return little_endian_read_16(event, (int)(int16_t) offset);
uint8_t offset = 16u + event[15] + 3u + 1u + event[16u + event[15] + 3u] + 1u + 1u + event[16u + event[15] + 3u + 1u + event[16u + event[15] + 3u] + 1u];
return little_endian_read_16(event, (int)(int8_t) offset);
}
/**
* @brief Get field extended_metadata_value_length from event GATTSERVICE_SUBEVENT_BASS_CLIENT_NOTIFY_RECEIVE_STATE_SUBGROUP
@ -13877,8 +13877,8 @@ static inline const uint8_t * gattservice_subevent_bass_client_notify_receive_st
* @note: btstack_type 2
*/
static inline uint16_t gattservice_subevent_bass_client_notify_receive_state_subgroup_get_vendor_specific_metadata_type(const uint8_t * event){
uint16_t offset = 16u + event[15] + 3u + 1u + event[16u + event[15] + 3u] + 1u + 1u + event[16u + event[15] + 3u + 1u + event[16u + event[15] + 3u] + 1u] + 2u + 1u + event[16u + event[15] + 3u + 1u + event[16u + event[15] + 3u] + 1u + 1u + event[16u + event[15] + 3u + 1u + event[16u + event[15] + 3u] + 1u] + 2u];
return little_endian_read_16(event, (int)(int16_t) offset);
uint8_t offset = 16u + event[15] + 3u + 1u + event[16u + event[15] + 3u] + 1u + 1u + event[16u + event[15] + 3u + 1u + event[16u + event[15] + 3u] + 1u] + 2u + 1u + event[16u + event[15] + 3u + 1u + event[16u + event[15] + 3u] + 1u + 1u + event[16u + event[15] + 3u + 1u + event[16u + event[15] + 3u] + 1u] + 2u];
return little_endian_read_16(event, (int)(int8_t) offset);
}
/**
* @brief Get field vendor_specific_metadata_value_length from event GATTSERVICE_SUBEVENT_BASS_CLIENT_NOTIFY_RECEIVE_STATE_SUBGROUP

View File

@ -273,8 +273,8 @@ def create_getter(event_name, field_name, field_type, offset, offset_is_number,
requires_signed = 'little_endian' in read_code or 'gatt_client_deserialize' in read_code
code = ''
if requires_signed and not offset_is_number:
code += 'uint16_t offset = %s;\n ' % offset
offset = '(int)(int16_t) offset'
code += 'uint8_t offset = %s;\n ' % offset
offset = '(int)(int8_t) offset'
code += read_code.format(offset=offset, result_name=result_name)
return template.format(description=description, fn_name=fn_name, result_name=result_name, result_type=result_type, code=code, format=field_type)