This repository has been archived on 2022-01-28. You can view files and clone it, but cannot push or open issues or pull requests.
Marlin-Artillery-M600/Marlin
Erik van der Zalm 9db9842aea Fixed error found by the free coverity tool (https://scan.coverity.com/)
===================================================
Hi,

Please find the latest report on new defect(s) introduced to ErikZalm/Marlin found with Coverity Scan.

Defect(s) Reported-by: Coverity Scan
Showing 15 of 15 defect(s)

** CID 59629:  Unchecked return value  (CHECKED_RETURN)
/Marlin_main.cpp: 2154 in process_commands()()

** CID 59630:  Operands don't affect result  (CONSTANT_EXPRESSION_RESULT)
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Tone.cpp: 319 in tone(unsigned char, unsigned int, unsigned long)()

** CID 59631:  Missing break in switch  (MISSING_BREAK)
/Marlin_main.cpp: 1187 in process_commands()()

** CID 59632:  Missing break in switch  (MISSING_BREAK)
/Marlin_main.cpp: 1193 in process_commands()()

** CID 59633:  Out-of-bounds write  (OVERRUN)
/temperature.cpp: 914 in disable_heater()()

** CID 59634:  Out-of-bounds write  (OVERRUN)
/temperature.cpp: 913 in disable_heater()()

** CID 59635:  Out-of-bounds read  (OVERRUN)
/temperature.cpp: 626 in analog2temp(int, unsigned char)()

** CID 59636:  Out-of-bounds read  (OVERRUN)
/temperature.cpp: 620 in analog2temp(int, unsigned char)()

** CID 59637:  Out-of-bounds write  (OVERRUN)
/temperature.cpp: 202 in PID_autotune(float, int, int)()

** CID 59638:  Out-of-bounds read  (OVERRUN)
/temperature.cpp: 214 in PID_autotune(float, int, int)()

** CID 59639:  Out-of-bounds write  (OVERRUN)
/Marlin_main.cpp: 2278 in process_commands()()

** CID 59640:  Out-of-bounds read  (OVERRUN)
/Marlin_main.cpp: 1802 in process_commands()()

** CID 59641:  Uninitialized scalar field  (UNINIT_CTOR)
/Applications/Arduino.app/Contents/Resources/Java/libraries/LiquidCrystal/LiquidCrystal.cpp: 51 in LiquidCrystal::LiquidCrystal(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)()

** CID 59642:  Uninitialized scalar field  (UNINIT_CTOR)
/Applications/Arduino.app/Contents/Resources/Java/libraries/LiquidCrystal/LiquidCrystal.cpp: 45 in LiquidCrystal::LiquidCrystal(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)()

** CID 59643:  Uninitialized scalar field  (UNINIT_CTOR)
/Applications/Arduino.app/Contents/Resources/Java/libraries/LiquidCrystal/LiquidCrystal.cpp: 32 in LiquidCrystal::LiquidCrystal(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)()

________________________________________________________________________________________________________
*** CID 59629:  Unchecked return value  (CHECKED_RETURN)
/Marlin_main.cpp: 2154 in process_commands()()
2148                 }
2149               #endif
2150             }
2151           }
2152           break;
2153         case 85: // M85
   CID 59629:  Unchecked return value  (CHECKED_RETURN)
   Calling "code_seen" without checking return value (as is done elsewhere 66 out of 67 times).
