tool/btstack_event_generator: enforce uint8_t offsets

This commit is contained in:
Matthias Ringwald 2020-07-07 22:22:23 +02:00
parent 4562e2a2b9
commit 3573e8a41e
2 changed files with 4 additions and 4 deletions

View File

@ -7254,7 +7254,7 @@ static inline const uint8_t * pbap_subevent_card_result_get_name(const uint8_t *
* @note: btstack_type J
*/
static inline uint8_t pbap_subevent_card_result_get_handle_len(const uint8_t * event){
return event[6 + event[5]];
return event[((uint8_t) 6) + event[5]];
}
/**
* @brief Get field handle from event PBAP_SUBEVENT_CARD_RESULT
@ -7263,7 +7263,7 @@ static inline uint8_t pbap_subevent_card_result_get_handle_len(const uint8_t * e
* @note: btstack_type V
*/
static inline const uint8_t * pbap_subevent_card_result_get_handle(const uint8_t * event){
return &event[6 + event[5] + 1];
return &event[((uint8_t) 6) + event[5] + ((uint8_t) 1)];
}
/**

View File

@ -311,7 +311,7 @@ def create_events(events):
if last_variable_length_field_pos >= 0:
if offset_is_number:
# convert to string
offset = '%u' % offset
offset = '((uint8_t) %u)' % offset
offset_is_number = 0
offset = offset + ' + event[%s]' % last_variable_length_field_pos
else:
@ -320,7 +320,7 @@ def create_events(events):
if offset_is_number:
offset += size_for_type(field_type)
else:
offset = offset + ' + %u' % size_for_type(field_type)
offset = offset + ' + ((uint8_t) %u)' % size_for_type(field_type)
if is_le_event(event_group):
fout.write("#endif\n")
fout.write("\n")