Procházet zdrojové kódy

Merge pull request #1584 from galexander1/stringcleanup

fix a handful of cases where strtod() was cast to int, instead of just using strtol()
Scott Lahteine před 10 roky
rodič
revize
c321c97f35
1 změnil soubory, kde provedl 4 přidání a 4 odebrání
  1. 4
    4
      Marlin/Marlin_main.cpp

+ 4
- 4
Marlin/Marlin_main.cpp Zobrazit soubor

@@ -765,7 +765,7 @@ void get_command()
765 765
           while(cmdbuffer[bufindw][count] != '*') checksum = checksum^cmdbuffer[bufindw][count++];
766 766
           strchr_pointer = strchr(cmdbuffer[bufindw], '*');
767 767
 
768
-          if( (int)(strtod(strchr_pointer + 1, NULL)) != checksum) {
768
+          if(strtol(strchr_pointer + 1, NULL, 10) != checksum) {
769 769
             SERIAL_ERROR_START;
770 770
             SERIAL_ERRORPGM(MSG_ERR_CHECKSUM_MISMATCH);
771 771
             SERIAL_ERRORLN(gcode_LastN);
@@ -801,7 +801,7 @@ void get_command()
801 801
       }
802 802
       if((strchr(cmdbuffer[bufindw], 'G') != NULL)){
803 803
         strchr_pointer = strchr(cmdbuffer[bufindw], 'G');
804
-        switch((int)((strtod(strchr_pointer + 1, NULL)))){
804
+        switch(strtol(strchr_pointer + 1, NULL, 10)){
805 805
         case 0:
806 806
         case 1:
807 807
         case 2:
@@ -4198,7 +4198,7 @@ inline void gcode_M350() {
4198 4198
  */
4199 4199
 inline void gcode_M351() {
4200 4200
   #if defined(X_MS1_PIN) && X_MS1_PIN > -1
4201
-    if (code_seen('S')) switch((int)code_value()) {
4201
+    if (code_seen('S')) switch(code_value_long()) {
4202 4202
       case 1:
4203 4203
         for(int i=0;i<NUM_AXIS;i++) if (code_seen(axis_codes[i])) microstep_ms(i, code_value(), -1);
4204 4204
         if (code_seen('B')) microstep_ms(4, code_value(), -1);
@@ -4397,7 +4397,7 @@ void process_commands() {
4397 4397
   }
4398 4398
 
4399 4399
   else if (code_seen('M')) {
4400
-    switch( (int)code_value() ) {
4400
+    switch( code_value_long() ) {
4401 4401
       #ifdef ULTIPANEL
4402 4402
         case 0: // M0 - Unconditional stop - Wait for user button press on LCD
4403 4403
         case 1: // M1 - Conditional stop - Wait for user button press on LCD

Loading…
Zrušit
Uložit