From 943fc7fd0bf720da5489482b8e2832fe46315b93 Mon Sep 17 00:00:00 2001 From: Daniel Adam Date: Sun, 4 May 2025 10:37:53 +0200 Subject: [PATCH 01/10] FIx syntax warnings in pre-commit script --- tools/pre-commit | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/pre-commit b/tools/pre-commit index f3e3ba6b3c..22daff4ab5 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)) From 7024f5c7147f484377bff26cbe0470b127cd1a44 Mon Sep 17 00:00:00 2001 From: Daniel Adam Date: Sun, 4 May 2025 11:09:52 +0200 Subject: [PATCH 02/10] Update Github runners to ubuntu-24.04 --- .github/workflows/CLA.yml | 2 +- .github/workflows/android.yml | 2 +- .github/workflows/build.yml | 6 +++--- .github/workflows/check-format.yml | 2 +- .github/workflows/coverity.yml | 2 +- .github/workflows/ctt-bot.yml | 4 ++-- .github/workflows/docker-build-publish-with-cfg.yml | 2 +- .github/workflows/doxygen-publish.yml | 2 +- .github/workflows/doxygen.yml | 2 +- .github/workflows/ghcr-check.yml | 2 +- .github/workflows/ghcr-cleanup.yml | 4 ++-- .github/workflows/plgd-device-test-with-cfg.yml | 2 +- .github/workflows/plgd-dps-test-with-cfg.yml | 2 +- .github/workflows/plgd-hub-test-with-cfg.yml | 2 +- .github/workflows/pr-format.yml | 2 +- .github/workflows/sonar-cloud-analysis.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- .github/workflows/unit-test-with-cfg.yml | 2 +- 18 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/workflows/CLA.yml b/.github/workflows/CLA.yml index 504347bc5a..994003d678 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 37fb9fbb77..8e5748625e 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 cb7e72b493..6c006b6f8f 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 1004fa60b4..3f4ad6e115 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: diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index 805f0474d7..31d05538e5 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 5e7bdecdba..ced03ca020 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 dceaf61b48..4b2a7215c0 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 9ffac85fea..da5025c477 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 b14df234df..d824f17dad 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 1955b10a91..b97b33a982 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 d27b7bf23d..bc1b1eb2f2 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 48f7605f4e..ac804dfe45 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 d9748e00d6..151d4c060a 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 327b7a3a87..9d3574ead9 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 623482fd86..75563da56a 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 diff --git a/.github/workflows/sonar-cloud-analysis.yml b/.github/workflows/sonar-cloud-analysis.yml index d0607d783f..4f5dec5862 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] diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index f62c5e6818..d690298e7b 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 diff --git a/.github/workflows/unit-test-with-cfg.yml b/.github/workflows/unit-test-with-cfg.yml index 886d82a887..e81b60620c 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 From d08bbef7487cbd61b5eaabd124ace2a23df7334b Mon Sep 17 00:00:00 2001 From: Daniel Adam Date: Sun, 4 May 2025 11:12:17 +0200 Subject: [PATCH 03/10] Update docker images to ubuntu:24.04 --- docker/apps/Dockerfile.cloud-server-debug | 2 +- docker/apps/Dockerfile.cloud-server-debug-clang | 2 +- docker/apps/Dockerfile.dps-cloud-server | 4 ++-- docker/apps/Dockerfile.dps-cloud-server-debug | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docker/apps/Dockerfile.cloud-server-debug b/docker/apps/Dockerfile.cloud-server-debug index e3369bd2c0..be2a5d18d5 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 567583a836..e1585c4581 100644 --- a/docker/apps/Dockerfile.cloud-server-debug-clang +++ b/docker/apps/Dockerfile.cloud-server-debug-clang @@ -1,5 +1,5 @@ # 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 && \ diff --git a/docker/apps/Dockerfile.dps-cloud-server b/docker/apps/Dockerfile.dps-cloud-server index cc72b54880..0c91100dea 100644 --- a/docker/apps/Dockerfile.dps-cloud-server +++ b/docker/apps/Dockerfile.dps-cloud-server @@ -1,4 +1,4 @@ -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 && \ @@ -20,7 +20,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 45bd5eae23..b0d867f840 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 && \ From 057d8e04b9dfc840c180087038017910f03bad81 Mon Sep 17 00:00:00 2001 From: Daniel Adam Date: Sun, 4 May 2025 11:29:13 +0200 Subject: [PATCH 04/10] Update Github runners to clang-19 --- .github/workflows/static-analysis.yml | 12 ++++++------ .github/workflows/unit-test-with-cfg.yml | 10 +++++----- api/unittest/discovery/discovery.cpp | 2 ++ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index d690298e7b..5c0bad95f1 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -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 e81b60620c..e3b882bbce 100644 --- a/.github/workflows/unit-test-with-cfg.yml +++ b/.github/workflows/unit-test-with-cfg.yml @@ -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/api/unittest/discovery/discovery.cpp b/api/unittest/discovery/discovery.cpp index 9c9acaff16..964dde7431 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 From eeadef7ea3aea40e5ec92f14af230d0e538a7b05 Mon Sep 17 00:00:00 2001 From: Daniel Adam Date: Sun, 4 May 2025 11:33:57 +0200 Subject: [PATCH 05/10] Update to clang-format-19 --- .github/workflows/check-format.yml | 6 +++--- .github/workflows/pr-format.yml | 4 ++-- api/cloud/oc_cloud_resource_internal.h | 12 ++---------- api/cloud/oc_cloud_schedule.c | 8 +++----- api/oc_rep_encode_cbor_internal.h | 6 ++++-- api/unittest/coreresourcetest.cpp | 14 +++++++------- api/unittest/resourcetest.cpp | 14 +++++++------- apps/cloud_proxy.c | 2 +- port/android/ipadapter.c | 2 +- port/linux/ipadapter.c | 2 +- port/oc_loop_event_internal.h | 15 +++------------ port/zephyr/src/storage.c | 5 +---- tools/clang-format.cmake | 6 +++--- 13 files changed, 38 insertions(+), 58 deletions(-) diff --git a/.github/workflows/check-format.yml b/.github/workflows/check-format.yml index 3f4ad6e115..ae9f1180d3 100644 --- a/.github/workflows/check-format.yml +++ b/.github/workflows/check-format.yml @@ -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/pr-format.yml b/.github/workflows/pr-format.yml index 75563da56a..94f4fde6a3 100644 --- a/.github/workflows/pr-format.yml +++ b/.github/workflows/pr-format.yml @@ -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/api/cloud/oc_cloud_resource_internal.h b/api/cloud/oc_cloud_resource_internal.h index 86a6f08d86..70b91dfd60 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 909033f20f..227f5dbb9f 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 d32e373cba..4f39dd6ba3 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 56e05af824..2a8a55d9b0 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/resourcetest.cpp b/api/unittest/resourcetest.cpp index 527dc6b59a..9f3f1edc62 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 28cabe973a..ce09c57a85 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/port/android/ipadapter.c b/port/android/ipadapter.c index 930820ea3e..0d1c371e17 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 2a8e8d5bb0..879580769c 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 b73532ec32..094f095ae3 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 4cd6f7136a..50ef578bc2 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/tools/clang-format.cmake b/tools/clang-format.cmake index 30e5096233..2f4de3d8a0 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 From 3057c0400aabd45d5cedf07faef95ae5af1f4b8b Mon Sep 17 00:00:00 2001 From: Daniel Adam Date: Sun, 4 May 2025 11:34:57 +0200 Subject: [PATCH 06/10] Update docker images to use clang-18 --- docker/apps/Dockerfile.cloud-server-debug-clang | 8 +++++--- docker/apps/Dockerfile.dps-cloud-server | 13 +++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/docker/apps/Dockerfile.cloud-server-debug-clang b/docker/apps/Dockerfile.cloud-server-debug-clang index e1585c4581..d898d8c80c 100644 --- a/docker/apps/Dockerfile.cloud-server-debug-clang +++ b/docker/apps/Dockerfile.cloud-server-debug-clang @@ -6,10 +6,12 @@ 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 0c91100dea..18805060d6 100644 --- a/docker/apps/Dockerfile.dps-cloud-server +++ b/docker/apps/Dockerfile.dps-cloud-server @@ -1,10 +1,15 @@ 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 From 104dfe4197f6749a8cf60a9b09b2b79d2e1c3404 Mon Sep 17 00:00:00 2001 From: Daniel Adam Date: Sun, 4 May 2025 15:21:16 +0200 Subject: [PATCH 07/10] Fix code coverage collection --- .github/workflows/sonar-cloud-analysis.yml | 3 ++- tools/collect-coverage.sh | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflows/sonar-cloud-analysis.yml b/.github/workflows/sonar-cloud-analysis.yml index 4f5dec5862..4dbaa2c9ea 100644 --- a/.github/workflows/sonar-cloud-analysis.yml +++ b/.github/workflows/sonar-cloud-analysis.yml @@ -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/tools/collect-coverage.sh b/tools/collect-coverage.sh index 23d3cdbc1c..cc23c1830d 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 From ac6621514a95774395b31756f9e0efd7a8a16f19 Mon Sep 17 00:00:00 2001 From: Daniel Adam Date: Mon, 5 May 2025 09:24:24 +0200 Subject: [PATCH 08/10] Update code coverage compile and linker flags --- CMakeLists.txt | 18 ++++++++++++++---- tools/collect-coverage.sh | 4 ++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 251d6088d5..1d7f5ed054 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/tools/collect-coverage.sh b/tools/collect-coverage.sh index cc23c1830d..b0b34d0441 100755 --- a/tools/collect-coverage.sh +++ b/tools/collect-coverage.sh @@ -140,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/.*" \ From 5168007dd40853585bbf6da076ac0c75ac574be7 Mon Sep 17 00:00:00 2001 From: Daniel Adam Date: Sun, 4 May 2025 19:38:36 +0200 Subject: [PATCH 09/10] swig: upgrade to java 1.8 Java 1.7 is no longer supported --- swig/Makefile | 2 +- swig/java_lang/build-iotivity-lite.sh | 2 +- swig/swig_interfaces/oc_enums.i | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/swig/Makefile b/swig/Makefile index 47b097e502..ae39e4638a 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 17464fce84..85c2c9fc93 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 f81159bbbd..61559dd59f 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; From 519036cf28af0e36b4d6ece535dba5b05530dc85 Mon Sep 17 00:00:00 2001 From: Daniel Adam Date: Thu, 8 May 2025 15:10:19 +0200 Subject: [PATCH 10/10] Fix Windows clang20 build --- .github/workflows/cmake-windows.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cmake-windows.yml b/.github/workflows/cmake-windows.yml index 78c6c89cb8..e4ae801184 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