diff --git a/chipset/bcm/btstack_chipset_bcm.c b/chipset/bcm/btstack_chipset_bcm.c index dc6d62d5f..220d378f8 100644 --- a/chipset/bcm/btstack_chipset_bcm.c +++ b/chipset/bcm/btstack_chipset_bcm.c @@ -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)){ diff --git a/chipset/csr/btstack_chipset_csr.c b/chipset/csr/btstack_chipset_csr.c index defc2166a..c9c730730 100644 --- a/chipset/csr/btstack_chipset_csr.c +++ b/chipset/csr/btstack_chipset_csr.c @@ -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; diff --git a/chipset/zephyr/btstack_chipset_zephyr.c b/chipset/zephyr/btstack_chipset_zephyr.c index 05a33732c..5a39d648a 100644 --- a/chipset/zephyr/btstack_chipset_zephyr.c +++ b/chipset/zephyr/btstack_chipset_zephyr.c @@ -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; diff --git a/platform/daemon/src/daemon.c b/platform/daemon/src/daemon.c index 23e54904f..3f9982486 100644 --- a/platform/daemon/src/daemon.c +++ b/platform/daemon/src/daemon.c @@ -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); diff --git a/platform/embedded/btstack_run_loop_embedded.c b/platform/embedded/btstack_run_loop_embedded.c index 7d1c71d47..daa891206 100644 --- a/platform/embedded/btstack_run_loop_embedded.c +++ b/platform/embedded/btstack_run_loop_embedded.c @@ -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(); } } diff --git a/platform/freertos/btstack_run_loop_freertos.c b/platform/freertos/btstack_run_loop_freertos.c index 2972e5c53..305230094 100644 --- a/platform/freertos/btstack_run_loop_freertos.c +++ b/platform/freertos/btstack_run_loop_freertos.c @@ -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; diff --git a/platform/libusb/hci_transport_h2_libusb.c b/platform/libusb/hci_transport_h2_libusb.c index fa54a0f74..314a3fa21 100644 --- a/platform/libusb/hci_transport_h2_libusb.c +++ b/platform/libusb/hci_transport_h2_libusb.c @@ -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; diff --git a/platform/posix/btstack_run_loop_posix.c b/platform/posix/btstack_run_loop_posix.c index 9d1ae8f1b..9ea60f376 100644 --- a/platform/posix/btstack_run_loop_posix.c +++ b/platform/posix/btstack_run_loop_posix.c @@ -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); diff --git a/platform/posix/btstack_tlv_posix.c b/platform/posix/btstack_tlv_posix.c index 3e5f30c5f..5a0b90dcf 100644 --- a/platform/posix/btstack_tlv_posix.c +++ b/platform/posix/btstack_tlv_posix.c @@ -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){ diff --git a/platform/posix/le_device_db_fs.c b/platform/posix/le_device_db_fs.c index f90d5b6ec..71364fc95 100644 --- a/platform/posix/le_device_db_fs.c +++ b/platform/posix/le_device_db_fs.c @@ -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; diff --git a/platform/wiced/btstack_run_loop_wiced.c b/platform/wiced/btstack_run_loop_wiced.c index 42915c446..7ee320e97 100644 --- a/platform/wiced/btstack_run_loop_wiced.c +++ b/platform/wiced/btstack_run_loop_wiced.c @@ -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) { diff --git a/platform/wiced/btstack_stdin_wiced.c b/platform/wiced/btstack_stdin_wiced.c index 59d30d99f..c3ae67eb7 100644 --- a/platform/wiced/btstack_stdin_wiced.c +++ b/platform/wiced/btstack_stdin_wiced.c @@ -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); } diff --git a/platform/windows/btstack_run_loop_windows.c b/platform/windows/btstack_run_loop_windows.c index d6bb4ae8b..cc5b7cc05 100644 --- a/platform/windows/btstack_run_loop_windows.c +++ b/platform/windows/btstack_run_loop_windows.c @@ -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]; diff --git a/platform/windows/btstack_stdin_windows.c b/platform/windows/btstack_stdin_windows.c index 2c5dfcda4..6ad7f989d 100644 --- a/platform/windows/btstack_stdin_windows.c +++ b/platform/windows/btstack_stdin_windows.c @@ -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); } diff --git a/src/ble/att_server.c b/src/ble/att_server.c index 81f1b7b61..2a20f924f 100644 --- a/src/ble/att_server.c +++ b/src/ble/att_server.c @@ -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)){ diff --git a/src/ble/sm.c b/src/ble/sm.c index f87832f7d..6b08ea7b1 100644 --- a/src/ble/sm.c +++ b/src/ble/sm.c @@ -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); diff --git a/src/btstack_crypto.c b/src/btstack_crypto.c index 123f3a2d1..df2cbe40f 100644 --- a/src/btstack_crypto.c +++ b/src/btstack_crypto.c @@ -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; diff --git a/src/btstack_resample.c b/src/btstack_resample.c index c26c3a41b..73202ff67 100644 --- a/src/btstack_resample.c +++ b/src/btstack_resample.c @@ -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; diff --git a/src/btstack_run_loop.c b/src/btstack_run_loop.c index de5accf90..0bfe4a247 100644 --- a/src/btstack_run_loop.c +++ b/src/btstack_run_loop.c @@ -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(); diff --git a/src/btstack_util.c b/src/btstack_util.c index 718cbf902..1aef6e4df 100644 --- a/src/btstack_util.c +++ b/src/btstack_util.c @@ -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; diff --git a/src/hci.c b/src/hci.c index a380d0e7a..b61d0edbf 100644 --- a/src/hci.c +++ b/src/hci.c @@ -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"); diff --git a/src/hci_transport_em9304_spi.c b/src/hci_transport_em9304_spi.c index 427478ba0..f928784f3 100644 --- a/src/hci_transport_em9304_spi.c +++ b/src/hci_transport_em9304_spi.c @@ -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); diff --git a/src/l2cap.c b/src/l2cap.c index aef4547ff..e0664de3f 100644 --- a/src/l2cap.c +++ b/src/l2cap.c @@ -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; diff --git a/src/mesh/mesh_keys.c b/src/mesh/mesh_keys.c index 62879a654..f9055aaf0 100644 --- a/src/mesh/mesh_keys.c +++ b/src/mesh/mesh_keys.c @@ -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); diff --git a/src/mesh/mesh_lower_transport.c b/src/mesh/mesh_lower_transport.c index 58e6623bf..542bb2267 100644 --- a/src/mesh/mesh_lower_transport.c +++ b/src/mesh/mesh_lower_transport.c @@ -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); diff --git a/src/mesh/mesh_upper_transport.c b/src/mesh/mesh_upper_transport.c index 24813c885..6929ba7b5 100644 --- a/src/mesh/mesh_upper_transport.c +++ b/src/mesh/mesh_upper_transport.c @@ -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 diff --git a/src/mesh/mesh_virtual_addresses.c b/src/mesh/mesh_virtual_addresses.c index 3f8d01869..00b56c9a0 100644 --- a/src/mesh/mesh_virtual_addresses.c +++ b/src/mesh/mesh_virtual_addresses.c @@ -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;