First of the big MISRA cleanups

This commit is contained in:
Josh Stewart 2019-06-26 10:31:35 +10:00
parent 55537a447a
commit 358c50e9ea
7 changed files with 37 additions and 36 deletions

View File

@ -49,9 +49,9 @@ before_install:
# - wget https://github.com/danmar/cppcheck/archive/1.79.zip # - wget https://github.com/danmar/cppcheck/archive/1.79.zip
# - unzip 1.79.zip # - unzip 1.79.zip
# - cd cppcheck-1.79 # - cd cppcheck-1.79
- git clone --depth=10 https://github.com/noisymime/cppcheck.git # - git clone --depth=10 https://github.com/noisymime/cppcheck.git
- cd cppcheck # - cd cppcheck
- sudo make install CFGDIR=/usr/share/cppcheck/ HAVE_RULES=yes # - sudo make install CFGDIR=/usr/share/cppcheck/ HAVE_RULES=yes
# Requirements for doxygen # Requirements for doxygen
- sudo apt-get install doxygen graphviz - sudo apt-get install doxygen graphviz
@ -61,7 +61,9 @@ install:
script: script:
- cd /home/travis/build - cd /home/travis/build
- git clone --depth=10 https://github.com/noisymime/cppcheck.git noisymime/cppcheck_github - git clone --depth=10 https://github.com/noisymime/cppcheck.git noisymime/cppcheck_github
- cd noisymime/speeduino - cd noisymime/cppcheck_github
- make
- cd ../speeduino
- platformio update - platformio update
# Run the builds # Run the builds
- platformio run -e megaatmega2560 -e teensy35 - platformio run -e megaatmega2560 -e teensy35

View File

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
cppcheck_path=cppcheck_github/ cppcheck_path=cppcheck_github/
#cppcheck_bin="${cppcheck_path}cppcheck" cppcheck_bin="${cppcheck_path}cppcheck"
cppcheck_bin="cppcheck" #cppcheck_bin="cppcheck"
cppcheck_misra="${cppcheck_path}addons/misra.py" cppcheck_misra="${cppcheck_path}addons/misra.py"
if [ -f ./results.txt ]; then if [ -f ./results.txt ]; then

View File

@ -94,7 +94,7 @@ No text specified
Rule 9.5 Rule 9.5
No text specified No text specified
Rule 10.1 Rule 10.1
No text specified Arguments of a conditional operation must be of an essentially boolean type
Rule 10.2 Rule 10.2
No text specified No text specified
Rule 10.3 Rule 10.3
@ -104,7 +104,7 @@ The target of an operation must be of an appropriate type
Rule 10.5 Rule 10.5
No text specified No text specified
Rule 10.6 Rule 10.6
No text Specified An expression should not assign a value to a variable of a narrower or essentially different type
Rule 10.7 Rule 10.7
No text specified No text specified
Rule 10.8 Rule 10.8
@ -126,7 +126,7 @@ No text specified
Rule 11.8 Rule 11.8
No text specified No text specified
Rule 11.9 Rule 11.9
No text specified An integer null pointer shall have no value assigned other than NULL macro
Rule 12.1 Rule 12.1
Advisory - Order of operations within an expression must be explicit. Multiple conditions in a logical operation should have brackets around them. Advisory - Order of operations within an expression must be explicit. Multiple conditions in a logical operation should have brackets around them.
Rule 12.2 Rule 12.2
@ -166,9 +166,9 @@ No text specified
Rule 15.5 Rule 15.5
Advisory - A function should only have a single return point Advisory - A function should only have a single return point
Rule 15.6 Rule 15.6
No text specified Loops, switch and if/else statements must have brackets around their body
Rule 15.7 Rule 15.7
No text specified 'else if' statements must terminate with a final 'else'
Rule 16.1 Rule 16.1
No text specified No text specified
Rule 16.2 Rule 16.2
@ -252,7 +252,7 @@ No text specified
Rule 21.2 Rule 21.2
No text specified No text specified
Rule 21.3 Rule 21.3
No text specified Memory allocation functions (Eg malloc(), talloc() etc) shall not be used
Rule 21.4 Rule 21.4
No text specified No text specified
Rule 21.5 Rule 21.5

View File

