diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index be726d163..a4fa16a8c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,7 +20,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [macos-latest, windows-latest, ubuntu-latest] + os: [macos-latest, windows-latest, ubuntu-22.04] steps: - name: Check out Luos repository uses: actions/checkout@v3 @@ -44,26 +44,26 @@ jobs: # Run Unit tests platformio test -vvv - - if: matrix.os == 'ubuntu-latest' + - if: matrix.os == 'ubuntu-22.04' run: | sudo apt-get install -y lcov lcov -d .pio/build/native/ -c -o lcov.info - lcov --remove lcov.info '*/usr/*' '*/Platforms/*' '*/bootloader/*' '*/.pio/*' '*/HAL/*' '*/test/*' '*/network/*' -o lcov.info + lcov --remove lcov.info '*/usr/*' '*/Platforms/*' '*/bootloader/*' '*/.pio/*' '*/HAL/*' '*/test/*' '*/network/*' -o lcov.info --ignore-errors empty - - if: matrix.os == 'ubuntu-latest' + - if: matrix.os == 'ubuntu-22.04' name: Coveralls uses: coverallsapp/github-action@v2 unit-tests: name: Unit tests needs: tests-run - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - run: echo "Tests succeed!" code-format: name: Code format - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: Check out Luos repository uses: actions/checkout@v3 @@ -89,8 +89,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - project_folders: - [ + project_folders: [ examples/projects/l0, examples/projects/Arduino, examples/projects/NUCLEO-L432KC, @@ -106,7 +105,7 @@ jobs: # examples/projects/ESP32, examples/projects/native, ] - os: [macos-latest, windows-latest, ubuntu-latest] + os: [macos-latest, windows-latest, ubuntu-22.04] steps: - name: Check out Luos repository @@ -152,6 +151,6 @@ jobs: build-success: name: Build success needs: examples-build - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - run: echo "Build succeed!" diff --git a/engine/core/src/routing_table.c b/engine/core/src/routing_table.c index 5af94fb67..7683ff90f 100644 --- a/engine/core/src/routing_table.c +++ b/engine/core/src/routing_table.c @@ -185,28 +185,18 @@ static void RoutingTB_AddNumToAlias(char *alias, uint8_t num) uint8_t intsize = 1; if (num > 9) { - // The string size of num is 2 + // The string size of num have a size of 2 intsize = 2; } - if (num > 99) // only 2 digit are alowed when add alias number - { - // This is probably a mistake, put an error into the alias - memset(alias, 0, MAX_ALIAS_SIZE - 1); - memcpy(alias, "error", strlen("error")); - return; - } + LUOS_ASSERT(num < 100); // only 2 digit are alowed when add alias number // Change size to fit into 15 characters if (strlen(alias) > (MAX_ALIAS_SIZE - 1 - intsize)) { alias[(MAX_ALIAS_SIZE - 1 - intsize)] = '\0'; } - else - { - alias[strlen(alias)] = '\0'; - } // Add a number at the end of the alias - char *alias_copy = alias; - sprintf(alias, "%s%d", alias_copy, num); + char *end_pointer = &alias[strlen(alias)]; + sprintf(end_pointer, "%d", num); } /****************************************************************************** diff --git a/test/tests_core/test_routing_table/main.c b/test/tests_core/test_routing_table/main.c index d6c1b34de..031cdfe5b 100644 --- a/test/tests_core/test_routing_table/main.c +++ b/test/tests_core/test_routing_table/main.c @@ -197,6 +197,20 @@ void unittest_RoutingTB_AddNumToAlias(void) } TEST_ASSERT_TRUE(IS_ASSERT()); END_TRY; + TRY + { + char alias[MAX_ALIAS_SIZE] = "Dummy_App"; + RoutingTB_AddNumToAlias(alias, 100); + } + TEST_ASSERT_TRUE(IS_ASSERT()); + END_TRY; + TRY + { + char alias[MAX_ALIAS_SIZE] = "Dummy_App"; + RoutingTB_AddNumToAlias(alias, 101); + } + TEST_ASSERT_TRUE(IS_ASSERT()); + END_TRY; } NEW_TEST_CASE("check RoutingTB_AddNumToAlias return value");