2154           code_seen('S');
2155           max_inactive_time = code_value() * 1000;
2156           break;
2157         case 92: // M92
2158           for(int8_t i=0; i < NUM_AXIS; i++)
2159           {

________________________________________________________________________________________________________
*** CID 59630:  Operands don't affect result  (CONSTANT_EXPRESSION_RESULT)
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Tone.cpp: 319 in tone(unsigned char, unsigned int, unsigned long)()
313         else
314         {
315           // two choices for the 16 bit timers: ck/1 or ck/64
316           ocr = F_CPU / frequency / 2 - 1;
317
318           prescalarbits = 0b001;
   CID 59630:  Operands don't affect result  (CONSTANT_EXPRESSION_RESULT)
   "ocr > 65535U" is always false regardless of the values of its operands. This occurs as the logical operand of if.
319           if (ocr > 0xffff)
320           {
321             ocr = F_CPU / frequency / 2 / 64 - 1;
322             prescalarbits = 0b011;
323           }
324

________________________________________________________________________________________________________
*** CID 59631:  Missing break in switch  (MISSING_BREAK)
/Marlin_main.cpp: 1187 in process_commands()()
1181         case 2: // G2  - CW ARC
1182           if(Stopped == false) {
1183             get_arc_coordinates();
1184             prepare_arc_move(true);
1185             return;
1186           }
   CID 59631:  Missing break in switch  (MISSING_BREAK)
   The above case falls through to this one.
1187         case 3: // G3  - CCW ARC
1188           if(Stopped == false) {
1189             get_arc_coordinates();
1190             prepare_arc_move(false);
1191             return;
1192           }

________________________________________________________________________________________________________
*** CID 59632:  Missing break in switch  (MISSING_BREAK)
/Marlin_main.cpp: 1193 in process_commands()()
1187         case 3: // G3  - CCW ARC
1188           if(Stopped == false) {
1189             get_arc_coordinates();
1190             prepare_arc_move(false);
1191             return;
1192           }
   CID 59632:  Missing break in switch  (MISSING_BREAK)
   The above case falls through to this one.
1193         case 4: // G4 dwell
1194           LCD_MESSAGEPGM(MSG_DWELL);
1195           codenum = 0;
1196           if(code_seen('P')) codenum = code_value(); // milliseconds to wait
1197           if(code_seen('S')) codenum = code_value() * 1000; // seconds to wait
1198

________________________________________________________________________________________________________
*** CID 59633:  Out-of-bounds write  (OVERRUN)
/temperature.cpp: 914 in disable_heater()()
908          WRITE(HEATER_0_PIN,LOW);
909        #endif
910       #endif
911
912       #if defined(TEMP_1_PIN) && TEMP_1_PIN > -1
913         target_temperature[1]=0;
   CID 59633:  Out-of-bounds write  (OVERRUN)
   Overrunning array "soft_pwm" of 1 bytes at byte offset 1 using index "1".
914         soft_pwm[1]=0;
915         #if defined(HEATER_1_PIN) && HEATER_1_PIN > -1
916           WRITE(HEATER_1_PIN,LOW);
917         #endif
918       #endif
919

________________________________________________________________________________________________________
*** CID 59634:  Out-of-bounds write  (OVERRUN)
/temperature.cpp: 913 in disable_heater()()
907        #if defined(HEATER_0_PIN) && HEATER_0_PIN > -1
908          WRITE(HEATER_0_PIN,LOW);
909        #endif
910       #endif
911
912       #if defined(TEMP_1_PIN) && TEMP_1_PIN > -1
   CID 59634:  Out-of-bounds write  (OVERRUN)
   Overrunning array "target_temperature" of 1 2-byte elements at element index 1 (byte offset 2) using index "1".
913         target_temperature[1]=0;
914         soft_pwm[1]=0;
915         #if defined(HEATER_1_PIN) && HEATER_1_PIN > -1
916           WRITE(HEATER_1_PIN,LOW);
917         #endif
918       #endif

________________________________________________________________________________________________________
*** CID 59635:  Out-of-bounds read  (OVERRUN)
/temperature.cpp: 626 in analog2temp(int, unsigned char)()
620       if(heater_ttbl_map[e] != NULL)
621       {
622         float celsius = 0;
623         uint8_t i;
624         short (*tt)[][2] = (short (*)[][2])(heater_ttbl_map[e]);
625
   CID 59635:  Out-of-bounds read  (OVERRUN)
   Overrunning array "heater_ttbllen_map" of 1 bytes at byte offset 1 using index "e" (which evaluates to 1).
626         for (i=1; i<heater_ttbllen_map[e]; i++)
627         {
628           if (PGM_RD_W((*tt)[i][0]) > raw)
629           {
630             celsius = PGM_RD_W((*tt)[i-1][1]) +
631               (raw - PGM_RD_W((*tt)[i-1][0])) *

________________________________________________________________________________________________________
*** CID 59636:  Out-of-bounds read  (OVERRUN)
/temperature.cpp: 620 in analog2temp(int, unsigned char)()
614         if (e == 0)
615         {
616           return 0.25 * raw;
617         }
618       #endif
619
   CID 59636:  Out-of-bounds read  (OVERRUN)
   Overrunning array "heater_ttbl_map" of 1 2-byte elements at element index 1 (byte offset 2) using index "e" (which evaluates to 1).
620       if(heater_ttbl_map[e] != NULL)
621       {
622         float celsius = 0;
623         uint8_t i;
624         short (*tt)[][2] = (short (*)[][2])(heater_ttbl_map[e]);
625

________________________________________________________________________________________________________
*** CID 59637:  Out-of-bounds write  (OVERRUN)
/temperature.cpp: 202 in PID_autotune(float, int, int)()
196       {
197          soft_pwm_bed = (MAX_BED_POWER)/2;
198          bias = d = (MAX_BED_POWER)/2;
199        }
200        else
201        {
   CID 59637:  Out-of-bounds write  (OVERRUN)
   Overrunning array "soft_pwm" of 1 bytes at byte offset 1 using index "extruder" (which evaluates to 1).
202          soft_pwm[extruder] = (PID_MAX)/2;
203          bias = d = (PID_MAX)/2;
204       }
205
206
207

________________________________________________________________________________________________________
*** CID 59638:  Out-of-bounds read  (OVERRUN)
/temperature.cpp: 214 in PID_autotune(float, int, int)()
208
209      for(;;) {
210
211         if(temp_meas_ready == true) { // temp sample ready
212           updateTemperaturesFromRawValues();
213
   CID 59638:  Out-of-bounds read  (OVERRUN)
   Overrunning array "current_temperature" of 1 4-byte elements at element index 1 (byte offset 4) using index "extruder" (which evaluates to 1).
214           input = (extruder<0)?current_temperature_bed:current_temperature[extruder];
215
216           max=max(max,input);
217           min=min(min,input);
218           if(heating == true && input > temp) {
219             if(millis() - t2 > 5000) {

________________________________________________________________________________________________________
*** CID 59639:  Out-of-bounds write  (OVERRUN)
/Marlin_main.cpp: 2278 in process_commands()()
2272               tmp_extruder = code_value();
2273               if(tmp_extruder >= EXTRUDERS) {
2274                 SERIAL_ECHO_START;
2275                 SERIAL_ECHO(MSG_M200_INVALID_EXTRUDER);
2276               }
2277             }
   CID 59639:  Out-of-bounds write  (OVERRUN)
   Overrunning array "volumetric_multiplier" of 1 4-byte elements at element index 1 (byte offset 4) using index "tmp_extruder" (which evaluates to 1).
2278             volumetric_multiplier[tmp_extruder] = 1 / area;
2279           }
2280           break;
2281         case 201: // M201
2282           for(int8_t i=0; i < NUM_AXIS; i++)
2283           {

________________________________________________________________________________________________________
*** CID 59640:  Out-of-bounds read  (OVERRUN)
/Marlin_main.cpp: 1802 in process_commands()()
1796             int pin_status = code_value();
1797             int pin_number = LED_PIN;
1798             if (code_seen('P') && pin_status >= 0 && pin_status <= 255)
1799               pin_number = code_value();
1800             for(int8_t i = 0; i < (int8_t)sizeof(sensitive_pins); i++)
1801             {
   CID 59640:  Out-of-bounds read  (OVERRUN)
   Overrunning array "sensitive_pins" of 28 2-byte elements at element index 55 (byte offset 110) using index "i" (which evaluates to 55).
1802               if (sensitive_pins[i] == pin_number)
1803               {
1804                 pin_number = -1;
1805                 break;
1806               }
1807             }

________________________________________________________________________________________________________
*** CID 59641:  Uninitialized scalar field  (UNINIT_CTOR)
/Applications/Arduino.app/Contents/Resources/Java/libraries/LiquidCrystal/LiquidCrystal.cpp: 51 in LiquidCrystal::LiquidCrystal(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)()
45     }
46
47     LiquidCrystal::LiquidCrystal(uint8_t rs,  uint8_t enable,
48     			     uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3)
49     {
50       init(1, rs, 255, enable, d0, d1, d2, d3, 0, 0, 0, 0);
   CID 59641:  Uninitialized scalar field  (UNINIT_CTOR)
   Non-static class member "_initialized" is not initialized in this constructor nor in any functions that it calls.
51     }
52
53     void LiquidCrystal::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable,
54     			 uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
55     			 uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7)
56     {

________________________________________________________________________________________________________
*** CID 59642:  Uninitialized scalar field  (UNINIT_CTOR)
/Applications/Arduino.app/Contents/Resources/Java/libraries/LiquidCrystal/LiquidCrystal.cpp: 45 in LiquidCrystal::LiquidCrystal(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)()
39     }
40
41     LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable,
42     			     uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3)
43     {
44       init(1, rs, rw, enable, d0, d1, d2, d3, 0, 0, 0, 0);
   CID 59642:  Uninitialized scalar field  (UNINIT_CTOR)
   Non-static class member "_initialized" is not initialized in this constructor nor in any functions that it calls.
45     }
46
47     LiquidCrystal::LiquidCrystal(uint8_t rs,  uint8_t enable,
48     			     uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3)
49     {
50       init(1, rs, 255, enable, d0, d1, d2, d3, 0, 0, 0, 0);

________________________________________________________________________________________________________
*** CID 59643:  Uninitialized scalar field  (UNINIT_CTOR)
/Applications/Arduino.app/Contents/Resources/Java/libraries/LiquidCrystal/LiquidCrystal.cpp: 32 in LiquidCrystal::LiquidCrystal(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)()
26
27     LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable,
28     			     uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
29     			     uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7)
30     {
31       init(0, rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7);
   CID 59643:  Uninitialized scalar field  (UNINIT_CTOR)
   Non-static class member "_initialized" is not initialized in this constructor nor in any functions that it calls.
32     }
33
34     LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t enable,
35     			     uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
36     			     uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7)
37     {

________________________________________________________________________________________________________
To view the defects in Coverity Scan visit, http://scan.coverity.com/projects/2224?tab=overview
2014-05-14 21:59:48 +02:00
..
example_configurations Add safety limit for hot bed power in example configuration 2014-04-25 17:04:24 +08:00
BlinkM.cpp Corrected LCD only error 2013-10-30 21:52:46 +01:00
BlinkM.h Corrected LCD only error 2013-10-30 21:52:46 +01:00
cardreader.cpp Various typo fixes - only in comments, no code changes. 2014-02-17 10:58:36 +00:00
cardreader.h preparation for hibernation 2013-10-22 10:04:08 +02:00
Configuration.h Merge branch 'Marlin_v1' of github.com:ErikZalm/Marlin into Marlin_v1 2014-05-01 12:03:47 +02:00
Configuration_adv.h Update Configuration_adv.h 2014-04-23 17:30:07 +08:00
ConfigurationStore.cpp Only increase EEPROM version for DELTA printers. 2014-02-26 17:29:27 +01:00
ConfigurationStore.h Removed Delta from the default config file. 2013-09-14 13:50:09 +02:00
COPYING first commit 2011-08-12 22:28:35 +02:00
create_speed_lookuptable.py Added 20MHz support. 2012-03-11 12:25:04 +01:00
createTemperatureLookupMarlin.py Add M605 to dynamically set delta configuration 2014-02-17 20:50:59 -08:00
digipot_mcp4451.cpp Add Digipot config for 5DPrint D8 Driver Board 2014-04-24 12:56:46 +08:00
dogm_font_data_marlin.h Removed STB custom font hack from u8glib library and moved to marlin project 2013-04-16 13:54:39 +02:00
dogm_lcd_implementation.h fixed bad lcd commit from makr3d 2013-07-15 17:34:21 +02:00
DOGMbitmaps.h Apply all changes from latest Marlin_V1 2013-06-06 15:49:25 -07:00
fastio.h Various typo fixes - only in comments, no code changes. 2014-02-25 09:52:58 +00:00
language.h Add makibox machine information 2014-04-24 12:55:21 +08:00
LCD Menu Tree.pdf Update the menu plan document with the current menu as per ultralcd.cpp. 2014-02-20 14:20:27 +00:00
LiquidCrystalRus.cpp Various typo fixes - only in comments, no code changes. 2014-02-17 10:58:36 +00:00
LiquidCrystalRus.h Enables support the Cyrillic alphabet for LCD 2012-10-12 19:06:43 +04:00
Makefile Makefile works with auto bed leveling 2014-02-16 23:23:29 -08:00
Marlin.h Individual extruder flow rate 2014-03-15 18:09:46 +01:00
Marlin.ino Add Azteeg X3 Pro as motherboard 68 2014-02-05 01:47:12 -08:00
Marlin.pde Add Azteeg X3 Pro as motherboard 68 2014-02-05 01:47:12 -08:00
Marlin_main.cpp Fixed error found by the free coverity tool (https://scan.coverity.com/) 2014-05-14 21:59:48 +02:00
MarlinSerial.cpp Various typo fixes - only in comments, no code changes. 2014-02-17 10:58:36 +00:00
MarlinSerial.h Initial SAV MkI (RepRap CloneWars board) integration. 2013-10-30 11:45:32 +01:00
Menu Plans.xlsx Update the menu plan document with the current menu as per ultralcd.cpp. 2014-02-20 14:20:27 +00:00
motion_control.cpp software_endstops: use *_MIN_POS and *_MAX_POS for arcs 2012-08-10 19:36:30 +01:00
motion_control.h Removed interrupt nesting in the stepper ISR. 2011-11-27 21:12:55 +01:00
pins.h Fix for pin mapping for SDSS pin and Fan pin, so Arduino library can be used 2014-04-25 12:57:47 +08:00
planner.cpp Fixed math 2014-01-31 08:43:11 -08:00
planner.h Bed Auto Leveling feature 2013-09-29 13:20:06 -03:00
qr_solve.cpp Various typo fixes - only in comments, no code changes. 2014-02-25 10:01:15 +00:00
qr_solve.h Simplify 3-point probing using new code only 2014-02-19 21:48:05 -08:00
Sd2Card.cpp Add feature to check&retry CRC read errors on SD. 2014-05-01 12:03:41 +02:00
Sd2Card.h Add feature to check&retry CRC read errors on SD. 2014-05-01 12:03:41 +02:00
Sd2PinMap.h Initial SAV MkI (RepRap CloneWars board) integration. 2013-10-30 11:45:32 +01:00
SdBaseFile.cpp Few simple fixes that save RAM, as static strings are stored in RAM by default. 2012-11-28 10:30:34 +01:00
SdBaseFile.h Added long filename support. 2012-08-22 14:49:57 +02:00
SdFatConfig.h Added long filename support. 2012-08-22 14:49:57 +02:00
SdFatStructs.h Added long filename support. 2012-08-22 14:49:57 +02:00
SdFatUtil.cpp Updated SERIAL define to MYSERIAL, because Arduino 1.0 defines SERIAL as 0. 2012-02-11 16:02:47 +01:00
SdFatUtil.h made sd code only compile with SDSUPPORT defined. safes 10k of codespace 2011-12-26 09:28:51 +01:00
SdFile.cpp First cleanup. Moved all code to cpp files, so there are no dependencies on pde files. And no more odd requirement to cat files together. (Still need to fix the Makefile). Also cleaned up some defines and made defines upper case as by C coding conventions. 2012-11-06 12:06:41 +01:00
SdFile.h made sd code only compile with SDSUPPORT defined. safes 10k of codespace 2011-12-26 09:28:51 +01:00
SdInfo.h made sd code only compile with SDSUPPORT defined. safes 10k of codespace 2011-12-26 09:28:51 +01:00
SdVolume.cpp made sd code only compile with SDSUPPORT defined. safes 10k of codespace 2011-12-26 09:28:51 +01:00
SdVolume.h made sd code only compile with SDSUPPORT defined. safes 10k of codespace 2011-12-26 09:28:51 +01:00
Servo.cpp Bed Auto Leveling feature 2013-09-29 13:20:06 -03:00
Servo.h Various typo fixes - only in comments, no code changes. 2014-02-25 09:52:58 +00:00
speed_lookuptable.h Made the 2nd speed lookup table condition more explicit. 2012-11-11 12:02:48 +01:00
stepper.cpp Merge branch 'Marlin_v1' of github.com:ErikZalm/Marlin into Marlin_v1 2014-05-01 12:03:47 +02:00
stepper.h Various typo fixes - only in comments, no code changes. 2014-02-25 09:52:58 +00:00
temperature.cpp Fixed error found by the free coverity tool (https://scan.coverity.com/) 2014-05-14 21:59:48 +02:00
temperature.h Various typo fixes - only in comments, no code changes. 2014-02-25 09:52:58 +00:00
thermistortables.h Add 5DPrint D8 Driver Board info and temperature table for Makibox hot bed 2014-04-24 16:49:42 +08:00
ultralcd.cpp Merge branch 'Marlin_v1' of github.com:ErikZalm/Marlin into Marlin_v1 2014-05-01 12:03:47 +02:00
ultralcd.h Various typo fixes - only in comments, no code changes. 2014-02-17 13:04:44 +00:00
ultralcd_implementation_hitachi_HD44780.h Various typo fixes - only in comments, no code changes. 2014-02-17 13:04:44 +00:00
ultralcd_st7920_u8glib_rrd.h Various typo fixes - only in comments, no code changes. 2014-02-17 10:58:36 +00:00
vector_3.cpp Merge pull request #689 from cajun-rat/tidy 2014-02-12 16:38:11 +00:00
vector_3.h Fixed the plane vector equation to a simpler one (only dependent on the normal) 2013-12-06 21:32:21 +01:00
watchdog.cpp Fix compiling the watchdog error message when the manual reset watchdog is used. 2012-12-06 10:27:50 +01:00
watchdog.h Various typo fixes - only in comments, no code changes. 2014-02-17 10:58:36 +00:00