@ -3,7 +3,6 @@
#include "globals.h" #include "globals.h"
#include "auxiliaries.h" #include "auxiliaries.h"
void initBoard() void initBoard()
{ {
/* /*
@ -20,7 +19,7 @@ void initBoard()
TCCR1B = 0x00; //Disbale Timer1 while we set it up TCCR1B = 0x00; //Disbale Timer1 while we set it up
TCNT1 = 0; //Reset Timer Count TCNT1 = 0; //Reset Timer Count
TCCR1A = 0x00; //Timer1 Control Reg A: Wave Gen Mode normal (Simply counts up from 0 to 65535 (16-bit int) TCCR1A = 0x00; //Timer1 Control Reg A: Wave Gen Mode normal (Simply counts up from 0 to 65535 (16-bit int)
TCCR1B = (1 << CS12); //Timer1 Control Reg B: Timer Prescaler set to 256. 1 tick = 16uS. Refer to http://www.instructables.com/files/orig/F3T/TIKL/H3WSA4V7/F3TTIKLH3WSA4V7.jpg TCCR1B = (1 << CS12); //Timer1 Control Reg B: Timer Prescaler set to 256. 1 tick = 16uS. Refer to www.instructables.com/files/orig/F3T/TIKL/H3WSA4V7/F3TTIKLH3WSA4V7.jpg
TIFR1 = (1 << OCF1A) | (1<<OCF1B) | (1<<OCF1C) | (1<<TOV1) | (1<<ICF1); //Clear the compare flags, overflow flag and external input flag bits TIFR1 = (1 << OCF1A) | (1<<OCF1B) | (1<<OCF1C) | (1<<TOV1) | (1<<ICF1); //Clear the compare flags, overflow flag and external input flag bits
boost_pwm_max_count = 1000000L / (16 * configPage6.boostFreq * 2); //Converts the frequency in Hz to the number of ticks (at 16uS) it takes to complete 1 cycle. The x2 is there because the frequency is stored at half value (in a byte) to allow freqneucies up to 511Hz boost_pwm_max_count = 1000000L / (16 * configPage6.boostFreq * 2); //Converts the frequency in Hz to the number of ticks (at 16uS) it takes to complete 1 cycle. The x2 is there because the frequency is stored at half value (in a byte) to allow freqneucies up to 511Hz
@ -40,7 +39,7 @@ void initBoard()
TCCR2B &= ~(1<<CS21); // Clear bit. Shouldn't be needed as initial value is 0 anyway, but best to play it safe TCCR2B &= ~(1<<CS21); // Clear bit. Shouldn't be needed as initial value is 0 anyway, but best to play it safe
TIFR2 = (1 << OCF2A) | (1<<OCF2B) | (1<<TOV2); //Clear the compare flag bits and overflow flag bit TIFR2 = (1 << OCF2A) | (1<<OCF2B) | (1<<TOV2); //Clear the compare flag bits and overflow flag bit
//Enable the watchdog timer for 2 second resets (Good reference: https://tushev.org/articles/arduino/5/arduino-and-watchdog-timer) //Enable the watchdog timer for 2 second resets (Good reference: www.tushev.org/articles/arduino/5/arduino-and-watchdog-timer)
//Boooooooooo WDT is currently broken on Mega 2560 bootloaders :( //Boooooooooo WDT is currently broken on Mega 2560 bootloaders :(
//wdt_enable(WDTO_2S); //wdt_enable(WDTO_2S);
@ -48,19 +47,19 @@ void initBoard()
*********************************************************************************************************** ***********************************************************************************************************
* Schedules * Schedules
* */ * */
//Much help in this from http://arduinomega.blogspot.com.au/2011/05/timer2-and-overflow-interrupt-lets-get.html //Much help in this from www.arduinomega.blogspot.com.au/2011/05/timer2-and-overflow-interrupt-lets-get.html
//Fuel Schedules, which uses timer 3 //Fuel Schedules, which uses timer 3
TCCR3B = 0x00; //Disable Timer3 while we set it up TCCR3B = 0x00; //Disable Timer3 while we set it up
TCNT3 = 0; //Reset Timer Count TCNT3 = 0; //Reset Timer Count
TCCR3A = 0x00; //Timer3 Control Reg A: Wave Gen Mode normal TCCR3A = 0x00; //Timer3 Control Reg A: Wave Gen Mode normal
TCCR3B = (1 << CS12); //Same as: 0x03. Timer3 Control Reg B: Timer Prescaler set to 256. Refer to http://www.instructables.com/files/orig/F3T/TIKL/H3WSA4V7/F3TTIKLH3WSA4V7.jpg TCCR3B = (1 << CS12); //Same as: 0x03. Timer3 Control Reg B: Timer Prescaler set to 256. Refer to www.instructables.com/files/orig/F3T/TIKL/H3WSA4V7/F3TTIKLH3WSA4V7.jpg
TIFR3 = (1 << OCF3A) | (1<<OCF3B) | (1<<OCF3C) | (1<<TOV3) | (1<<ICF3); //Clear the compare flags, overflow flag and external input flag bits TIFR3 = (1 << OCF3A) | (1<<OCF3B) | (1<<OCF3C) | (1<<TOV3) | (1<<ICF3); //Clear the compare flags, overflow flag and external input flag bits
//Ignition Schedules, which uses timer 5. This is also used by the fast version of micros(). If the speed of this timer is changed from 4uS ticks, that MUST be changed as well. See globals.h and timers.ino //Ignition Schedules, which uses timer 5. This is also used by the fast version of micros(). If the speed of this timer is changed from 4uS ticks, that MUST be changed as well. See globals.h and timers.ino
TCCR5B = 0x00; //Disable Timer5 while we set it up TCCR5B = 0x00; //Disable Timer5 while we set it up
TCNT5 = 0; //Reset Timer Count TCNT5 = 0; //Reset Timer Count
TCCR5A = 0x00; //Timer5 Control Reg A: Wave Gen Mode normal TCCR5A = 0x00; //Timer5 Control Reg A: Wave Gen Mode normal
TCCR5B = (1 << CS11) | (1 << CS10); //Timer5 Control Reg B: Timer Prescaler set to 64. Refer to http://www.instructables.com/files/orig/F3T/TIKL/H3WSA4V7/F3TTIKLH3WSA4V7.jpg TCCR5B = (1 << CS11) | (1 << CS10); //Timer5 Control Reg B: Timer Prescaler set to 64. Refer to www.instructables.com/files/orig/F3T/TIKL/H3WSA4V7/F3TTIKLH3WSA4V7.jpg
TIFR5 = (1 << OCF5A) | (1<<OCF5B) | (1<<OCF5C) | (1<<TOV5) | (1<<ICF5); //Clear the compare flags, overflow flag and external input flag bits TIFR5 = (1 << OCF5A) | (1<<OCF5B) | (1<<OCF5C) | (1<<TOV5) | (1<<ICF5); //Clear the compare flags, overflow flag and external input flag bits
#if defined(TIMER5_MICROS) #if defined(TIMER5_MICROS)
@ -72,7 +71,7 @@ void initBoard()
TCCR4B = 0x00; //Disable Timer4 while we set it up TCCR4B = 0x00; //Disable Timer4 while we set it up
TCNT4 = 0; //Reset Timer Count TCNT4 = 0; //Reset Timer Count
TCCR4A = 0x00; //Timer4 Control Reg A: Wave Gen Mode normal TCCR4A = 0x00; //Timer4 Control Reg A: Wave Gen Mode normal
TCCR4B = (1 << CS12); //Timer4 Control Reg B: aka Divisor = 256 = 122.5HzTimer Prescaler set to 256. Refer to http://www.instructables.com/files/orig/F3T/TIKL/H3WSA4V7/F3TTIKLH3WSA4V7.jpg TCCR4B = (1 << CS12); //Timer4 Control Reg B: aka Divisor = 256 = 122.5HzTimer Prescaler set to 256. Refer to www.instructables.com/files/orig/F3T/TIKL/H3WSA4V7/F3TTIKLH3WSA4V7.jpg
TIFR4 = (1 << OCF4A) | (1<<OCF4B) | (1<<OCF4C) | (1<<TOV4) | (1<<ICF4); //Clear the compare flags, overflow flag and external input flag bits TIFR4 = (1 << OCF4A) | (1<<OCF4B) | (1<<OCF4C) | (1<<TOV4) | (1<<ICF4); //Clear the compare flags, overflow flag and external input flag bits
} }

