Skip to content

Commit

Permalink
Cppcheck CI
Browse files Browse the repository at this point in the history
  • Loading branch information
dzid26 committed Jul 17, 2024
1 parent ad782fd commit 7678b9a
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 11 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,60 @@ jobs:
path: bin/main.hex


Static-analysis:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Prepare cppcheck
run: |
mkdir -p b
git clone https://github.com/danmar/cppcheck.git
cd cppcheck
git fetch --all --tags --force
git checkout 2.14.2
mkdir -p build
- name: Cache Cppcheck build
id: cppcheck-build
uses: actions/cache@v4
env:
cache-name: cppcheck-build
with:
path: ./cppcheck/build
key: ${{ runner.os }}-cppcheck-build-${{ env.cache-name }}-${{ hashFiles('cli/*.*') }}
restore-keys: |
${{ runner.os }}-cppcheck-build-${{ env.cache-name }}-
${{ runner.os }}-cppcheck-build-
${{ runner.os }}-
- name: Install cppcheck
shell: bash
run: |
cd cppcheck/build
cmake ..
cmake --build .
sudo make install
cppcheck --version
- name: Cache Cppcheck dumps
id: cppcheck-dump-dir
uses: actions/cache@v4
env:
cache-name: cppcheck-build-dir
with:
path: ./b
key: ${{ runner.os }}-cppcheck-dump-dir-${{ env.cache-name }}-${{ hashFiles('src/**/*.{c,h}') }}
restore-keys: |
${{ runner.os }}-cppcheck-dump-dir-${{ env.cache-name }}-
${{ runner.os }}-cppcheck-dump-dir-
${{ runner.os }}-
- name: Run cppcheck
shell: bash
run: |
cppcheck src --cppcheck-build-dir=b -j8 --enable=all --check-level=exhaustive --force --std=c99 -Isrc/STM8S_StdPeriph_Lib/inc -iSTM8S_StdPeriph_Lib --suppress=missingIncludeSystem --suppress=variableScope -DSTM8S105 -DHSE_Value=16000000 -D_SDCC_ -DUSE_STDPERIPH_DRIVER -USTM8AF52Ax -USTM8AF622x -USTM8AF626x -USTM8AF62Ax -USTM8S003 -USTM8S005 -USTM8S007 -USTM8S103 -USTM8S207 -USTM8S208 -USTM8S903 -U__CSMC__ -U__ICCSTM8__ -U__RCST7__ -U__CDT_PARSER__ -URAM_EXECUTION -UHALL_DEBUG -UTIME_DEBUG -UUSE_FULL_ASSERT 2>/dev/null
Compare_builds:
needs: [Build_Windows, Build_Linux]
runs-on: ubuntu-22.04
Expand Down
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Debug

**/*.launch
.vscode
.*
!.github
tools/Java_Configurator_Source/
!tools/Java_Configurator_Source/src
*.hex
*.bin
*.elf
*.dump
*.ctu-info
src/Result.log
bin/
experimental settings/
Expand Down
10 changes: 5 additions & 5 deletions src/ebike_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -2231,13 +2231,13 @@ static void uart_receive_package(void)
m_configuration_variables.ui8_startup_boost_enabled = ui8_startup_boost_enabled_temp;
ui8_display_function_status[1][ECO] = m_configuration_variables.ui8_startup_boost_enabled;

if (ui8_display_torque_sensor_flag_2) {
if (ui8_display_torque_sensor_flag_2) { // cppcheck-suppress knownConditionTrueFalse
// set display torque sensor step for calibration
ui8_display_torque_sensor_step = 1;
// delay display torque sensor step for calibration
ui8_delay_display_function = DELAY_DISPLAY_TORQUE_CALIBRATION;
}
else if (ui8_display_torque_sensor_flag_1) {
else if (ui8_display_torque_sensor_flag_1) { // cppcheck-suppress knownConditionTrueFalse
// restore torque sensor advanced
m_configuration_variables.ui8_torque_sensor_adv_enabled = ui8_torque_sensor_adv_enabled_temp;
ui8_display_function_status[2][ECO] = m_configuration_variables.ui8_torque_sensor_adv_enabled;
Expand All @@ -2254,7 +2254,7 @@ static void uart_receive_package(void)
case TURBO:
switch (ui8_menu_index) {
case 2:
if (ui8_lights_configuration_2 == 9) {
if (ui8_lights_configuration_2 == 9) { // cppcheck-suppress knownConditionTrueFalse
// restore previous lights configuration
m_configuration_variables.ui8_lights_configuration = ui8_lights_configuration_temp;
ui8_display_lights_configuration = m_configuration_variables.ui8_lights_configuration;
Expand All @@ -2263,7 +2263,7 @@ static void uart_receive_package(void)
}
break;
case 3:
if (ui8_lights_configuration_2 == 9) {
if (ui8_lights_configuration_2 == 9) { // cppcheck-suppress knownConditionTrueFalse
// restore previous assist without pedal rotation
m_configuration_variables.ui8_assist_without_pedal_rotation_enabled = ui8_assist_without_pedal_rotation_temp;
ui8_display_function_status[1][TURBO] = m_configuration_variables.ui8_assist_without_pedal_rotation_enabled;
Expand All @@ -2274,7 +2274,7 @@ static void uart_receive_package(void)
ui8_display_lights_configuration = m_configuration_variables.ui8_lights_configuration;
}

if (ui8_lights_configuration_3 == 10) {
if (ui8_lights_configuration_3 == 10) { // cppcheck-suppress knownConditionTrueFalse
// display status
ui8_display_alternative_lights_configuration = 1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ int main(void) {
ebike_app_controller();

#ifdef TIME_DEBUG
ui8_main_time = ui8_tim4_counter - ui8_main_time
ui8_main_time = ui8_tim4_counter - ui8_main_time;
if (ui8_main_time > ui8_max_ebike_time) {
ui8_max_ebike_time = ui8_main_time;
}
Expand Down
2 changes: 1 addition & 1 deletion src/motor.c
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ void TIM1_CAP_COM_IRQHandler(void) __interrupt(TIM1_CAP_COM_IRQHANDLER)
}

// save percentage remaining battery capacity at shutdown
struct_configuration_variables *p_configuration_variables;
const struct_configuration_variables *p_configuration_variables;
p_configuration_variables = get_configuration_variables();

if ((ui16_adc_voltage < BATTERY_VOLTAGE_SHUTDOWN_10_BIT)
Expand Down

0 comments on commit 7678b9a

Please sign in to comment.