Author: Finlay Davidson <finlay.davidson@coderclass.nl>
Update clang-{format,tidy} to 14 Also add configuration options only available in 13 and 14. Fixes warning about -fstack-usage in clang-tidy check.
.clang-format | 7 ++++++- .github/workflows/format.yml | 4 ++-- src/components/ble/BatteryInformationService.cpp | 1 + src/components/ble/MotionService.cpp | 1 + src/components/datetime/DateTimeController.cpp | 1 + src/components/fs/FS.cpp | 5 +++++ src/components/motion/MotionController.cpp | 3 +++ src/displayapp/DisplayApp.cpp | 1 + src/displayapp/screens/WatchFaceCasioStyleG7710.cpp | 1 + src/displayapp/screens/settings/SettingSetTime.cpp | 1 + src/displayapp/widgets/Counter.cpp | 2 ++ src/drivers/Bma421.cpp | 2 ++ src/drivers/DebugPins.cpp | 2 ++ src/drivers/Hrs3300.cpp | 1 + src/recoveryLoader.cpp | 1 + tests/test-format.sh | 2 +- tests/test-tidy.sh | 2 +-
diff --git a/.clang-format b/.clang-format index dec58189edfee376b6b04bf175a3414e35cd3bd0..3e397c6da55d1700e54aa2424e951fddce0f4c04 100644 --- a/.clang-format +++ b/.clang-format @@ -59,6 +59,7 @@ Cpp11BracedListStyle: true DeriveLineEnding: false DerivePointerAlignment: false DisableFormat: false +EmptyLineAfterAccessModifier: Never ExperimentalAutoDetectBinPacking: true FixNamespaceComments: false ForEachMacros: @@ -78,6 +79,7 @@ Priority: 1 SortPriority: 0 IncludeIsMainRegex: '(Test)?$' IncludeIsMainSourceRegex: '' +IndentAccessModifiers: false IndentCaseLabels: true IndentGotoLabels: true IndentPPDirectives: BeforeHash @@ -92,6 +94,7 @@ MacroBlockBegin: '' MacroBlockEnd: '' MaxEmptyLinesToKeep: 1 NamespaceIndentation: All +PackConstructorInitializers: NextLine PenaltyBreakAssignment: 2 PenaltyBreakBeforeFirstCallParameter: 19 PenaltyBreakComment: 300 @@ -101,7 +104,9 @@ PenaltyBreakTemplateDeclaration: 10 PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 60 PointerAlignment: Left +ReferenceAlignment: Pointer ReflowComments: true +SeparateDefinitionBlocks: Always SortIncludes: false SortUsingDeclarations: true SpaceAfterCStyleCast: true @@ -123,7 +128,7 @@ SpacesInCStyleCastParentheses: false SpacesInParentheses: false SpacesInSquareBrackets: false SpaceBeforeSquareBrackets: false -# Needs new Clang: SpaceAroundPointerQualifiers: After +SpaceAroundPointerQualifiers: Default Standard: Latest StatementMacros: - Q_UNUSED diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 23f71a9409f0ce899ded82c29be060a8546962ac..32451a0b387f4988dc52419db03c7e1d09a00387 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -23,7 +23,7 @@ - name: Install clang-format run: | sudo apt-get update - sudo apt-get -y install clang-format-12 + sudo apt-get -y install clang-format-14 - name: Check formatting run: tests/test-format.sh @@ -55,7 +55,7 @@ run: git fetch origin "$GITHUB_BASE_REF":"$GITHUB_BASE_REF" - name: Install clang-tidy run: | apt-get update - apt-get -y install clang-tidy-12 + apt-get -y install clang-tidy-14 - name: Prepare environment shell: bash env: diff --git a/src/components/ble/BatteryInformationService.cpp b/src/components/ble/BatteryInformationService.cpp index 9a3f86f5737fffac687233353497b8eddbb9985c..14589cb9591d98170c02602908ea3efeb64df78a 100644 --- a/src/components/ble/BatteryInformationService.cpp +++ b/src/components/ble/BatteryInformationService.cpp @@ -49,6 +49,7 @@ return (res == 0) ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES; } return 0; } + void BatteryInformationService::NotifyBatteryLevel(uint16_t connectionHandle, uint8_t level) { auto* om = ble_hs_mbuf_from_flat(&level, 1); ble_gattc_notify_custom(connectionHandle, batteryLevelHandle, om); diff --git a/src/components/ble/MotionService.cpp b/src/components/ble/MotionService.cpp index 121ad3b08a5d7f81058e3fa26508d7d11069de49..a7e959237e2ed1b49fc6e32af7e548fd3ba3540c 100644 --- a/src/components/ble/MotionService.cpp +++ b/src/components/ble/MotionService.cpp @@ -90,6 +90,7 @@ } ble_gattc_notify_custom(connectionHandle, stepCountHandle, om); } + void MotionService::OnNewMotionValues(int16_t x, int16_t y, int16_t z) { if (!motionValuesNoficationEnabled) return; diff --git a/src/components/datetime/DateTimeController.cpp b/src/components/datetime/DateTimeController.cpp index e8c7cd5bd2ce209d356b9df0f476c18a6a2f5cba..73364b2f096b7aadaeb71a6455af5d57011001ed 100644 --- a/src/components/datetime/DateTimeController.cpp +++ b/src/components/datetime/DateTimeController.cpp @@ -142,6 +142,7 @@ this->systemTask = systemTask; } using ClockType = Pinetime::Controllers::Settings::ClockType; + std::string DateTime::FormattedTime() { // Return time as a string in 12- or 24-hour format char buff[9]; diff --git a/src/components/fs/FS.cpp b/src/components/fs/FS.cpp index 14b05525dda65198d42d1ff280e5f2baacea8a7b..a67b6b3df0befbd9f3f490c003e1fd102ab484f9 100644 --- a/src/components/fs/FS.cpp +++ b/src/components/fs/FS.cpp @@ -89,18 +89,23 @@ int FS::DirRead(lfs_dir_t* dir, lfs_info* info) { return lfs_dir_read(&lfs, dir, info); } + int FS::DirRewind(lfs_dir_t* dir) { return lfs_dir_rewind(&lfs, dir); } + int FS::DirCreate(const char* path) { return lfs_mkdir(&lfs, path); } + int FS::Rename(const char* oldPath, const char* newPath) { return lfs_rename(&lfs, oldPath, newPath); } + int FS::Stat(const char* path, lfs_info* info) { return lfs_stat(&lfs, path, info); } + lfs_ssize_t FS::GetFSSize() { return lfs_fs_size(&lfs); } diff --git a/src/components/motion/MotionController.cpp b/src/components/motion/MotionController.cpp index d93d769ba5693aec227ae772068c43b9fbd7c6af..8ba468149cf361af6010468d7fcc57ee203de6f3 100644 --- a/src/components/motion/MotionController.cpp +++ b/src/components/motion/MotionController.cpp @@ -61,6 +61,7 @@ lastYForShake = y / 2; lastZForShake = z; return wake; } + int32_t MotionController::currentShakeSpeed() { return accumulatedspeed; } @@ -68,6 +69,7 @@ void MotionController::IsSensorOk(bool isOk) { isSensorOk = isOk; } + void MotionController::Init(Pinetime::Drivers::Bma421::DeviceTypes types) { switch (types) { case Drivers::Bma421::DeviceTypes::BMA421: @@ -81,6 +83,7 @@ this->deviceType = DeviceTypes::Unknown; break; } } + void MotionController::SetService(Pinetime::Controllers::MotionService* service) { this->service = service; } diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 015bc8de6452afb7b77ebad59d7036595c0b3b40..9535c2f3a1d58fd6b29517e133a102812f18adf4 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -529,6 +529,7 @@ void DisplayApp::Register(Pinetime::System::SystemTask* systemTask) { this->systemTask = systemTask; } + void DisplayApp::ApplyBrightness() { auto brightness = settingsController.GetBrightness(); if (brightness != Controllers::BrightnessController::Levels::Low && brightness != Controllers::BrightnessController::Levels::Medium && diff --git a/src/displayapp/screens/WatchFaceCasioStyleG7710.cpp b/src/displayapp/screens/WatchFaceCasioStyleG7710.cpp index bdae0d428e5f22c776b9a9d0f770279583bf308b..94b6a405839950946c1e6ccd83524392f92f8baa 100644 --- a/src/displayapp/screens/WatchFaceCasioStyleG7710.cpp +++ b/src/displayapp/screens/WatchFaceCasioStyleG7710.cpp @@ -333,6 +333,7 @@ lv_obj_realign(stepValue); lv_obj_realign(stepIcon); } } + bool WatchFaceCasioStyleG7710::IsAvailable(Pinetime::Controllers::FS& filesystem) { lfs_file file = {}; diff --git a/src/displayapp/screens/settings/SettingSetTime.cpp b/src/displayapp/screens/settings/SettingSetTime.cpp index e7d824fd357af9c07ec00de580937b78cda3ab27..f85fe073cf7f38ac8e4587b0fa296af91c9364e9 100644 --- a/src/displayapp/screens/settings/SettingSetTime.cpp +++ b/src/displayapp/screens/settings/SettingSetTime.cpp @@ -18,6 +18,7 @@ if (event == LV_EVENT_CLICKED) { screen->SetTime(); } } + void ValueChangedHandler(void* userData) { auto* screen = static_cast<SettingSetTime*>(userData); screen->UpdateScreen(); diff --git a/src/displayapp/widgets/Counter.cpp b/src/displayapp/widgets/Counter.cpp index ccc28cc81f59cc7b3cc4916d83a7d5d697e849bc..b486e3727f6a194b542d3e62965af63d1d9c658e 100644 --- a/src/displayapp/widgets/Counter.cpp +++ b/src/displayapp/widgets/Counter.cpp @@ -18,6 +18,7 @@ if (event == LV_EVENT_SHORT_CLICKED || event == LV_EVENT_LONG_PRESSED_REPEAT) { widget->DownBtnPressed(); } } + constexpr int digitCount(int number) { int digitCount = 0; while (number > 0) { @@ -67,6 +68,7 @@ lv_obj_set_hidden(upperLine, true); lv_obj_set_hidden(lowerLine, true); lv_obj_set_style_local_bg_opa(counterContainer, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); } + void Counter::ShowControls() { lv_obj_set_hidden(upBtn, false); lv_obj_set_hidden(downBtn, false); diff --git a/src/drivers/Bma421.cpp b/src/drivers/Bma421.cpp index 539cc8d1d3d6b05f81f8d794ec501e1bd0e3bc7c..07a94329b76eae17a337d4f365ba31ca70671969 100644 --- a/src/drivers/Bma421.cpp +++ b/src/drivers/Bma421.cpp @@ -118,6 +118,7 @@ // X and Y axis are swapped because of the way the sensor is mounted in the PineTime return {steps, data.y, data.x, data.z}; } + bool Bma421::IsOk() const { return isOk; } @@ -133,6 +134,7 @@ isResetOk = true; nrf_delay_ms(1); } } + Bma421::DeviceTypes Bma421::DeviceType() const { return deviceType; } diff --git a/src/drivers/DebugPins.cpp b/src/drivers/DebugPins.cpp index 4b2f0f163443d59abe0a4eb4093751fa47f48681..6d24ca0477e34c6ad70fcc03542480359965826d 100644 --- a/src/drivers/DebugPins.cpp +++ b/src/drivers/DebugPins.cpp @@ -18,6 +18,7 @@ nrf_gpio_cfg_output(DebugPin4); nrf_gpio_pin_clear(DebugPin4); } + void debugpins_set(debugpins_pins pin) { nrf_gpio_pin_set(static_cast<uint32_t>(pin)); } @@ -33,6 +34,7 @@ } #else void debugpins_init() { } + void debugpins_set(debugpins_pins pin) { } diff --git a/src/drivers/Hrs3300.cpp b/src/drivers/Hrs3300.cpp index ec620af2ce96147fa630f1fddf301ed10af829bb..6c47ae2818fdddc9b17c2cc55d19399397a11c1a 100644 --- a/src/drivers/Hrs3300.cpp +++ b/src/drivers/Hrs3300.cpp @@ -13,6 +13,7 @@ #include#include <nrf_log.h> using namespace Pinetime::Drivers; + /** Driver for the HRS3300 heart rate sensor. * Original implementation from wasp-os : https://github.com/daniel-thompson/wasp-os/blob/master/wasp/drivers/hrs3300.py */ diff --git a/src/recoveryLoader.cpp b/src/recoveryLoader.cpp index 27a79d9c738cdbb12a66c17d0453da16b38e1390..ea608a8bbb83219eb41a4a032232974c1c5f02ab 100644 --- a/src/recoveryLoader.cpp +++ b/src/recoveryLoader.cpp @@ -81,6 +81,7 @@ NRF_WDT->RR[0] = WDT_RR_RR_Reload; } uint8_t displayBuffer[displayWidth * bytesPerPixel]; + void Process(void* instance) { RefreshWatchdog(); APP_GPIOTE_INIT(2); diff --git a/tests/test-format.sh b/tests/test-format.sh index fd3201d0db39db9c39f4fc53f1a1a09c2e51b77c..693377b96f9cf402e8279856b68afb37e0f9801c 100755 --- a/tests/test-format.sh +++ b/tests/test-format.sh @@ -20,7 +20,7 @@ src/libs/*|src/FreeRTOS/*) continue ;; *.cpp|*.h) echo Checking "$file" PATCH="$(basename "$file").patch" - git clang-format-12 -q --style file --diff "$GITHUB_BASE_REF" "$file" > "$PATCH" + git clang-format-14 -q --style file --diff "$GITHUB_BASE_REF" "$file" > "$PATCH" if [ -s "$PATCH" ] then printf "\033[31mError:\033[0m Formatting error in %s\n" "$file" diff --git a/tests/test-tidy.sh b/tests/test-tidy.sh index f1ee5feda02ee57fbb7999fcfba8949060d11e6a..522f6e2a7e132f66abad6e04b330f8c22ff6f9a1 100755 --- a/tests/test-tidy.sh +++ b/tests/test-tidy.sh @@ -17,7 +17,7 @@ case "$file" in src/libs/*|src/FreeRTOS/*) continue ;; *.cpp|*.h) echo "::group::$file" - clang-tidy-12 -p build "$file" || true + clang-tidy-14 -p build "$file" || true echo "::endgroup::" esac done