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.
This commit is contained in:
Finlay Davidson 2023-01-03 14:05:30 +00:00 committed by JF
parent 318a243df1
commit eda96ffadc
17 changed files with 32 additions and 5 deletions

View file

@ -59,6 +59,7 @@ Cpp11BracedListStyle: true
DeriveLineEnding: false DeriveLineEnding: false
DerivePointerAlignment: false DerivePointerAlignment: false
DisableFormat: false DisableFormat: false
EmptyLineAfterAccessModifier: Never
ExperimentalAutoDetectBinPacking: true ExperimentalAutoDetectBinPacking: true
FixNamespaceComments: false FixNamespaceComments: false
ForEachMacros: ForEachMacros:
@ -78,6 +79,7 @@ IncludeCategories:
SortPriority: 0 SortPriority: 0
IncludeIsMainRegex: '(Test)?$' IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: '' IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseLabels: true IndentCaseLabels: true
IndentGotoLabels: true IndentGotoLabels: true
IndentPPDirectives: BeforeHash IndentPPDirectives: BeforeHash
@ -92,6 +94,7 @@ MacroBlockBegin: ''
MacroBlockEnd: '' MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1 MaxEmptyLinesToKeep: 1
NamespaceIndentation: All NamespaceIndentation: All
PackConstructorInitializers: NextLine
PenaltyBreakAssignment: 2 PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19 PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300 PenaltyBreakComment: 300
@ -101,7 +104,9 @@ PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000 PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60 PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left PointerAlignment: Left
ReferenceAlignment: Pointer
ReflowComments: true ReflowComments: true
SeparateDefinitionBlocks: Always
SortIncludes: false SortIncludes: false
SortUsingDeclarations: true SortUsingDeclarations: true
SpaceAfterCStyleCast: true SpaceAfterCStyleCast: true
@ -123,7 +128,7 @@ SpacesInCStyleCastParentheses: false
SpacesInParentheses: false SpacesInParentheses: false
SpacesInSquareBrackets: false SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false SpaceBeforeSquareBrackets: false
# Needs new Clang: SpaceAroundPointerQualifiers: After SpaceAroundPointerQualifiers: Default
Standard: Latest Standard: Latest
StatementMacros: StatementMacros:
- Q_UNUSED - Q_UNUSED

View file

@ -23,7 +23,7 @@ jobs:
- name: Install clang-format - name: Install clang-format
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get -y install clang-format-12 sudo apt-get -y install clang-format-14
- name: Check formatting - name: Check formatting
run: tests/test-format.sh run: tests/test-format.sh
@ -55,7 +55,7 @@ jobs:
- name: Install clang-tidy - name: Install clang-tidy
run: | run: |
apt-get update apt-get update
apt-get -y install clang-tidy-12 apt-get -y install clang-tidy-14
- name: Prepare environment - name: Prepare environment
shell: bash shell: bash
env: env:

View file

