MISRAC2012-Rule-14.4_d: use while(true) instead of while(1)

This commit is contained in:
Matthias Ringwald 2019-12-03 12:52:10 +01:00
parent 6e79178071
commit ff3cc4a537
27 changed files with 33 additions and 33 deletions

View File

@ -181,7 +181,7 @@ void btstack_chipset_bcm_set_hcd_folder_path(const char * path){
static int equal_ignore_case(const char *str1, const char *str2){
if (!str1 || !str2) return (1);
int i = 0;
while (1){
while (true){
if (!str1[i] && !str2[i]) return 1;
if (tolower(str1[i]) != tolower(str2[i])) return 0;
if (!str1[i] || !str2[i]) return 0;
@ -229,7 +229,7 @@ void btstack_chipset_bcm_set_device_name(const char * device_name){
log_error("chipset-bcm: could not get directory for %s", hcd_folder_path);
return;
}
while (1){
while (true){
struct dirent *dp = readdir(dirp);
if (!dp) break;
if (equal_ignore_case(filename_complete, dp->d_name)){

View File

@ -144,7 +144,7 @@ static enum update_result update_init_script_command(uint8_t *hci_cmd_buffer){
static btstack_chipset_result_t chipset_next_command(uint8_t * hci_cmd_buffer){
while (1){
while (true){
if (init_script_offset >= init_script_size) {
return BTSTACK_CHIPSET_DONE;

View File

@ -71,7 +71,7 @@ static void chipset_init(const void * config){
static btstack_chipset_result_t chipset_next_command(uint8_t * hci_cmd_buffer){
while (1){
while (true){
if (init_script_offset >= init_script_size) {
return BTSTACK_CHIPSET_DONE;

View File

@ -2166,7 +2166,7 @@ int main (int argc, char * const * argv){
{ 0,0,0,0 } // This is a filler for -1
};
while (1) {
while (true) {
int c;
int option_index = -1;
c = getopt_long(argc, argv, "h", long_options, &option_index);

View File

@ -222,7 +222,7 @@ void btstack_run_loop_embedded_execute_once(void) {
* Execute run_loop
*/
static void btstack_run_loop_embedded_execute(void) {
while (1) {
while (true) {
btstack_run_loop_embedded_execute_once();
}
}

View File

@ -213,7 +213,7 @@ void btstack_run_loop_freertos_execute_code_on_main_thread_from_isr(void (*fn)(v
static void btstack_run_loop_freertos_execute(void) {
log_debug("RL: execute");
while (1) {
while (true) {
// process data sources
btstack_data_source_t *ds;
@ -226,7 +226,7 @@ static void btstack_run_loop_freertos_execute(void) {
}
// process registered function calls on run loop thread
while (1){
while (true){
function_call_t message = { NULL, NULL };
BaseType_t res = xQueueReceive( btstack_run_loop_queue, &message, 0);
if (res == pdFALSE) break;

View File

@ -1022,7 +1022,7 @@ static int usb_open(void){
} else {
int deviceIndex = -1;
while (1){
while (true){
// look for next Bluetooth dongle
deviceIndex = scan_for_bt_device(devs, deviceIndex+1);
if (deviceIndex < 0) break;

View File

@ -210,7 +210,7 @@ static void btstack_run_loop_posix_execute(void) {
log_info("POSIX run loop using ettimeofday fallback.");
#endif
while (1) {
while (true) {
// collect FDs
FD_ZERO(&descriptors_read);
FD_ZERO(&descriptors_write);

View File

@ -180,7 +180,7 @@ static int btstack_tlv_posix_read_db(btstack_tlv_posix_t * self){
if (memcmp(header, btstack_tlv_header_magic, strlen(btstack_tlv_header_magic)) == 0){
log_info("BTstack Magic Header found");
// read entries
while (1){
while (true){
uint8_t entry[8];
size_t entries_read = fread(entry, 1, sizeof(entry), self->file);
if (entries_read == 0){

View File

@ -211,7 +211,7 @@ static void le_device_db_read(void){
FILE * wFile = fopen(db_path,"r");
if (wFile == NULL) return;
// skip header
while (1) {
while (true) {
int c = fgetc(wFile);
if (feof(wFile)) goto exit;
if (c == '\n') break;

View File

@ -128,7 +128,7 @@ void btstack_run_loop_wiced_execute_code_on_main_thread(wiced_result_t (*fn)(voi
* Execute run_loop
*/
static void btstack_run_loop_wiced_execute(void) {
while (1) {
while (true) {
// get next timeout
uint32_t timeout_ms = WICED_NEVER_TIMEOUT;
if (timers) {

View File

@ -58,7 +58,7 @@ static wiced_result_t stdin_reader_notify(void * p){
static void stdin_reader_thread_process(wiced_thread_arg_t p){
UNUSED(p);
while (1){
while (true){
uint8_t c = getchar();
btstack_run_loop_wiced_execute_code_on_main_thread(&stdin_reader_notify, (void *)(uintptr_t) c);
}

View File

@ -152,7 +152,7 @@ static void btstack_run_loop_windows_execute(void) {
btstack_timer_source_t *ts;
btstack_linked_list_iterator_t it;
while (1) {
while (true) {
// collect handles to wait for
HANDLE handles[100];

View File

@ -63,7 +63,7 @@ static HANDLE key_processed_handle;
static void (*stdin_handler)(char c);
static WINAPI DWORD stdin_reader_thread_process(void * p){
while (1){
while (true){
key_read_buffer = getch();
SignalObjectAndWait(stdin_source.source.handle, key_processed_handle, INFINITE, FALSE);
}

View File

@ -696,7 +696,7 @@ static void att_server_handle_can_send_now(void){
for (phase_index = ATT_SERVER_RUN_PHASE_1_REQUESTS; phase_index <= ATT_SERVER_RUN_PHASE_3_NOTIFICATIONS; phase_index++){
att_server_run_phase_t phase = (att_server_run_phase_t) phase_index;
hci_con_handle_t skip_connections_until = att_server_last_can_send_now;
while (1){
while (true){
btstack_linked_list_iterator_t it;
hci_connections_get_iterator(&it);
while(btstack_linked_list_iterator_has_next(&it)){

View File

@ -2008,7 +2008,7 @@ static void sm_run(void){
// active connection handling
// -- use loop to handle next connection if lock on setup context is released
while (1) {
while (true) {
// Find connections that requires setup context and make active if no other is locked
hci_connections_get_iterator(&it);

View File

@ -646,7 +646,7 @@ static void btstack_crypto_run(void){
if (hci_get_state() != HCI_STATE_WORKING) return;
// try to do as much as possible
while (1){
while (true){
// anything to do?
if (btstack_linked_list_empty(&btstack_crypto_operations)) return;

View File

@ -68,7 +68,7 @@ uint16_t btstack_resample_block(btstack_resample_t * context, const int16_t * in
context->src_pos += context->src_step;
}
// process current block
while (1){
while (true){
const uint16_t src_pos = context->src_pos >> 16;
const uint16_t t = context->src_pos & 0xffff;
int index = src_pos * context->num_channels;

View File

@ -60,7 +60,7 @@ extern const btstack_run_loop_t btstack_run_loop_embedded;
static void btstack_run_loop_assert(void){
if (!the_run_loop){
log_error("ERROR: run_loop function called before btstack_run_loop_init!");
while(1);
while (true);
}
}
@ -193,7 +193,7 @@ void btstack_run_loop_execute(void){
void btstack_run_loop_init(const btstack_run_loop_t * run_loop){
if (the_run_loop){
log_error("ERROR: run loop initialized twice!");
while(1);
while (true);
}
the_run_loop = run_loop;
the_run_loop->init();

View File

@ -373,7 +373,7 @@ int sscanf_bd_addr(const char * addr_string, bd_addr_t addr){
uint32_t btstack_atoi(const char *str){
uint32_t val = 0;
while (1){
while (true){
char chr = *str;
if (!chr || (chr < '0') || (chr > '9'))
return val;

View File

@ -653,7 +653,7 @@ static int hci_send_acl_packet_fragments(hci_connection_t *connection){
int err;
// multiple packets could be send on a synchronous HCI transport
while (1){
while (true){
log_debug("hci_send_acl_packet_fragments loop entered");

View File

@ -400,7 +400,7 @@ static void hci_transport_em9304_spi_reset_statemachine(void){
}
static void hci_transport_em9304_spi_process_data(void){
while (1){
while (true){
uint16_t bytes_available = em9304_engine_num_bytes_available();
log_debug("transfer_rx_data: ring buffer has %u -> hci wants %u", bytes_available, hci_transport_em9304_spi_bytes_to_read);

View File

@ -725,7 +725,7 @@ static void l2cap_ertm_process_req_seq(l2cap_channel_t * l2cap_channel, uint8_t
int num_buffers_acked = 0;
l2cap_ertm_tx_packet_state_t * tx_state;
log_info("l2cap_ertm_process_req_seq: tx_read_index %u, tx_write_index %u, req_seq %u", l2cap_channel->tx_read_index, l2cap_channel->tx_write_index, req_seq);
while (1){
while (true){
// no unack packets left
if (l2cap_channel->unacked_frames == 0) {
@ -3460,7 +3460,7 @@ static void l2cap_acl_classic_handler(hci_con_handle_t handle, uint8_t *packet,
l2cap_ertm_handle_in_sequence_sdu(l2cap_channel, sar, payload_data, payload_len);
// process stored segments
while (1){
while (true){
int index = l2cap_channel->rx_store_index;
l2cap_ertm_rx_packet_state_t * rx_state = &l2cap_channel->rx_packets_state[index];
if (!rx_state->valid) break;

View File

@ -110,7 +110,7 @@ void mesh_network_key_nid_iterator_init(mesh_network_key_iterator_t *it, uint8_t
int mesh_network_key_nid_iterator_has_more(mesh_network_key_iterator_t *it){
// find next matching key
while (1){
while (true){
if (it->key && it->key->nid == it->nid) return 1;
if (!btstack_linked_list_iterator_has_next(&it->it)) break;
it->key = (mesh_network_key_t *) btstack_linked_list_iterator_next(&it->it);
@ -188,7 +188,7 @@ void mesh_transport_key_iterator_init(mesh_transport_key_iterator_t *it, uint16_
int mesh_transport_key_iterator_has_more(mesh_transport_key_iterator_t *it){
// find next matching key
while (1){
while (true){
if (it->key && it->key->netkey_index == it->netkey_index) return 1;
if (!btstack_linked_list_iterator_has_next(&it->it)) break;
it->key = (mesh_transport_key_t *) btstack_linked_list_iterator_next(&it->it);
@ -220,7 +220,7 @@ int mesh_transport_key_aid_iterator_has_more(mesh_transport_key_iterator_t *it){
return it->key != NULL;
}
// find next matching key
while (1){
while (true){
if (it->key && it->key->aid == it->aid && it->key->netkey_index == it->netkey_index) return 1;
if (!btstack_linked_list_iterator_has_next(&it->it)) break;
it->key = (mesh_transport_key_t *) btstack_linked_list_iterator_next(&it->it);

View File

@ -742,7 +742,7 @@ void mesh_lower_transport_send_pdu(mesh_pdu_t *pdu){
// network pdu without payload = 9 bytes
if (network_pdu->len < 9){
printf("too short, %u\n", network_pdu->len);
while(1);
while (true);
}
}
btstack_linked_list_add_tail(&lower_transport_outgoing, (btstack_linked_item_t*) pdu);

View File

@ -107,7 +107,7 @@ static void mesh_transport_key_and_virtual_address_iterator_init(mesh_transport_
static int mesh_transport_key_and_virtual_address_iterator_has_more(mesh_transport_key_and_virtual_address_iterator_t * it){
if (mesh_network_address_virtual(it->dst)) {
// find next valid entry
while (1){
while (true){
if (mesh_virtual_address_iterator_has_more(&it->address_it)) return 1;
if (!mesh_transport_key_aid_iterator_has_more(&it->key_it)) return 0;
// get next key

View File

@ -116,7 +116,7 @@ void mesh_virtual_address_iterator_init(mesh_virtual_address_iterator_t * it, ui
int mesh_virtual_address_iterator_has_more(mesh_virtual_address_iterator_t * it){
// find next matching key
while (1){
while (true){
printf("check %p\n", it->address);
if (it->address && it->address->hash == it->hash) return 1;
if (!btstack_linked_list_iterator_has_next(&it->it)) break;