diff --git a/.github/workflows/CLA.yml b/.github/workflows/CLA.yml index 504347bc5..994003d67 100644 --- a/.github/workflows/CLA.yml +++ b/.github/workflows/CLA.yml @@ -7,7 +7,7 @@ on: jobs: CLAssistant: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: "CLA Assistant" if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target' diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 37fb9fbb7..8e5748625 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -34,7 +34,7 @@ on: jobs: make_android: # The type of runner that the job will run on - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 strategy: fail-fast: false matrix: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cb7e72b49..6c006b6f8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,7 @@ on: jobs: make_linux_java: # The type of runner that the job will run on - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 strategy: fail-fast: false matrix: @@ -62,7 +62,7 @@ jobs: JUNIT4=./junit-4.13.jar HAMCREST_CORE=./hamcrest-core-1.3.jar ./run-unit-tests.sh ctt_build: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Checkout repository uses: actions/checkout@v4 @@ -76,7 +76,7 @@ jobs: build_esp32: # The type of runner that the job will run on - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 strategy: fail-fast: false matrix: diff --git a/.github/workflows/check-format.yml b/.github/workflows/check-format.yml index 1004fa60b..ae9f1180d 100644 --- a/.github/workflows/check-format.yml +++ b/.github/workflows/check-format.yml @@ -22,7 +22,7 @@ jobs: # This workflow contains a single job called "check-formatting" check-formatting: # The type of runner that the job will run on - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 # Steps represent a sequence of tasks that will be executed as part of the job steps: @@ -32,14 +32,14 @@ jobs: with: submodules: "true" - - name: Install clang-format-17 + - name: Install clang-format-19 run: | sudo apt-get update -y sudo apt-get install curl curl -sL https://apt.llvm.org/llvm.sh > llvm.sh chmod u+x llvm.sh - sudo ./llvm.sh 17 - sudo apt-get install clang-format-17 + sudo ./llvm.sh 19 + sudo apt-get install clang-format-19 # Runs a set of commands using the runners shell - name: format-check diff --git a/.github/workflows/cmake-windows.yml b/.github/workflows/cmake-windows.yml index 78c6c89cb..e4ae80118 100644 --- a/.github/workflows/cmake-windows.yml +++ b/.github/workflows/cmake-windows.yml @@ -153,7 +153,8 @@ jobs: - name: Clang64 msystem: CLANG64 build_type: Debug - build_args: "-DOC_ASAN_ENABLED=ON -DOC_UBSAN_ENABLED=ON" + # TODO: remove once GTest library is updated to version with newer CMake + build_args: "-DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DOC_ASAN_ENABLED=ON -DOC_UBSAN_ENABLED=ON" cc: clang cxx: clang++ build_testing: ON diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index 805f0474d..31d05538e 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -7,7 +7,7 @@ on: jobs: coverity: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/ctt-bot.yml b/.github/workflows/ctt-bot.yml index 5e7bdecdb..ced03ca02 100644 --- a/.github/workflows/ctt-bot.yml +++ b/.github/workflows/ctt-bot.yml @@ -8,7 +8,7 @@ jobs: info-comment: name: Info comment if: github.event.action == 'opened' - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: Generate token id: generate_token @@ -33,7 +33,7 @@ jobs: remove-label: name: Remove label if: github.event.action == 'synchronize' - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: Generate token id: generate_token diff --git a/.github/workflows/docker-build-publish-with-cfg.yml b/.github/workflows/docker-build-publish-with-cfg.yml index dceaf61b4..4b2a7215c 100644 --- a/.github/workflows/docker-build-publish-with-cfg.yml +++ b/.github/workflows/docker-build-publish-with-cfg.yml @@ -30,7 +30,7 @@ env: jobs: build-and-push-image: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 permissions: contents: read packages: write diff --git a/.github/workflows/doxygen-publish.yml b/.github/workflows/doxygen-publish.yml index 9ffac85fe..da5025c47 100644 --- a/.github/workflows/doxygen-publish.yml +++ b/.github/workflows/doxygen-publish.yml @@ -16,7 +16,7 @@ on: jobs: doxygen-publish: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 if: (github.event_name == 'pull_request' && github.event.pull_request.merged) || github.event_name == 'workflow_dispatch' steps: - name: Checkout repository diff --git a/.github/workflows/doxygen.yml b/.github/workflows/doxygen.yml index b14df234d..d824f17da 100644 --- a/.github/workflows/doxygen.yml +++ b/.github/workflows/doxygen.yml @@ -15,7 +15,7 @@ on: jobs: doxygen: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Checkout repository uses: actions/checkout@v4 diff --git a/.github/workflows/ghcr-check.yml b/.github/workflows/ghcr-check.yml index 1955b10a9..b97b33a98 100644 --- a/.github/workflows/ghcr-check.yml +++ b/.github/workflows/ghcr-check.yml @@ -21,7 +21,7 @@ on: jobs: check_package: name: Check released packages - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/ghcr-cleanup.yml b/.github/workflows/ghcr-cleanup.yml index d27b7bf23..bc1b1eb2f 100644 --- a/.github/workflows/ghcr-cleanup.yml +++ b/.github/workflows/ghcr-cleanup.yml @@ -10,7 +10,7 @@ jobs: pull-request-ghcr-cleanup: if: ${{ github.event_name == 'pull_request' }} name: Delete images related to closed PR - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: Delete images related to closed PR (1) id: run-pr-1 @@ -52,7 +52,7 @@ jobs: nightly-ghcr-cleanup: if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} name: Delete stale or untagged images - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: Checkout local actions uses: actions/checkout@v4 diff --git a/.github/workflows/plgd-device-test-with-cfg.yml b/.github/workflows/plgd-device-test-with-cfg.yml index 48f7605f4..ac804dfe4 100644 --- a/.github/workflows/plgd-device-test-with-cfg.yml +++ b/.github/workflows/plgd-device-test-with-cfg.yml @@ -51,7 +51,7 @@ env: jobs: plgd-device-test-with-cfg: if: ${{ !inputs.skip }} - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Checkout repository diff --git a/.github/workflows/plgd-dps-test-with-cfg.yml b/.github/workflows/plgd-dps-test-with-cfg.yml index d9748e00d..151d4c060 100644 --- a/.github/workflows/plgd-dps-test-with-cfg.yml +++ b/.github/workflows/plgd-dps-test-with-cfg.yml @@ -43,7 +43,7 @@ env: jobs: plgd-hub-test-with-cfg: if: ${{ !inputs.skip }} - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Checkout repository uses: actions/checkout@v4 diff --git a/.github/workflows/plgd-hub-test-with-cfg.yml b/.github/workflows/plgd-hub-test-with-cfg.yml index 327b7a3a8..9d3574ead 100644 --- a/.github/workflows/plgd-hub-test-with-cfg.yml +++ b/.github/workflows/plgd-hub-test-with-cfg.yml @@ -68,7 +68,7 @@ env: jobs: plgd-hub-test-with-cfg: if: ${{ !inputs.skip }} - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Checkout repository uses: actions/checkout@v4 diff --git a/.github/workflows/pr-format.yml b/.github/workflows/pr-format.yml index 623482fd8..94f4fde6a 100644 --- a/.github/workflows/pr-format.yml +++ b/.github/workflows/pr-format.yml @@ -11,7 +11,7 @@ jobs: format: name: Format the pull request if the '~format' comment is made if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '~format') }} - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - uses: octokit/graphql-action@v2.x id: get_branch @@ -50,8 +50,8 @@ jobs: sudo apt-get install curl curl -sL https://apt.llvm.org/llvm.sh > llvm.sh chmod u+x llvm.sh - sudo ./llvm.sh 17 - sudo apt-get install clang-format-17 + sudo ./llvm.sh 19 + sudo apt-get install clang-format-19 cmake -S ${{ github.workspace }}/iotivity-lite -B ${{ github.workspace }}/build-format make -C ${{ github.workspace }}/build-format format diff --git a/.github/workflows/sonar-cloud-analysis.yml b/.github/workflows/sonar-cloud-analysis.yml index d0607d783..4dbaa2c9e 100644 --- a/.github/workflows/sonar-cloud-analysis.yml +++ b/.github/workflows/sonar-cloud-analysis.yml @@ -96,7 +96,7 @@ jobs: # don't run for forks if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) name: Sonar Cloud scan - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 env: BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed needs: [unit-tests, plgd-device-tests, plgd-hub-tests, plgd-dps-tests] @@ -131,12 +131,13 @@ jobs: run: | sudo apt-get update -y sudo apt-get install -y gcovr + gcovr --version - name: Create single coverage file in sonarqube format run: | cd tools # ls -lR . - gcovr --add-tracefile "coverage/*coverage*.json" --sonarqube --output "coverage.xml" --verbose + gcovr --merge-mode-functions=separate --add-tracefile "coverage/*coverage*.json" --sonarqube --output "coverage.xml" --verbose - name: Run sonar-scanner env: diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index f62c5e681..5c0bad95f 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -23,7 +23,7 @@ jobs: - build_args: -DPLGD_DEV_TIME_ENABLED=ON -DPLGD_DEV_DEVICE_PROVISIONING_ENABLED=ON - build_args: -DOC_DYNAMIC_ALLOCATION_ENABLED=OFF -DOC_PUSH_ENABLED=OFF -DOC_JSON_ENCODER_ENABLED=OFF -DOC_DEBUG_ENABLED=ON - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Checkout repository @@ -31,17 +31,17 @@ jobs: with: submodules: "true" - - name: Install clang-17 and clang-tidy-17 + - name: Install clang-19 and clang-tidy-19 run: | sudo apt-get update -y sudo apt-get install curl curl -sL https://apt.llvm.org/llvm.sh > llvm.sh chmod u+x llvm.sh - sudo ./llvm.sh 17 - sudo apt-get install clang-17 clang-tidy-17 - sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-17 200 - sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-17 200 - sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-17 200 + sudo ./llvm.sh 19 + sudo apt-get install clang-19 clang-tidy-19 + sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-19 200 + sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-19 200 + sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-19 200 update-alternatives --verbose --display clang - name: Build with clang and analyze with clang-tidy diff --git a/.github/workflows/unit-test-with-cfg.yml b/.github/workflows/unit-test-with-cfg.yml index 886d82a88..e3b882bbc 100644 --- a/.github/workflows/unit-test-with-cfg.yml +++ b/.github/workflows/unit-test-with-cfg.yml @@ -37,7 +37,7 @@ on: default: false jobs: unit-test-with-cfg: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Checkout repository @@ -57,17 +57,17 @@ jobs: repository: wolfcw/libfaketime path: libfaketime - - name: Install clang-17 + - name: Install clang-19 if: ${{ inputs.clang }} run: | sudo apt-get update -y sudo apt-get install curl curl -sL https://apt.llvm.org/llvm.sh > llvm.sh chmod u+x llvm.sh - sudo ./llvm.sh 17 - sudo apt-get install clang-17 - sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-17 200 - sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-17 200 + sudo ./llvm.sh 19 + sudo apt-get install clang-19 + sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-19 200 + sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-19 200 - name: Install libfaketime if: ${{ inputs.install_faketime }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 251d6088d..1d7f5ed05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -489,7 +489,17 @@ if(WIN32 AND (MSVC OR OC_COMPILER_IS_CLANG)) endif() if(OC_COVERAGE_ENABLED) - list(APPEND PRIVATE_COMPILE_OPTIONS "--coverage") + set(COVERAGE_COMPILE_OPTIONS "--coverage") + set(COVERAGE_LINK_OPTIONS "--coverage") + if(OC_COMPILER_IS_GCC) + set(COVERAGE_COMPILE_OPTIONS -ftest-coverage -fprofile-arcs -fprofile-values -fprofile-abs-path) + check_c_compiler_flag(-fprofile-update=atomic HAVE_ATOMIC_PROFILE_UPDATE) + if(HAVE_ATOMIC_PROFILE_UPDATE) + list(APPEND COVERAGE_COMPILE_OPTIONS -fprofile-update=atomic) + endif() + set(COVERAGE_LINK_OPTIONS -lgcov -fprofile-arcs) + endif() + list(APPEND PRIVATE_COMPILE_OPTIONS ${COVERAGE_COMPILE_OPTIONS}) endif() # ####### Gather source files ######## @@ -628,7 +638,7 @@ else() endif() if(OC_COVERAGE_ENABLED) - list(APPEND PRIVATE_LINK_LIBS "--coverage") + list(APPEND PRIVATE_LINK_LIBS ${COVERAGE_LINK_OPTIONS}) endif() # ####### Object libraries ######## @@ -881,8 +891,8 @@ if(OC_SECURITY_ENABLED) endif() if(OC_COVERAGE_ENABLED) - target_compile_options(client-server-static PRIVATE "--coverage") - target_link_libraries(client-server-static PRIVATE "--coverage") + target_compile_options(client-server-static PRIVATE ${COVERAGE_COMPILE_OPTIONS}) + target_link_libraries(client-server-static PRIVATE ${COVERAGE_LINK_OPTIONS}) endif() set_target_properties(client-server-static PROPERTIES diff --git a/api/cloud/oc_cloud_resource_internal.h b/api/cloud/oc_cloud_resource_internal.h index 86a6f08d8..70b91dfd6 100644 --- a/api/cloud/oc_cloud_resource_internal.h +++ b/api/cloud/oc_cloud_resource_internal.h @@ -42,17 +42,9 @@ extern "C" { /// Default sid value from OCF Device to Cloud Services Specification, /// equivalent to "00000000-0000-0000-0000-000000000000" #ifdef __cplusplus -#define OCF_COAPCLOUDCONF_DEFAULT_SID \ - oc_uuid_t \ - { \ - 0 \ - } +#define OCF_COAPCLOUDCONF_DEFAULT_SID oc_uuid_t{ 0 } #else /* !__cplusplus */ -#define OCF_COAPCLOUDCONF_DEFAULT_SID \ - (oc_uuid_t) \ - { \ - 0 \ - } +#define OCF_COAPCLOUDCONF_DEFAULT_SID (oc_uuid_t){ 0 } #endif /* __cplusplus */ #define OCF_COAPCLOUDCONF_PROP_ACCESSTOKEN "at" diff --git a/api/cloud/oc_cloud_schedule.c b/api/cloud/oc_cloud_schedule.c index 909033f20..227f5dbb9 100644 --- a/api/cloud/oc_cloud_schedule.c +++ b/api/cloud/oc_cloud_schedule.c @@ -33,11 +33,9 @@ #include #define OC_CLOUD_DEFAULT_RETRY_TIMEOUTS \ - { \ - 2 * MILLISECONDS_PER_SECOND, 4 * MILLISECONDS_PER_SECOND, \ - 8 * MILLISECONDS_PER_SECOND, 16 * MILLISECONDS_PER_SECOND, \ - 32 * MILLISECONDS_PER_SECOND, 64 * MILLISECONDS_PER_SECOND \ - } + { 2 * MILLISECONDS_PER_SECOND, 4 * MILLISECONDS_PER_SECOND, \ + 8 * MILLISECONDS_PER_SECOND, 16 * MILLISECONDS_PER_SECOND, \ + 32 * MILLISECONDS_PER_SECOND, 64 * MILLISECONDS_PER_SECOND } static uint16_t g_retry_timeout_ms[OC_CLOUD_RETRY_TIMEOUTS_SIZE] = OC_CLOUD_DEFAULT_RETRY_TIMEOUTS; diff --git a/api/oc_rep_encode_cbor_internal.h b/api/oc_rep_encode_cbor_internal.h index d32e373cb..4f39dd6ba 100644 --- a/api/oc_rep_encode_cbor_internal.h +++ b/api/oc_rep_encode_cbor_internal.h @@ -30,8 +30,10 @@ extern "C" { .get_buffer_size = &cbor_encoder_get_buffer_size, \ .get_extra_bytes_needed = &cbor_encoder_get_extra_bytes_needed, \ \ - .encode_null = &cbor_encode_null, .encode_boolean = &cbor_encode_boolean, \ - .encode_int = &cbor_encode_int, .encode_uint = &cbor_encode_uint, \ + .encode_null = &cbor_encode_null, \ + .encode_boolean = &cbor_encode_boolean, \ + .encode_int = &cbor_encode_int, \ + .encode_uint = &cbor_encode_uint, \ .encode_floating_point = &cbor_encode_floating_point, \ .encode_double = &cbor_encode_double, \ .encode_text_string = &cbor_encode_text_string, \ diff --git a/api/unittest/coreresourcetest.cpp b/api/unittest/coreresourcetest.cpp index 56e05af82..2a8a55d9b 100644 --- a/api/unittest/coreresourcetest.cpp +++ b/api/unittest/coreresourcetest.cpp @@ -244,13 +244,13 @@ class TestCoreResourceWithDevice : public testing::Test { /*uri=*/"/oic/d", }, #if defined(OC_SERVER) && defined(OC_DYNAMIC_ALLOCATION) - { - /*rt=*/OCF_D_RT, - /*name=*/std::string(kDevice2Name), - /*spec_version=*/"ocf.1.0.0", - /*data_model_version=*/"ocf.res.1.0.0", - /*uri=*/"/oic/d", - }, + { + /*rt=*/OCF_D_RT, + /*name=*/std::string(kDevice2Name), + /*spec_version=*/"ocf.1.0.0", + /*data_model_version=*/"ocf.res.1.0.0", + /*uri=*/"/oic/d", + }, #endif /* OC_SERVER && OC_DYNAMIC_ALLOCATION */ }); EXPECT_TRUE(oc::TestDevice::StartServer()); diff --git a/api/unittest/discovery/discovery.cpp b/api/unittest/discovery/discovery.cpp index 9c9acaff1..964dde743 100644 --- a/api/unittest/discovery/discovery.cpp +++ b/api/unittest/discovery/discovery.cpp @@ -38,6 +38,8 @@ #include "gtest/gtest.h" +#include + namespace oc::discovery { LinkData diff --git a/api/unittest/resourcetest.cpp b/api/unittest/resourcetest.cpp index 527dc6b59..9f3f1edc6 100644 --- a/api/unittest/resourcetest.cpp +++ b/api/unittest/resourcetest.cpp @@ -274,13 +274,13 @@ class TestResourceWithDevice : public testing::Test { /*uri=*/"/oic/d", }, #if defined(OC_SERVER) && defined(OC_DYNAMIC_ALLOCATION) - { - /*rt=*/"oic.d.test2", - /*name=*/std::string(kDevice2Name), - /*spec_version=*/"ocf.1.0.0", - /*data_model_version=*/"ocf.res.1.0.0", - /*uri=*/"/oic/d", - }, + { + /*rt=*/"oic.d.test2", + /*name=*/std::string(kDevice2Name), + /*spec_version=*/"ocf.1.0.0", + /*data_model_version=*/"ocf.res.1.0.0", + /*uri=*/"/oic/d", + }, #endif /* OC_SERVER && OC_DYNAMIC_ALLOCATION */ }); EXPECT_TRUE(oc::TestDevice::StartServer()); diff --git a/apps/cloud_proxy.c b/apps/cloud_proxy.c index 28cabe973..ce09c57a8 100644 --- a/apps/cloud_proxy.c +++ b/apps/cloud_proxy.c @@ -1542,7 +1542,7 @@ discovery(const char *anchor, const char *uri, oc_string_array_t types, (char *)btoa(add_err), retval); } /* adding current device, e.g. add the resource to the cloud RD */ - } /* if loop */ + } /* if loop */ return OC_CONTINUE_DISCOVERY; } diff --git a/docker/apps/Dockerfile.cloud-server-debug b/docker/apps/Dockerfile.cloud-server-debug index e3369bd2c..be2a5d18d 100644 --- a/docker/apps/Dockerfile.cloud-server-debug +++ b/docker/apps/Dockerfile.cloud-server-debug @@ -1,4 +1,4 @@ -FROM ubuntu:22.04 AS service +FROM ubuntu:24.04 AS service ARG BUILD_TYPE=Release ARG BUILD_ARGS RUN apt-get update -y && \ diff --git a/docker/apps/Dockerfile.cloud-server-debug-clang b/docker/apps/Dockerfile.cloud-server-debug-clang index 567583a83..d898d8c80 100644 --- a/docker/apps/Dockerfile.cloud-server-debug-clang +++ b/docker/apps/Dockerfile.cloud-server-debug-clang @@ -1,15 +1,17 @@ # GCC thread-sanitizer keeps reporting false positives, so we use clang instead for tests with thread-sanitizer. -FROM ubuntu:22.04 AS service +FROM ubuntu:24.04 AS service ARG BUILD_TYPE=Release ARG BUILD_ARGS RUN apt-get update -y && \ DEBIAN_FRONTEND="noninteractive" apt-get install --no-install-recommends -y bash ca-certificates cmake gdb git-core make patch python3 && \ apt-get clean # install clang -RUN DEBIAN_FRONTEND="noninteractive" apt-get install --no-install-recommends -y clang-15 && \ +# - libclang-rt-18-dev is needed for thread-sanitizer +# - we're using clang-18 and not clang-19 because linux/arm/v7 doesn't have libclang-rt-19-dev +RUN DEBIAN_FRONTEND="noninteractive" apt-get install --no-install-recommends -y clang-18 libclang-rt-18-dev && \ apt-get clean && \ - update-alternatives --install /usr/bin/clang clang /usr/bin/clang-15 100 && \ - update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-15 100 + update-alternatives --install /usr/bin/clang clang /usr/bin/clang-18 100 && \ + update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-18 100 COPY ./ /iotivity-lite/ WORKDIR /iotivity-lite RUN git submodule update --recursive diff --git a/docker/apps/Dockerfile.dps-cloud-server b/docker/apps/Dockerfile.dps-cloud-server index cc72b5488..18805060d 100644 --- a/docker/apps/Dockerfile.dps-cloud-server +++ b/docker/apps/Dockerfile.dps-cloud-server @@ -1,10 +1,15 @@ -FROM ubuntu:22.04 AS build +FROM ubuntu:24.04 AS build RUN apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends build-essential \ - ca-certificates clang-15 cmake g++ gcc git python3 && \ + DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y build-essential \ + ca-certificates cmake g++ gcc git python3 && \ + apt-get clean +# install clang +# - libclang-rt-18-dev is needed for thread-sanitizer +# - we're using clang-18 and not clang-19 because linux/arm/v7 doesn't have libclang-rt-19-dev +RUN DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y clang-18 libclang-rt-18-dev && \ apt-get clean && \ - update-alternatives --install /usr/bin/clang clang /usr/bin/clang-15 10 && \ - update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-15 10 + update-alternatives --install /usr/bin/clang clang /usr/bin/clang-18 100 && \ + update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-18 100 ARG BUILD_TYPE=Release ARG BUILD_ARGS= RUN mkdir /device-provisioning-client @@ -20,7 +25,7 @@ RUN ls -l . && \ cmake --build . --target mbedtls mbedx509 mbedcrypto && \ cmake --build . -j$(nproc) --target dps_cloud_server -FROM ubuntu:22.04 AS service +FROM ubuntu:24.04 AS service RUN apt-get update \ && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends gcc adduser \ && apt-get clean diff --git a/docker/apps/Dockerfile.dps-cloud-server-debug b/docker/apps/Dockerfile.dps-cloud-server-debug index 45bd5eae2..b0d867f84 100644 --- a/docker/apps/Dockerfile.dps-cloud-server-debug +++ b/docker/apps/Dockerfile.dps-cloud-server-debug @@ -1,4 +1,4 @@ -FROM ubuntu:22.04 AS service +FROM ubuntu:24.04 AS service RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends adduser build-essential \ ca-certificates cmake g++ gcc gcovr git python3 && \ diff --git a/port/android/ipadapter.c b/port/android/ipadapter.c index 930820ea3..0d1c371e1 100644 --- a/port/android/ipadapter.c +++ b/port/android/ipadapter.c @@ -493,7 +493,7 @@ get_interface_addresses(ip_context_t *dev, unsigned char family, uint16_t port, ep.flags = IPV6; } } else if (attr->rta_type == IFA_FLAGS) { - if (*(uint32_t *)(RTA_DATA(attr)) & IFA_F_TEMPORARY) { + if (*(uint32_t *)(RTA_DATA(attr))&IFA_F_TEMPORARY) { include = false; } } diff --git a/port/linux/ipadapter.c b/port/linux/ipadapter.c index 2a8e8d5bb..879580769 100644 --- a/port/linux/ipadapter.c +++ b/port/linux/ipadapter.c @@ -371,7 +371,7 @@ get_interface_addresses(ip_context_t *dev, unsigned char family, int port, ep.flags = IPV6; } } else if (attr->rta_type == IFA_FLAGS) { - if (*(uint32_t *)(RTA_DATA(attr)) & IFA_F_TEMPORARY) { + if (*(uint32_t *)(RTA_DATA(attr))&IFA_F_TEMPORARY) { include = false; } } diff --git a/port/oc_loop_event_internal.h b/port/oc_loop_event_internal.h index b73532ec3..094f095ae 100644 --- a/port/oc_loop_event_internal.h +++ b/port/oc_loop_event_internal.h @@ -45,20 +45,11 @@ typedef struct oc_loop_event_t } oc_loop_event_t; #ifdef _WIN32 -#define OC_LOOP_EVENT_INIT \ - { \ - INVALID_HANDLE_VALUE \ - } +#define OC_LOOP_EVENT_INIT { INVALID_HANDLE_VALUE } #elif defined(__linux__) || defined(__ANDROID_API__) -#define OC_LOOP_EVENT_INIT \ - { \ - -1 \ - } +#define OC_LOOP_EVENT_INIT { -1 } #else /* !_WIN32 && !__linux__ && !__ANDROID_API__ */ -#define OC_LOOP_EVENT_INIT \ - { \ - -1, -1 \ - } +#define OC_LOOP_EVENT_INIT { -1, -1 } #endif /* _WIN32 */ /** diff --git a/port/zephyr/src/storage.c b/port/zephyr/src/storage.c index 4cd6f7136..50ef578bc 100644 --- a/port/zephyr/src/storage.c +++ b/port/zephyr/src/storage.c @@ -44,10 +44,7 @@ #define OC_MEMORY_KEY_NAME_SIZE 64 #endif -#define OC_MEMMAP_KEY \ - { \ - 0xab, 0xcd, 0xef \ - } +#define OC_MEMMAP_KEY { 0xab, 0xcd, 0xef } #define OC_MEMMAP_CLOSER_ERASABLE_SECTOR(_pos) \ (_pos * (_pos / memmap.sector_size)) diff --git a/swig/Makefile b/swig/Makefile index 47b097e50..ae39e4638 100644 --- a/swig/Makefile +++ b/swig/Makefile @@ -180,7 +180,7 @@ copy_java: build_jar: copy_java mkdir -p $(IOTIVITY_LITE_JAVA_BIN_DIR) - $(JAVAC) -source 1.7 -target 1.7 -sourcepath $(IOTIVITY_LITE_JAVA_SRC_DIR) -d $(IOTIVITY_LITE_JAVA_BIN_DIR) $(IOTIVITY_LITE_JAVA_SRC_DIR)$(PACKAGE_DIR)*.java $(IOTIVITY_LITE_JAVA_SRC_DIR)$(PACKAGE_DIR)oc/*.java + $(JAVAC) -source 1.8 -target 1.8 -sourcepath $(IOTIVITY_LITE_JAVA_SRC_DIR) -d $(IOTIVITY_LITE_JAVA_BIN_DIR) $(IOTIVITY_LITE_JAVA_SRC_DIR)$(PACKAGE_DIR)*.java $(IOTIVITY_LITE_JAVA_SRC_DIR)$(PACKAGE_DIR)oc/*.java $(JAR) -cfv $(IOTIVITY_LITE_JAVA_LIBS_DIR)$(JAR_NAME) -C $(IOTIVITY_LITE_JAVA_BIN_DIR) . build_jni_so: $(JNI_SRC) diff --git a/swig/java_lang/build-iotivity-lite.sh b/swig/java_lang/build-iotivity-lite.sh index 17464fce8..85c2c9fc9 100755 --- a/swig/java_lang/build-iotivity-lite.sh +++ b/swig/java_lang/build-iotivity-lite.sh @@ -7,7 +7,7 @@ rm -rf ../iotivity-lite-java/bin mkdir ../iotivity-lite-java/bin # compile swig generated java files and custom java files -javac -source 1.7 -target 1.7 -sourcepath ../iotivity-lite-java/src -d ../iotivity-lite-java/bin ../iotivity-lite-java/src/org/iotivity/*.java ../iotivity-lite-java/src/org/iotivity/oc/*.java +javac -source 1.8 -target 1.8 -sourcepath ../iotivity-lite-java/src -d ../iotivity-lite-java/bin ../iotivity-lite-java/src/org/iotivity/*.java ../iotivity-lite-java/src/org/iotivity/oc/*.java # create jar file jar -cfv ../iotivity-lite-java/libs/iotivity-lite.jar -C ../iotivity-lite-java/bin . diff --git a/swig/swig_interfaces/oc_enums.i b/swig/swig_interfaces/oc_enums.i index f81159bbb..61559dd59 100644 --- a/swig/swig_interfaces/oc_enums.i +++ b/swig/swig_interfaces/oc_enums.i @@ -21,11 +21,11 @@ %} %rename(OCEnum) oc_enum_t; -%rename("%(strip:[OC_ENUM_])s", %isenumitem) ""; +%rename("%(strip:[OC_ENUM_])s", %$isenumitem) ""; %rename(OCPositionDescription) oc_pos_description_t; -%rename("%(strip:[OC_POS_])s", %isenumitem) ""; +%rename("%(strip:[OC_POS_])s", %$isenumitem) ""; %rename(OCLocation) oc_locn_t; -%rename("%(strip:[OCF_LOCN_])s", %isenumitem) ""; +%rename("%(strip:[OCF_LOCN_])s", %$isenumitem) ""; %rename(enumToString) oc_enum_to_str; %rename(positionDescriptionToString) oc_enum_pos_desc_to_str; diff --git a/tools/clang-format.cmake b/tools/clang-format.cmake index 30e509623..2f4de3d8a 100755 --- a/tools/clang-format.cmake +++ b/tools/clang-format.cmake @@ -10,7 +10,7 @@ list(FILTER iotivity_allsource EXCLUDE REGEX "port/esp32/esp-idf/") # Find clang-format find_program( CLANG_FORMAT_EXE - NAMES "clang-format-17" + NAMES "clang-format-19" "clang-format" DOC "Path to clang-format executable" ) @@ -27,8 +27,8 @@ execute_process( # Version check message(STATUS ${CLANG_VERSION}) -if(NOT ${CLANG_VERSION} MATCHES "version 17\.0") - message(FATAL_ERROR "clang-format must be version 17.0") +if(NOT ${CLANG_VERSION} MATCHES "version 19\.") + message(FATAL_ERROR "clang-format must be version 19+") endif() # Run clang format diff --git a/tools/collect-coverage.sh b/tools/collect-coverage.sh index 23d3cdbc1..b0b34d044 100755 --- a/tools/collect-coverage.sh +++ b/tools/collect-coverage.sh @@ -99,12 +99,23 @@ echo "Detected compiler: ${COMPILER}" GCOV=gcov if [[ "${COMPILER}" == "clang" ]]; then - if which llvm-cov 2>/dev/null 1>&2; then - GCOV="llvm-cov gcov" + clang --version + CLANG_VERSION=$(clang --version | awk 'NR==1 { split($4, v, "."); print v[1] }') + if ! which llvm-cov-${CLANG_VERSION} 2>/dev/null 1>&2; then + echo "llvm-cov-${CLANG_VERSION} not installed" >&2 + exit 1 fi - if which llvm-cov-10 2>/dev/null 1>&2; then - GCOV="llvm-cov-10 gcov" + GCOV="llvm-cov-${CLANG_VERSION} gcov" +fi + +if [[ "${COMPILER}" == "gcc" ]]; then + gcc --version + GCC_VERSION=$(gcc --version | awk 'NR==1 { split($4, v, "."); print v[1] }') + if ! which gcov-${GCC_VERSION} 2>/dev/null 1>&2; then + echo "gcov-${GCC_VERSION} not installed" >&2 + exit 1 fi + GCOV="gcov-${GCC_VERSION}" fi if ! which gcovr 2>/dev/null 1>&2; then @@ -129,6 +140,10 @@ if awk "BEGIN {exit !(${GCOVR_VERSION} >= 5.0)}"; then pattern+=")\(.*" GCOVR_OPTS+=("--exclude-lines-by-pattern" "${pattern}") fi +if awk "BEGIN {exit !(${GCOVR_VERSION} >= 6.0)}"; then + echo "gcovr v6.0+ detected" + GCOVR_OPTS+=("--merge-mode-functions" "separate") +fi gcovr --verbose --root .. \ --exclude "../deps/.*" \ diff --git a/tools/pre-commit b/tools/pre-commit index f3e3ba6b3..22daff4ab 100755 --- a/tools/pre-commit +++ b/tools/pre-commit @@ -25,19 +25,19 @@ def format(diff): changes = {} for line in diff.splitlines(): - m = re.search(b'^\+\+\+\ (.*?/)(\S*)', line) + m = re.search(b'^\\+\\+\\+\\ (.*?/)(\\S*)', line) if m: filename = m.group(2) if not filename: continue - if not re.match(b'^.*\.(c|h)$', filename): + if not re.match(b'^.*\\.(c|h)$', filename): continue if not filename in changes: changes[filename] = [] - m = re.search(b'^@@.*\+(\d+),(\d+)?', line) + m = re.search(b'^@@.*\\+(\\d+),(\\d+)?', line) if m: start = int(m.group(1)) end = start + int(m.group(2))