@ -49,6 +49,7 @@ int BatteryInformationService::OnBatteryServiceRequested(uint16_t connectionHand
} }
return 0; return 0;
} }
void BatteryInformationService::NotifyBatteryLevel(uint16_t connectionHandle, uint8_t level) { void BatteryInformationService::NotifyBatteryLevel(uint16_t connectionHandle, uint8_t level) {
auto* om = ble_hs_mbuf_from_flat(&level, 1); auto* om = ble_hs_mbuf_from_flat(&level, 1);
ble_gattc_notify_custom(connectionHandle, batteryLevelHandle, om); ble_gattc_notify_custom(connectionHandle, batteryLevelHandle, om);

View file

@ -90,6 +90,7 @@ void MotionService::OnNewStepCountValue(uint32_t stepCount) {
ble_gattc_notify_custom(connectionHandle, stepCountHandle, om); ble_gattc_notify_custom(connectionHandle, stepCountHandle, om);
} }
void MotionService::OnNewMotionValues(int16_t x, int16_t y, int16_t z) { void MotionService::OnNewMotionValues(int16_t x, int16_t y, int16_t z) {
if (!motionValuesNoficationEnabled) if (!motionValuesNoficationEnabled)
return; return;

View file

@ -142,6 +142,7 @@ void DateTime::Register(Pinetime::System::SystemTask* systemTask) {
} }
using ClockType = Pinetime::Controllers::Settings::ClockType; using ClockType = Pinetime::Controllers::Settings::ClockType;
std::string DateTime::FormattedTime() { std::string DateTime::FormattedTime() {
// Return time as a string in 12- or 24-hour format // Return time as a string in 12- or 24-hour format
char buff[9]; char buff[9];

View file

@ -89,18 +89,23 @@ int FS::DirClose(lfs_dir_t* lfs_dir) {
int FS::DirRead(lfs_dir_t* dir, lfs_info* info) { int FS::DirRead(lfs_dir_t* dir, lfs_info* info) {
return lfs_dir_read(&lfs, dir, info); return lfs_dir_read(&lfs, dir, info);
} }
int FS::DirRewind(lfs_dir_t* dir) { int FS::DirRewind(lfs_dir_t* dir) {
return lfs_dir_rewind(&lfs, dir); return lfs_dir_rewind(&lfs, dir);
} }
int FS::DirCreate(const char* path) { int FS::DirCreate(const char* path) {
return lfs_mkdir(&lfs, path); return lfs_mkdir(&lfs, path);
} }
int FS::Rename(const char* oldPath, const char* newPath) { int FS::Rename(const char* oldPath, const char* newPath) {
return lfs_rename(&lfs, oldPath, newPath); return lfs_rename(&lfs, oldPath, newPath);
} }
int FS::Stat(const char* path, lfs_info* info) { int FS::Stat(const char* path, lfs_info* info) {
return lfs_stat(&lfs, path, info); return lfs_stat(&lfs, path, info);
} }
lfs_ssize_t FS::GetFSSize() { lfs_ssize_t FS::GetFSSize() {
return lfs_fs_size(&lfs); return lfs_fs_size(&lfs);
} }

View file

@ -61,6 +61,7 @@ bool MotionController::Should_ShakeWake(uint16_t thresh) {
lastZForShake = z; lastZForShake = z;
return wake; return wake;
} }
int32_t MotionController::currentShakeSpeed() { int32_t MotionController::currentShakeSpeed() {
return accumulatedspeed; return accumulatedspeed;
} }
@ -68,6 +69,7 @@ int32_t MotionController::currentShakeSpeed() {
void MotionController::IsSensorOk(bool isOk) { void MotionController::IsSensorOk(bool isOk) {
isSensorOk = isOk; isSensorOk = isOk;
} }
void MotionController::Init(Pinetime::Drivers::Bma421::DeviceTypes types) { void MotionController::Init(Pinetime::Drivers::Bma421::DeviceTypes types) {
switch (types) { switch (types) {
case Drivers::Bma421::DeviceTypes::BMA421: case Drivers::Bma421::DeviceTypes::BMA421:
@ -81,6 +83,7 @@ void MotionController::Init(Pinetime::Drivers::Bma421::DeviceTypes types) {
break; break;
} }
} }
void MotionController::SetService(Pinetime::Controllers::MotionService* service) { void MotionController::SetService(Pinetime::Controllers::MotionService* service) {
this->service = service; this->service = service;
} }

View file

@ -529,6 +529,7 @@ void DisplayApp::PushMessageToSystemTask(Pinetime::System::Messages message) {
void DisplayApp::Register(Pinetime::System::SystemTask* systemTask) { void DisplayApp::Register(Pinetime::System::SystemTask* systemTask) {
this->systemTask = systemTask; this->systemTask = systemTask;
} }
void DisplayApp::ApplyBrightness() { void DisplayApp::ApplyBrightness() {
auto brightness = settingsController.GetBrightness(); auto brightness = settingsController.GetBrightness();
if (brightness != Controllers::BrightnessController::Levels::Low && brightness != Controllers::BrightnessController::Levels::Medium && if (brightness != Controllers::BrightnessController::Levels::Low && brightness != Controllers::BrightnessController::Levels::Medium &&

View file

@ -333,6 +333,7 @@ void WatchFaceCasioStyleG7710::Refresh() {
lv_obj_realign(stepIcon); lv_obj_realign(stepIcon);
} }
} }
bool WatchFaceCasioStyleG7710::IsAvailable(Pinetime::Controllers::FS& filesystem) { bool WatchFaceCasioStyleG7710::IsAvailable(Pinetime::Controllers::FS& filesystem) {
lfs_file file = {}; lfs_file file = {};

View file

@ -18,6 +18,7 @@ namespace {
screen->SetTime(); screen->SetTime();
} }
} }
void ValueChangedHandler(void* userData) { void ValueChangedHandler(void* userData) {
auto* screen = static_cast<SettingSetTime*>(userData); auto* screen = static_cast<SettingSetTime*>(userData);
screen->UpdateScreen(); screen->UpdateScreen();

View file

@ -18,6 +18,7 @@ namespace {
widget->DownBtnPressed(); widget->DownBtnPressed();
} }
} }
constexpr int digitCount(int number) { constexpr int digitCount(int number) {
int digitCount = 0; int digitCount = 0;
while (number > 0) { while (number > 0) {
@ -67,6 +68,7 @@ void Counter::HideControls() {
lv_obj_set_hidden(lowerLine, 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); lv_obj_set_style_local_bg_opa(counterContainer, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
} }
void Counter::ShowControls() { void Counter::ShowControls() {
lv_obj_set_hidden(upBtn, false); lv_obj_set_hidden(upBtn, false);
lv_obj_set_hidden(downBtn, false); lv_obj_set_hidden(downBtn, false);

View file

@ -118,6 +118,7 @@ Bma421::Values Bma421::Process() {
// X and Y axis are swapped because of the way the sensor is mounted in the PineTime // 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}; return {steps, data.y, data.x, data.z};
} }
bool Bma421::IsOk() const { bool Bma421::IsOk() const {
return isOk; return isOk;
} }
@ -133,6 +134,7 @@ void Bma421::SoftReset() {
nrf_delay_ms(1); nrf_delay_ms(1);
} }
} }
Bma421::DeviceTypes Bma421::DeviceType() const { Bma421::DeviceTypes Bma421::DeviceType() const {
return deviceType; return deviceType;
} }

View file

@ -18,6 +18,7 @@ void debugpins_init() {
nrf_gpio_cfg_output(DebugPin4); nrf_gpio_cfg_output(DebugPin4);
nrf_gpio_pin_clear(DebugPin4); nrf_gpio_pin_clear(DebugPin4);
} }
void debugpins_set(debugpins_pins pin) { void debugpins_set(debugpins_pins pin) {
nrf_gpio_pin_set(static_cast<uint32_t>(pin)); nrf_gpio_pin_set(static_cast<uint32_t>(pin));
} }
@ -33,6 +34,7 @@ void debugpins_pulse(debugpins_pins pin) {
#else #else
void debugpins_init() { void debugpins_init() {
} }
void debugpins_set(debugpins_pins pin) { void debugpins_set(debugpins_pins pin) {
} }

View file

@ -13,6 +13,7 @@
#include <nrf_log.h> #include <nrf_log.h>
using namespace Pinetime::Drivers; using namespace Pinetime::Drivers;
/** Driver for the HRS3300 heart rate sensor. /** 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 * Original implementation from wasp-os : https://github.com/daniel-thompson/wasp-os/blob/master/wasp/drivers/hrs3300.py
*/ */

View file

@ -81,6 +81,7 @@ void RefreshWatchdog() {
} }
uint8_t displayBuffer[displayWidth * bytesPerPixel]; uint8_t displayBuffer[displayWidth * bytesPerPixel];
void Process(void* instance) { void Process(void* instance) {
RefreshWatchdog(); RefreshWatchdog();
APP_GPIOTE_INIT(2); APP_GPIOTE_INIT(2);

View file

@ -20,7 +20,7 @@ do
*.cpp|*.h) *.cpp|*.h)
echo Checking "$file" echo Checking "$file"
PATCH="$(basename "$file").patch" 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" ] if [ -s "$PATCH" ]
then then
printf "\033[31mError:\033[0m Formatting error in %s\n" "$file" printf "\033[31mError:\033[0m Formatting error in %s\n" "$file"

View file

@ -17,7 +17,7 @@ do
src/libs/*|src/FreeRTOS/*) continue ;; src/libs/*|src/FreeRTOS/*) continue ;;
*.cpp|*.h) *.cpp|*.h)
echo "::group::$file" echo "::group::$file"
clang-tidy-12 -p build "$file" || true clang-tidy-14 -p build "$file" || true
echo "::endgroup::" echo "::endgroup::"
esac esac
done done