View File

@ -1412,7 +1412,7 @@ void sendPageASCII()
currentTitleIndex = 132; //Change over to vvtTable mid display currentTitleIndex = 132; //Change over to vvtTable mid display
currentTable = vvtTable; currentTable = vvtTable;
} }
else currentTitleIndex = 0; else { currentTitleIndex = 0; }
}while(currentTitleIndex == 132); //Should never loop unless going to display vvtTable }while(currentTitleIndex == 132); //Should never loop unless going to display vvtTable
} //is map } //is map
else else

View File

@ -634,7 +634,7 @@ void triggerSetEndTeeth_DualWheel()
/* ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- /* -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Name: Basic Distributor Name: Basic Distributor
Desc: Tooth equal to the number of cylinders are evenly spaced on the cam. No position sensing (Distributor is retained) so crank angle is a made up figure based purely on the first teeth to be seen Desc: Tooth equal to the number of cylinders are evenly spaced on the cam. No position sensing (Distributor is retained) so crank angle is a made up figure based purely on the first teeth to be seen
Note: This is a very simple decoder. See http://www.megamanual.com/ms2/GM_7pinHEI.htm Note: This is a very simple decoder. See www.megamanual.com/ms2/GM_7pinHEI.htm
*/ */
void triggerSetup_BasicDistributor() void triggerSetup_BasicDistributor()
{ {
@ -662,11 +662,11 @@ void triggerPri_BasicDistributor()
{ {
if( (toothCurrentCount == triggerActualTeeth) || (currentStatus.hasSync == false) ) //Check if we're back to the beginning of a revolution if( (toothCurrentCount == triggerActualTeeth) || (currentStatus.hasSync == false) ) //Check if we're back to the beginning of a revolution
{ {
toothCurrentCount = 1; //Reset the counter toothCurrentCount = 1; //Reset the counter
toothOneMinusOneTime = toothOneTime; toothOneMinusOneTime = toothOneTime;
toothOneTime = curTime; toothOneTime = curTime;
currentStatus.hasSync = true; currentStatus.hasSync = true;
currentStatus.startRevolutions++; //Counter currentStatus.startRevolutions++; //Counter
} }
else else
{ {
@ -779,7 +779,7 @@ void triggerSetEndTeeth_BasicDistributor()
Name: GM7X Name: GM7X
Desc: GM 7X trigger wheel. It has six equally spaced teeth and a seventh tooth for cylinder identification. Desc: GM 7X trigger wheel. It has six equally spaced teeth and a seventh tooth for cylinder identification.
Note: Within the code below, the sync tooth is referred to as tooth #3 rather than tooth #7. This makes for simpler angle calculations Note: Within the code below, the sync tooth is referred to as tooth #3 rather than tooth #7. This makes for simpler angle calculations
https://speeduino.com/forum/download/file.php?id=4743 www.speeduino.com/forum/download/file.php?id=4743
*/ */
void triggerSetup_GM7X() void triggerSetup_GM7X()
{ {
@ -914,7 +914,7 @@ void triggerSetEndTeeth_GM7X()
/* ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- /* -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Name: Mitsubishi 4G63 / NA/NB Miata + MX-5 / 4/2 Name: Mitsubishi 4G63 / NA/NB Miata + MX-5 / 4/2
Desc: TBA Desc: TBA
Note: https://raw.githubusercontent.com/noisymime/speeduino/master/reference/wiki/decoders/4g63_trace.png Note: raw.githubusercontent.com/noisymime/speeduino/master/reference/wiki/decoders/4g63_trace.png
Tooth #1 is defined as the next crank tooth after the crank signal is HIGH when the cam signal is falling. Tooth #1 is defined as the next crank tooth after the crank signal is HIGH when the cam signal is falling.
Tooth number one is at 355* ATDC Tooth number one is at 355* ATDC
*/ */
@ -966,7 +966,7 @@ void triggerSetup_4G63()
triggerActualTeeth = 8; triggerActualTeeth = 8;
} }
/* /*
* https://forums.libreems.org/attachment.php?aid=34 * forums.libreems.org/attachment.php?aid=34
toothAngles[0] = 715; //Falling edge of tooth #1 toothAngles[0] = 715; //Falling edge of tooth #1
toothAngles[1] = 49; //Falling edge of wide cam toothAngles[1] = 49; //Falling edge of wide cam
toothAngles[2] = 105; //Rising edge of tooth #2 toothAngles[2] = 105; //Rising edge of tooth #2
@ -1365,7 +1365,7 @@ void triggerSetEndTeeth_4G63()
Name: GM Name: GM
Desc: TBA Desc: TBA
Note: Useful references: Note: Useful references:
http://www.vems.hu/wiki/index.php?page=MembersPage%2FJorgenKarlsson%2FTwentyFourX www.vems.hu/wiki/index.php?page=MembersPage%2FJorgenKarlsson%2FTwentyFourX
Provided that the cam signal is used, this decoder simply counts the teeth and then looks their angles up against a lookup table. The cam signal is used to determine tooth #1 Provided that the cam signal is used, this decoder simply counts the teeth and then looks their angles up against a lookup table. The cam signal is used to determine tooth #1
*/ */
void triggerSetup_24X() void triggerSetup_24X()
@ -1488,7 +1488,7 @@ Name: Jeep 2000
Desc: For '91 to 2000 6 cylinder Jeep engines Desc: For '91 to 2000 6 cylinder Jeep engines
Note: Quite similar to the 24X setup. 24 crank teeth over 720 degrees, in groups of 4. Crank wheel is high for 360 crank degrees. AS we only need timing within 360 degrees, only 12 tooth angles are defined. Note: Quite similar to the 24X setup. 24 crank teeth over 720 degrees, in groups of 4. Crank wheel is high for 360 crank degrees. AS we only need timing within 360 degrees, only 12 tooth angles are defined.
Tooth number 1 represents the first tooth seen after the cam signal goes high Tooth number 1 represents the first tooth seen after the cam signal goes high
http://speeduino.com/forum/download/file.php?id=205 www.speeduino.com/forum/download/file.php?id=205
*/ */
void triggerSetup_Jeep2000() void triggerSetup_Jeep2000()
{ {
@ -1808,7 +1808,7 @@ void triggerSetEndTeeth_HondaD17()
/* ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- /* -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Name: Miata '99 to '05 Name: Miata '99 to '05
Desc: TBA (See: http://forum.diyefi.org/viewtopic.php?f=56&t=1077) Desc: TBA (See: www.forum.diyefi.org/viewtopic.php?f=56&t=1077)
Note: 4x 70 degree duration teeth running at cam speed. Believed to be at the same angles as the 4g63 decoder Note: 4x 70 degree duration teeth running at cam speed. Believed to be at the same angles as the 4g63 decoder
Tooth #1 is defined as the next crank tooth after the crank signal is HIGH when the cam signal is falling. Tooth #1 is defined as the next crank tooth after the crank signal is HIGH when the cam signal is falling.
Tooth number one is at 355* ATDC Tooth number one is at 355* ATDC
@ -2290,7 +2290,7 @@ void triggerSetEndTeeth_non360()
/* ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- /* -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Name: Nissan 360 tooth with cam Name: Nissan 360 tooth with cam
Desc: Desc:
Note: https://wiki.r31skylineclub.com/index.php/Crank_Angle_Sensor Note: wiki.r31skylineclub.com/index.php/Crank_Angle_Sensor
*/ */
void triggerSetup_Nissan360() void triggerSetup_Nissan360()
{ {
@ -2767,7 +2767,7 @@ void triggerSetEndTeeth_Subaru67()
/* ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- /* -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Name: Daihatsu +1 trigger for 3 and 4 cylinder engines Name: Daihatsu +1 trigger for 3 and 4 cylinder engines
Desc: Tooth equal to the number of cylinders are evenly spaced on the cam. No position sensing (Distributor is retained) so crank angle is a made up figure based purely on the first teeth to be seen Desc: Tooth equal to the number of cylinders are evenly spaced on the cam. No position sensing (Distributor is retained) so crank angle is a made up figure based purely on the first teeth to be seen
Note: This is a very simple decoder. See http://www.megamanual.com/ms2/GM_7pinHEI.htm Note: This is a very simple decoder. See www.megamanual.com/ms2/GM_7pinHEI.htm
*/ */
void triggerSetup_Daihatsu() void triggerSetup_Daihatsu()
{ {
@ -3070,7 +3070,7 @@ void triggerSetEndTeeth_Harley()
/* /*
Name: 36-2-2-2 trigger wheel wheel Name: 36-2-2-2 trigger wheel wheel
Desc: A crank based trigger with a nominal 36 teeth, but 6 of these removed in 3 groups of 2. 2 of these groups are located concurrently. Desc: A crank based trigger with a nominal 36 teeth, but 6 of these removed in 3 groups of 2. 2 of these groups are located concurrently.
Note: http://thefactoryfiveforum.com/attachment.php?attachmentid=34279&d=1412431418 Note: www.thefactoryfiveforum.com/attachment.php?attachmentid=34279&d=1412431418
*/ */
void triggerSetup_ThirtySixMinus222() void triggerSetup_ThirtySixMinus222()
{ {

View File

@ -641,7 +641,7 @@ struct config4 {
byte ADCFILTER_BARO; byte ADCFILTER_BARO;
byte cltAdvBins[6]; /**< Coolant Temp timing advance curve bins */ byte cltAdvBins[6]; /**< Coolant Temp timing advance curve bins */
byte cltAdvValues[6]; /**< Coolant timing advance curve values. These are multiplied by 10 and translated by 127 to allow for negative values */ byte cltAdvValues[6]; /**< Coolant timing advance curve values. These are translated by 15 to allow for negative values */
byte maeBins[4]; /**< MAP based AE MAPdot bins */ byte maeBins[4]; /**< MAP based AE MAPdot bins */
byte maeRates[4]; /**< MAP based AE values */ byte maeRates[4]; /**< MAP based AE values */