From f0b9d65ac90444db5edd237e8498513bfeb97f49 Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Thu, 26 Sep 2024 12:18:33 -0700 Subject: [PATCH] Fix lots of Greentea test warnings (#365) --- .../source/generic/GattClientImpl.cpp | 3 ++ .../tls/tlssocket_cert_in_filesystem.cpp | 3 +- .../tests/TESTS/netsocket/udp/main.cpp | 2 +- .../TESTS/mbed_drivers/reset_reason/main.cpp | 6 ++-- drivers/usb/include/usb/internal/USBDevice.h | 2 ++ drivers/usb/source/USBDevice.cpp | 13 +++++-- .../usb/tests/TESTS/usb_device/msd/main.cpp | 29 +++++++-------- hal/tests/TESTS/mbed_hal/ospi/main.cpp | 12 +++---- .../sleep_manager_racecondition/main.cpp | 12 +++---- hal/tests/TESTS/mbed_hal/ticker/main.cpp | 2 +- .../TESTS/pin_names/arduino_uno/main.cpp | 2 +- .../TESTS/mbed_functional/callback/main.cpp | 10 +++--- platform/tests/TESTS/mbed_micro/cpp/main.cpp | 2 +- .../TESTS/mbed_platform/FileHandle/main.cpp | 2 +- .../mbed_platform/error_handling/main.cpp | 2 +- .../minimal-printf/compliance/CMakeLists.txt | 5 +++ .../minimal-printf/compliance/main.cpp | 2 +- .../TESTS/mbed_platform/wait_ns/main.cpp | 3 +- .../TESTS/mbed_rtos/heap_and_stack/main.cpp | 2 +- rtos/tests/TESTS/mbed_rtos/malloc/main.cpp | 2 +- rtos/tests/TESTS/mbed_rtos/mutex/main.cpp | 6 ---- rtos/tests/TESTS/mbed_rtos/signals/main.cpp | 36 +++++++++---------- rtos/tests/TESTS/mbed_rtos/threads/main.cpp | 4 +-- tools/cmake/toolchains/GCC_ARM.cmake | 1 + tools/python/memap/memap.py | 2 +- 25 files changed, 89 insertions(+), 76 deletions(-) diff --git a/connectivity/FEATURE_BLE/source/generic/GattClientImpl.cpp b/connectivity/FEATURE_BLE/source/generic/GattClientImpl.cpp index 338f9c59ce8..320d13c896f 100644 --- a/connectivity/FEATURE_BLE/source/generic/GattClientImpl.cpp +++ b/connectivity/FEATURE_BLE/source/generic/GattClientImpl.cpp @@ -488,6 +488,7 @@ struct GattClient::DiscoveryControlBlock final : public ProcedureControlBlock { bool done; }; +#undef TRACE_CLASS #define TRACE_CLASS "ReadControlBlock" struct GattClient::ReadControlBlock final : public ProcedureControlBlock { using ProcedureControlBlock::connection_handle; @@ -701,6 +702,7 @@ struct GattClient::ReadControlBlock final : public ProcedureControlBlock { /* * Control block for the write process */ +#undef TRACE_CLASS #define TRACE_CLASS "WriteControlBlock" struct GattClient::WriteControlBlock final : public ProcedureControlBlock { using ProcedureControlBlock::connection_handle; @@ -926,6 +928,7 @@ struct GattClient::WriteControlBlock final : public ProcedureControlBlock { /* * Control block for the descriptor discovery process */ +#undef TRACE_CLASS #define TRACE_CLASS "DescriptorDiscoveryControlBlock" struct GattClient::DescriptorDiscoveryControlBlock final : public ProcedureControlBlock { using ProcedureControlBlock::connection_handle; diff --git a/connectivity/netsocket/tests/TESTS/netsocket/tls/tlssocket_cert_in_filesystem.cpp b/connectivity/netsocket/tests/TESTS/netsocket/tls/tlssocket_cert_in_filesystem.cpp index e45fad36262..1abedc1637e 100644 --- a/connectivity/netsocket/tests/TESTS/netsocket/tls/tlssocket_cert_in_filesystem.cpp +++ b/connectivity/netsocket/tests/TESTS/netsocket/tls/tlssocket_cert_in_filesystem.cpp @@ -36,7 +36,8 @@ void TLSSOCKET_CERT_IN_FILESYSTEM() TEST_ASSERT_EQUAL(0, fs.mount(&bd)); FILE *fp = fopen("/fs/certs.pem", "wb"); - int ret = fwrite(tls_global::cert, strlen(tls_global::cert), 1, fp); + size_t ret = fwrite(tls_global::cert, strlen(tls_global::cert), 1, fp); + TEST_ASSERT_EQUAL(1, ret); fclose(fp); TLSSocket sock; diff --git a/connectivity/netsocket/tests/TESTS/netsocket/udp/main.cpp b/connectivity/netsocket/tests/TESTS/netsocket/udp/main.cpp index 5816525fa0b..67325258a39 100644 --- a/connectivity/netsocket/tests/TESTS/netsocket/udp/main.cpp +++ b/connectivity/netsocket/tests/TESTS/netsocket/udp/main.cpp @@ -73,7 +73,7 @@ static void _ifup() #if MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == MESH tr_info("Waiting for GLOBAL_UP\n"); while (net->get_connection_status() != NSAPI_STATUS_GLOBAL_UP) { - ThisThread::sleep_for(500); + ThisThread::sleep_for(500ms); } #endif tr_info("MBED: UDPClient IP address is '%s'\n", address ? address.get_ip_address() : "null"); diff --git a/drivers/tests/TESTS/mbed_drivers/reset_reason/main.cpp b/drivers/tests/TESTS/mbed_drivers/reset_reason/main.cpp index 3c9a9519e37..53632a52111 100644 --- a/drivers/tests/TESTS/mbed_drivers/reset_reason/main.cpp +++ b/drivers/tests/TESTS/mbed_drivers/reset_reason/main.cpp @@ -27,7 +27,7 @@ #if DEVICE_WATCHDOG # include "hal/watchdog_api.h" # define MSG_VALUE_WATCHDOG_STATUS 1 -# define WDG_TIMEOUT_MS 50UL +# define WDG_TIMEOUT_MS 50ms #else # define MSG_VALUE_WATCHDOG_STATUS 0 #endif @@ -60,7 +60,7 @@ * (1 start_bit + 8 data_bits + 1 stop_bit) * 128 * 1000 / 9600 = 133.3 ms. * To be on the safe side, set the wait time to 150 ms. */ -#define SERIAL_FLUSH_TIME_MS 150 +#define SERIAL_FLUSH_TIME_MS 150ms typedef enum { CMD_STATUS_CONTINUE, @@ -113,7 +113,7 @@ static cmd_status_t handle_command(const char *key, const char *value) if (strcmp(key, MSG_KEY_DEVICE_RESET) == 0 && strcmp(value, MSG_VALUE_DEVICE_RESET_WATCHDOG) == 0) { greentea_send_kv(MSG_KEY_DEVICE_RESET, MSG_VALUE_DEVICE_RESET_ACK); ThisThread::sleep_for(SERIAL_FLUSH_TIME_MS); // Wait for the serial buffers to flush. - watchdog_config_t config = { .timeout_ms = WDG_TIMEOUT_MS }; + watchdog_config_t config = { .timeout_ms = WDG_TIMEOUT_MS.count() }; if (hal_watchdog_init(&config) != WATCHDOG_STATUS_OK) { TEST_ASSERT_MESSAGE(0, "hal_watchdog_init() error."); return CMD_STATUS_ERROR; diff --git a/drivers/usb/include/usb/internal/USBDevice.h b/drivers/usb/include/usb/internal/USBDevice.h index f03f7f80956..066017ecc93 100644 --- a/drivers/usb/include/usb/internal/USBDevice.h +++ b/drivers/usb/include/usb/internal/USBDevice.h @@ -547,6 +547,8 @@ class USBDevice: public USBPhyEvents { void _complete_set_configuration(); void _complete_set_interface(); + void _clear_endpoints(); + struct endpoint_info_t { mbed::Callback callback; uint16_t max_packet_size; diff --git a/drivers/usb/source/USBDevice.cpp b/drivers/usb/source/USBDevice.cpp index 6d3cfc87d47..07493e79854 100644 --- a/drivers/usb/source/USBDevice.cpp +++ b/drivers/usb/source/USBDevice.cpp @@ -402,7 +402,7 @@ void USBDevice::_complete_set_configuration() if ((_abort_control || !success) && !configured()) { // The set configuration request was aborted or failed so // reset any endpoints which may have been added. - memset(_endpoint_info, 0, sizeof(_endpoint_info)); + _clear_endpoints(); _device.configuration = 0; _endpoint_add_remove_allowed = false; } @@ -1348,7 +1348,7 @@ USBDevice::USBDevice(USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint1 this->product_id = product_id; this->product_release = product_release; - memset(_endpoint_info, 0, sizeof(_endpoint_info)); + _clear_endpoints(); memset(&_transfer, 0, sizeof(_transfer)); _transfer.user_callback = None; @@ -1754,7 +1754,7 @@ void USBDevice::_change_state(DeviceState new_state) bool leaving_default_state = (old_state >= Default) && (new_state < Default); if (leaving_configured_state) { - memset(_endpoint_info, 0, sizeof(_endpoint_info)); + _clear_endpoints(); _device.configuration = 0; _endpoint_add_remove_allowed = false; } @@ -1771,3 +1771,10 @@ void USBDevice::_run_later(void (USBDevice::*function)()) { _post_process = function; } + +void USBDevice::_clear_endpoints() +{ + for (auto &info : _endpoint_info) { + info = endpoint_info_t{}; + } +} diff --git a/drivers/usb/tests/TESTS/usb_device/msd/main.cpp b/drivers/usb/tests/TESTS/usb_device/msd/main.cpp index 19f5f1dcaeb..c2d679cd313 100644 --- a/drivers/usb/tests/TESTS/usb_device/msd/main.cpp +++ b/drivers/usb/tests/TESTS/usb_device/msd/main.cpp @@ -217,7 +217,7 @@ void msd_process(USBMSD *msd) Semaphore proc; msd->attach(callback(run_processing, &proc)); while (!msd_process_done) { - proc.try_acquire_for(100); + proc.try_acquire_for(100ms); msd->process(); if (msd->media_removed()) { media_remove_event.release(); @@ -233,7 +233,7 @@ void msd_process(USBMSD *msd) for (int x = 0; x < 15; x++) { \ prev_read_counter = usb.get_read_counter();\ prev_program_counter = usb.get_program_counter();\ - ThisThread::sleep_for(1000);\ + ThisThread::sleep_for(1000ms);\ if ((usb.get_read_counter() == prev_read_counter) && \ (usb.get_program_counter() == prev_program_counter)) {\ break;\ @@ -241,18 +241,19 @@ void msd_process(USBMSD *msd) } -#define TEST_ASSERT_EQUAL_STRING_LOOP(expected, actual, loop_index) \ - if (strcmp(expected, actual) != 0) { \ - char str[128]; \ - sprintf(str, "expected %s was %s (loop index: %lu)", expected, actual, loop_index); \ - TEST_ASSERT_MESSAGE(false, str); \ +char testMessageBuffer[300]; + + +#define TEST_ASSERT_EQUAL_STRING_LOOP(expected, actual, loop_index) \ + if (strcmp(expected, actual) != 0) { \ + sprintf(testMessageBuffer, "expected %s was %s (loop index: %lu)", expected, actual, loop_index); \ + TEST_ASSERT_MESSAGE(false, testMessageBuffer); \ } -#define TEST_ASSERT_EQUAL_LOOP(expected, actual, loop_index) \ - if (expected != actual) { \ - char str[128]; \ - sprintf(str, "expected %d was %d (loop index: %lu)", expected, actual, loop_index); \ - TEST_ASSERT_MESSAGE(false, str); \ +#define TEST_ASSERT_EQUAL_LOOP(expected, actual, loop_index) \ + if (expected != actual) { \ + sprintf(testMessageBuffer, "expected %d was %d (loop index: %lu)", expected, actual, loop_index); \ + TEST_ASSERT_MESSAGE(false, testMessageBuffer); \ } @@ -341,7 +342,7 @@ void mount_unmount_test(BlockDevice *bd, FileSystem *fs) TEST_ASSERT_EQUAL_STRING_LOOP("passed", _key, i); // wait for unmount event (set 10s timeout) - media_remove_event.try_acquire_for(10000); + media_remove_event.try_acquire_for(10s); if (!usb.media_removed()) { TEST_ASSERT_EQUAL_LOOP(true, usb.media_removed(), i); } @@ -436,7 +437,7 @@ void mount_unmount_and_data_test(BlockDevice *bd, FileSystem *fs) TEST_ASSERT_EQUAL_STRING("passed", _key); do { - ThisThread::sleep_for(1); + ThisThread::sleep_for(1ms); } while (test_files_exist(fs_root)); TEST_ASSERT_EQUAL(false, test_files_exist(fs_root)); diff --git a/hal/tests/TESTS/mbed_hal/ospi/main.cpp b/hal/tests/TESTS/mbed_hal/ospi/main.cpp index ab966087ea8..61810584c1e 100644 --- a/hal/tests/TESTS/mbed_hal/ospi/main.cpp +++ b/hal/tests/TESTS/mbed_hal/ospi/main.cpp @@ -115,7 +115,7 @@ static void _ospi_write_read_test(Ospi &ospi, ospi_bus_width_t write_inst_width, ospi_status_t ret = OSPI_STATUS_OK; Timer timer; - int erase_time = 0, write_time = 0, read_time = 0; + std::chrono::microseconds erase_time{}, write_time{}, read_time{}; size_t buf_len = data_size; for (uint32_t tc = 0; tc < test_count; tc++) { @@ -136,7 +136,7 @@ static void _ospi_write_read_test(Ospi &ospi, ospi_bus_width_t write_inst_width, WAIT_FOR(SECTOR_ERASE_MAX_TIME, ospi); timer.stop(); - erase_time = timer.read_us(); + erase_time = timer.elapsed_time(); // switching to extended-SPI/DPI/QPI mode here for write operation // for DPI/QPI ospi.cmd is automatically switched to 2_2_2/4_4_4 mode @@ -167,7 +167,7 @@ static void _ospi_write_read_test(Ospi &ospi, ospi_bus_width_t write_inst_width, WAIT_FOR(PAGE_PROG_MAX_TIME, ospi); timer.stop(); - write_time = timer.read_us(); + write_time = timer.elapsed_time(); } // switching back to single channel SPI @@ -193,7 +193,7 @@ static void _ospi_write_read_test(Ospi &ospi, ospi_bus_width_t write_inst_width, TEST_ASSERT_EQUAL(read_size, buf_len); timer.stop(); - read_time = timer.read_us(); + read_time = timer.elapsed_time(); } ospi.cmd.set_dummy_cycles(0); @@ -211,13 +211,13 @@ static void _ospi_write_read_test(Ospi &ospi, ospi_bus_width_t write_inst_width, if (tx_buf[i] != rx_buf[i]) { log_data("tx data", tx_buf, data_size); log_data("rx data", rx_buf, data_size); - utest_printf("erase/write/read time: %d/%d/%d [us]\r\n", erase_time, write_time, read_time); + utest_printf("erase/write/read time: %" PRIi64 "/%" PRIi64 "/%" PRIi64 " [us]\r\n", erase_time.count(), write_time.count(), read_time.count()); TEST_ASSERT_EQUAL(tx_buf[i], rx_buf[i]); } } #ifdef OSPI_TEST_LOG_FLASH_TIME - utest_printf("erase/write/read time: %d/%d/%d [us]\r\n", erase_time, write_time, read_time); + utest_printf("erase/write/read time: %" PRIi64 "/%" PRIi64 "/%" PRIi64 " [us]\r\n", erase_time.count(), write_time.count(), read_time.count()); #endif #ifdef OSPI_TEST_LOG_DATA diff --git a/hal/tests/TESTS/mbed_hal/sleep_manager_racecondition/main.cpp b/hal/tests/TESTS/mbed_hal/sleep_manager_racecondition/main.cpp index 034b41cbe42..5d2773f22e7 100644 --- a/hal/tests/TESTS/mbed_hal/sleep_manager_racecondition/main.cpp +++ b/hal/tests/TESTS/mbed_hal/sleep_manager_racecondition/main.cpp @@ -32,7 +32,7 @@ void sleep_manager_locking_thread_test() { for (uint32_t i = 0; i < 100; i++) { sleep_manager_lock_deep_sleep(); - ThisThread::sleep_for(25); + ThisThread::sleep_for(25ms); sleep_manager_unlock_deep_sleep(); } } @@ -45,7 +45,7 @@ void sleep_manager_multithread_test() Thread t2(osPriorityNormal, TEST_STACK_SIZE); t1.start(callback(cb)); - ThisThread::sleep_for(25); + ThisThread::sleep_for(25ms); t2.start(callback(cb)); // Wait for the threads to finish @@ -70,13 +70,13 @@ void sleep_manager_irq_test() Ticker ticker1; Timer timer; - ticker1.attach_us(&sleep_manager_locking_irq_test, 1000); + ticker1.attach(&sleep_manager_locking_irq_test, 1ms); // run this for 10 seconds timer.start(); - int start = timer.read(); - int end = start + 10; - while (timer.read() < end) { + const auto start = timer.elapsed_time(); + const auto end = start + 10s; + while (timer.elapsed_time() < end) { sleep_manager_locking_irq_test(); } timer.stop(); diff --git a/hal/tests/TESTS/mbed_hal/ticker/main.cpp b/hal/tests/TESTS/mbed_hal/ticker/main.cpp index 778b4e83fbd..e35fed1411f 100644 --- a/hal/tests/TESTS/mbed_hal/ticker/main.cpp +++ b/hal/tests/TESTS/mbed_hal/ticker/main.cpp @@ -2251,7 +2251,7 @@ static void test_match_interval_passed_table() {0xfffffffe, 0xffffffff, 0xffffffff, true}, {0x00000000, 0xffffffff, 0xffffffff, true}, }; - for (int i = 0; i < MBED_ARRAY_SIZE(test_values); i++) { + for (size_t i = 0; i < MBED_ARRAY_SIZE(test_values); i++) { const uint32_t prev = test_values[i].prev; const uint32_t cur = test_values[i].cur; const uint32_t match = test_values[i].match; diff --git a/hal/tests/TESTS/pin_names/arduino_uno/main.cpp b/hal/tests/TESTS/pin_names/arduino_uno/main.cpp index 8022d507bc9..53bd25e1dd8 100644 --- a/hal/tests/TESTS/pin_names/arduino_uno/main.cpp +++ b/hal/tests/TESTS/pin_names/arduino_uno/main.cpp @@ -154,7 +154,7 @@ void UART_test() } // 3. check if Arduino_uno pins are not using the same UART instance as console - int console_uart = pinmap_peripheral(CONSOLE_TX, serial_tx_pinmap()); + uint32_t console_uart = pinmap_peripheral(CONSOLE_TX, serial_tx_pinmap()); if (console_uart != 0) { TEST_ASSERT_NOT_EQUAL(console_uart, pinmap_peripheral(TX_pin, serial_tx_pinmap())); } diff --git a/platform/tests/TESTS/mbed_functional/callback/main.cpp b/platform/tests/TESTS/mbed_functional/callback/main.cpp index 4b8b7fe50eb..ac33d14bf46 100644 --- a/platform/tests/TESTS/mbed_functional/callback/main.cpp +++ b/platform/tests/TESTS/mbed_functional/callback/main.cpp @@ -755,11 +755,6 @@ static int construct_count; static int destruct_count; static int copy_count; -static int live_count() -{ - return construct_count - destruct_count; -} - struct FunctionObject { FunctionObject(int n) : val(n) { @@ -824,6 +819,11 @@ void test_trivial() } #if MBED_CONF_PLATFORM_CALLBACK_NONTRIVIAL +static int live_count() +{ + return construct_count - destruct_count; +} + void test_nontrivial() { { diff --git a/platform/tests/TESTS/mbed_micro/cpp/main.cpp b/platform/tests/TESTS/mbed_micro/cpp/main.cpp index af956a333a8..6d766d5996e 100644 --- a/platform/tests/TESTS/mbed_micro/cpp/main.cpp +++ b/platform/tests/TESTS/mbed_micro/cpp/main.cpp @@ -30,7 +30,7 @@ class Test { private: const char *name; - const int pattern; + const uint32_t pattern; public: Test(const char *_name, bool print_message = true) : name(_name), pattern(PATTERN_CHECK_VALUE) diff --git a/platform/tests/TESTS/mbed_platform/FileHandle/main.cpp b/platform/tests/TESTS/mbed_platform/FileHandle/main.cpp index 4efd8f4a55c..256f2847e0c 100644 --- a/platform/tests/TESTS/mbed_platform/FileHandle/main.cpp +++ b/platform/tests/TESTS/mbed_platform/FileHandle/main.cpp @@ -101,7 +101,7 @@ void test_fwrite_fread() std::clearerr(file); // ARMCC/IAR returns 0 here instead of number of elements successfully written !!! - TEST_ASSERT_TRUE(write_ret >= 0 && write_ret <= (str2_size - 1)); + TEST_ASSERT_TRUE(write_ret <= (str2_size - 1)); // write 3; expected written 0 TestFile::resetFunctionCallHistory(); diff --git a/platform/tests/TESTS/mbed_platform/error_handling/main.cpp b/platform/tests/TESTS/mbed_platform/error_handling/main.cpp index cb97eb0c729..ddb81a182ef 100644 --- a/platform/tests/TESTS/mbed_platform/error_handling/main.cpp +++ b/platform/tests/TESTS/mbed_platform/error_handling/main.cpp @@ -267,7 +267,7 @@ void test_error_hook() } MBED_WARNING1(MBED_ERROR_INVALID_ARGUMENT, "Test for error hook", 1234); - bool acquired = callback_sem.try_acquire_for(5000); + bool acquired = callback_sem.try_acquire_for(5s); TEST_ASSERT(acquired); } diff --git a/platform/tests/TESTS/mbed_platform/minimal-printf/compliance/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/minimal-printf/compliance/CMakeLists.txt index c431a112f05..da048f8eda9 100644 --- a/platform/tests/TESTS/mbed_platform/minimal-printf/compliance/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/minimal-printf/compliance/CMakeLists.txt @@ -12,3 +12,8 @@ mbed_greentea_add_test( main.cpp mbed_printf.c ) + +# Disable "snprintf into buffer of size x" warnings +target_compile_options(test-mbed-platform-minimal-printf-compliance + PRIVATE + -Wno-format-truncation) \ No newline at end of file diff --git a/platform/tests/TESTS/mbed_platform/minimal-printf/compliance/main.cpp b/platform/tests/TESTS/mbed_platform/minimal-printf/compliance/main.cpp index 1faf1dd3b86..ea28cb31a34 100644 --- a/platform/tests/TESTS/mbed_platform/minimal-printf/compliance/main.cpp +++ b/platform/tests/TESTS/mbed_platform/minimal-printf/compliance/main.cpp @@ -126,7 +126,7 @@ static int make_test_string( ) { char *exp_str = &expected_string[0]; - int str_length = 0; + size_t str_length = 0; memset(exp_str, 0, MAX_STRING_SIZE); if (prefix) { str_length = strlen(prefix); diff --git a/platform/tests/TESTS/mbed_platform/wait_ns/main.cpp b/platform/tests/TESTS/mbed_platform/wait_ns/main.cpp index 9d8743b0338..600c2f4dc48 100644 --- a/platform/tests/TESTS/mbed_platform/wait_ns/main.cpp +++ b/platform/tests/TESTS/mbed_platform/wait_ns/main.cpp @@ -77,7 +77,8 @@ void test_wait_ns_time_measurement() timer.stop(); /* Check results - wait_val_us us have elapsed. */ - TEST_ASSERT_FLOAT_WITHIN(DELTA * wait_val_s, MIDPOINT * wait_val_s, timer.read()); + TEST_ASSERT_FLOAT_WITHIN(DELTA * wait_val_s, MIDPOINT * wait_val_s, + std::chrono::duration(timer.elapsed_time()).count()); } utest::v1::status_t test_setup(const size_t number_of_cases) diff --git a/rtos/tests/TESTS/mbed_rtos/heap_and_stack/main.cpp b/rtos/tests/TESTS/mbed_rtos/heap_and_stack/main.cpp index e4c88a3c0f3..1d1d2bc5488 100644 --- a/rtos/tests/TESTS/mbed_rtos/heap_and_stack/main.cpp +++ b/rtos/tests/TESTS/mbed_rtos/heap_and_stack/main.cpp @@ -260,7 +260,7 @@ void test_heap_allocation_free(void) check_and_free_heap(head, max_allocation_size); // Force a task switch so a stack check is performed - ThisThread::sleep_for(10); + ThisThread::sleep_for(10s); printf("Total size dynamically allocated: %luB\n", max_allocation_size); } diff --git a/rtos/tests/TESTS/mbed_rtos/malloc/main.cpp b/rtos/tests/TESTS/mbed_rtos/malloc/main.cpp index a470547e2d7..7b02e811bcd 100644 --- a/rtos/tests/TESTS/mbed_rtos/malloc/main.cpp +++ b/rtos/tests/TESTS/mbed_rtos/malloc/main.cpp @@ -89,7 +89,7 @@ void test_multithread_allocation(void) // Give the test time to run while (test_time--) { - ThisThread::sleep_for(1000); + ThisThread::sleep_for(1s); } // Join and delete all threads diff --git a/rtos/tests/TESTS/mbed_rtos/mutex/main.cpp b/rtos/tests/TESTS/mbed_rtos/mutex/main.cpp index 52705edf910..7afadc3d65d 100644 --- a/rtos/tests/TESTS/mbed_rtos/mutex/main.cpp +++ b/rtos/tests/TESTS/mbed_rtos/mutex/main.cpp @@ -58,7 +58,6 @@ volatile bool mutex_defect = false; bool manipulate_protected_zone(const Kernel::Clock::duration thread_delay) { bool result = true; - osStatus stat; stdio_mutex.lock(); @@ -128,7 +127,6 @@ void test_multiple_threads(void) void test_dual_thread_nolock_lock_thread(Mutex *mutex) { - osStatus stat; mutex->lock(); mutex->unlock(); @@ -184,7 +182,6 @@ void test_dual_thread_lock_unlock_thread(Mutex *mutex) void test_dual_thread_lock_unlock(void) { Mutex mutex; - osStatus stat; Thread thread(osPriorityNormal, TEST_STACK_SIZE); mutex.lock(); @@ -230,7 +227,6 @@ template void test_dual_thread_lock(void) { Mutex mutex; - osStatus stat; Thread thread(osPriorityNormal, TEST_STACK_SIZE); mutex.lock(); @@ -251,7 +247,6 @@ void test_dual_thread_lock(void) void test_single_thread_lock_recursive(void) { Mutex mutex; - osStatus stat; mutex.lock(); @@ -287,7 +282,6 @@ void test_single_thread_trylock(void) void test_single_thread_lock(void) { Mutex mutex; - osStatus stat; mutex.lock(); diff --git a/rtos/tests/TESTS/mbed_rtos/signals/main.cpp b/rtos/tests/TESTS/mbed_rtos/signals/main.cpp index 0a4d7caef59..2da8b68932e 100644 --- a/rtos/tests/TESTS/mbed_rtos/signals/main.cpp +++ b/rtos/tests/TESTS/mbed_rtos/signals/main.cpp @@ -35,7 +35,7 @@ using utest::v1::Case; template void run_signal_wait(void) { - uint32_t ret = ThisThread::flags_wait_all_for(signals, timeout); + uint32_t ret = ThisThread::flags_wait_all_for(signals, std::chrono::milliseconds(timeout)); TEST_ASSERT_EQUAL(test_val, ret); } @@ -64,7 +64,7 @@ void test_clear_no_signals_with_ticker(void) { Ticker t; osThreadFlagsSet(ThisThread::get_id(), ALL_SIGNALS); - t.attach_us([&] { run_multiple_wait_clear(NO_SIGNALS, NO_SIGNALS, ALL_SIGNALS, ALL_SIGNALS); }, 3000); + t.attach([&] { run_multiple_wait_clear(NO_SIGNALS, NO_SIGNALS, ALL_SIGNALS, ALL_SIGNALS); }, 3ms); } /** Validate all flags_clr clears the signal in one shot @@ -77,7 +77,7 @@ void test_clear_all_with_ticker(void) { Ticker t; osThreadFlagsSet(ThisThread::get_id(), ALL_SIGNALS); - t.attach_us([&] { run_multiple_wait_clear(ALL_SIGNALS, NO_SIGNALS, ALL_SIGNALS, NO_SIGNALS); }, 3000); + t.attach([&] { run_multiple_wait_clear(ALL_SIGNALS, NO_SIGNALS, ALL_SIGNALS, NO_SIGNALS); }, 3ms); } /** Validate if any signals are set on ticker callback @@ -89,7 +89,7 @@ void test_clear_all_with_ticker(void) void test_init_state_with_ticker(void) { Ticker t; - t.attach_us(callback(run_clear), 3000); + t.attach(callback(run_clear), 3ms); } /** Validate signal_wait return status if timeout specified @@ -102,7 +102,7 @@ template void test_wait_timeout_with_ticker(void) { Ticker t; - t.attach_us(callback(run_signal_wait), 3000); + t.attach(callback(run_signal_wait), 3ms); } void run_release_wait_signal_wait_callback() @@ -121,21 +121,20 @@ void run_release_wait_signal_wait_callback() void test_wait_all_already_set_with_ticker(void) { Ticker t; - t.attach_us([&] { run_release_wait_signal_wait_callback(); }, 3000); - uint32_t ret = ThisThread::flags_wait_all_for(ALL_SIGNALS, osWaitForever); + t.attach([&] { run_release_wait_signal_wait_callback(); }, 3ms); + uint32_t ret = ThisThread::flags_wait_all_for(ALL_SIGNALS, Kernel::wait_for_u32_forever); TEST_ASSERT_EQUAL(ALL_SIGNALS, ret); } void run_release_wait_signal_set_callback(int32_t signal, osThreadId_t id) { - int32_t ret; if (signal == 0) { for (int i = 0; i < 16; i++) { int32_t signal = 1 << i; - ret = osThreadFlagsSet(id, signal); + osThreadFlagsSet(id, signal); } } else { - ret = osThreadFlagsSet(id, signal); + osThreadFlagsSet(id, signal); } } @@ -153,8 +152,8 @@ void test_wait_all_loop_with_ticker(void) Semaphore sem(0, 1); Ticker t; osThreadId_t id = ThisThread::get_id(); - t.attach_us([&] { run_release_wait_signal_set_callback(0, id); }, 4000); - ret = ThisThread::flags_wait_all_for((ALL_SIGNALS & 0xFFFF), osWaitForever, true); + t.attach([&] { run_release_wait_signal_set_callback(0, id); }, 4ms); + ret = ThisThread::flags_wait_all_for((ALL_SIGNALS & 0xFFFF), Kernel::wait_for_u32_forever, true); TEST_ASSERT_EQUAL((ALL_SIGNALS & 0xFFFF), ret); } @@ -172,10 +171,10 @@ void test_set_double_with_ticker(void) int32_t ret; Ticker t1, t2; osThreadId_t id = ThisThread::get_id(); - t1.attach_us([&] { run_release_wait_signal_set_callback(SIGNAL2, id); }, 3000); - t2.attach_us([&] { run_release_wait_signal_set_callback(SIGNAL1 | SIGNAL2 | SIGNAL3, id); }, 4000); + t1.attach([&] { run_release_wait_signal_set_callback(SIGNAL2, id); }, 3ms); + t2.attach([&] { run_release_wait_signal_set_callback(SIGNAL1 | SIGNAL2 | SIGNAL3, id); }, 4ms); - ret = ThisThread::flags_wait_all_for((SIGNAL1 | SIGNAL2 | SIGNAL3), osWaitForever, true); + ret = ThisThread::flags_wait_all_for((SIGNAL1 | SIGNAL2 | SIGNAL3), Kernel::wait_for_u32_forever, true); TEST_ASSERT_EQUAL(SIGNAL1 | SIGNAL2 | SIGNAL3, ret); } @@ -197,7 +196,7 @@ template void run_release_signal_wait(Semaphore *sem) { sem->release(); - uint32_t ret = ThisThread::flags_wait_all_for(signals, timeout); + uint32_t ret = ThisThread::flags_wait_all_for(signals, std::chrono::milliseconds(timeout)); TEST_ASSERT_EQUAL(test_val, ret); } @@ -206,7 +205,7 @@ void run_release_wait_signal_wait(Sync *sync) { sync->sem_parent.release(); sync->sem_child.acquire(); - uint32_t ret = ThisThread::flags_wait_all_for(signals, timeout); + uint32_t ret = ThisThread::flags_wait_all_for(signals, std::chrono::milliseconds(timeout)); TEST_ASSERT_EQUAL(test_val, ret); } @@ -314,7 +313,6 @@ void test_set_all(void) */ void test_set_prohibited(void) { - int32_t ret; Semaphore sem_parent(0, 1); Semaphore sem_child(0, 1); Sync sync(sem_parent, sem_child); @@ -326,7 +324,7 @@ void test_set_prohibited(void) t.flags_set(ALL_SIGNALS); #if !MBED_TRAP_ERRORS_ENABLED - ret = t.flags_set(PROHIBITED_SIGNAL); + int32_t ret = t.flags_set(PROHIBITED_SIGNAL); TEST_ASSERT_EQUAL(osErrorParameter, ret); #endif diff --git a/rtos/tests/TESTS/mbed_rtos/threads/main.cpp b/rtos/tests/TESTS/mbed_rtos/threads/main.cpp index 3b27ab0dd2a..e2b26e43325 100644 --- a/rtos/tests/TESTS/mbed_rtos/threads/main.cpp +++ b/rtos/tests/TESTS/mbed_rtos/threads/main.cpp @@ -370,7 +370,7 @@ void test_thread_flags_set() Thread::State state = t_wait.get_state(); TEST_ASSERT_EQUAL(Thread::WaitingThreadFlag, state); - int32_t res = t_wait.flags_set(S); + t_wait.flags_set(S); t_wait.join(); } @@ -741,7 +741,7 @@ void test_msg_put() /** Utility function that places some date on the stack */ void use_some_stack() { - volatile uint32_t stack_filler[10] = {0xDEADBEEF}; + [[maybe_unused]] volatile uint32_t stack_filler[10] = {0xDEADBEEF}; } /** Testing thread with external stack memory diff --git a/tools/cmake/toolchains/GCC_ARM.cmake b/tools/cmake/toolchains/GCC_ARM.cmake index 2dae4d4546a..5341f910934 100644 --- a/tools/cmake/toolchains/GCC_ARM.cmake +++ b/tools/cmake/toolchains/GCC_ARM.cmake @@ -34,6 +34,7 @@ list(APPEND common_options "-Wextra" "-Wno-unused-parameter" "-Wno-missing-field-initializers" + "-Wno-psabi" # Disable "parameter passing changed in GCC 7.1" warning "-fmessage-length=0" "-fno-exceptions" "-ffunction-sections" diff --git a/tools/python/memap/memap.py b/tools/python/memap/memap.py index 100db9d5bb7..7dbf2926e71 100644 --- a/tools/python/memap/memap.py +++ b/tools/python/memap/memap.py @@ -158,7 +158,7 @@ def add_symbol(self, symbol_name: str, object_name: str, start_addr: int, size: # Don't count the heap output section for memory bank size tracking, because the linker scripts (almost always?) # configure that section to expand to fill the remaining amount of space - if section not in {".heap"}: + if section not in {".heap", ".heap_0"}: self._add_symbol_to_memory_banks(symbol_name, start_addr, size) if vma_lma_offset != 0: self._add_symbol_to_memory_banks(f"", start_addr + vma_lma_offset, size)