Browse Source

🚨 Fix some compiler warnings

Scott Lahteine 3 years ago
parent
commit
80810f1b18

+ 4
- 0
Marlin/src/HAL/AVR/HAL.h View File

19
  */
19
  */
20
 #pragma once
20
 #pragma once
21
 
21
 
22
+/**
23
+ * HAL for Arduino AVR
24
+ */
25
+
22
 #include "../shared/Marduino.h"
26
 #include "../shared/Marduino.h"
23
 #include "../shared/HAL_SPI.h"
27
 #include "../shared/HAL_SPI.h"
24
 #include "fastio.h"
28
 #include "fastio.h"

+ 3
- 1
Marlin/src/core/serial_hook.h View File

43
   }
43
   }
44
 
44
 
45
   constexpr SerialMask(const uint8_t mask) : mask(mask) {}
45
   constexpr SerialMask(const uint8_t mask) : mask(mask) {}
46
-  constexpr SerialMask(const SerialMask & other) : mask(other.mask) {} // Can't use = default here since not all framework support this
46
+  constexpr SerialMask(const SerialMask &rs) : mask(rs.mask) {} // Can't use = default here since not all frameworks support this
47
+
48
+  SerialMask& operator=(const SerialMask &rs) { mask = rs.mask; return *this; }
47
 
49
 
48
   static constexpr uint8_t All = 0xFF;
50
   static constexpr uint8_t All = 0xFF;
49
 };
51
 };

+ 9
- 9
Marlin/src/core/types.h View File

91
   void set(const int n)                    { b |=  (bits_t)_BV(n); }
91
   void set(const int n)                    { b |=  (bits_t)_BV(n); }
92
   void clear(const int n)                  { b &= ~(bits_t)_BV(n); }
92
   void clear(const int n)                  { b &= ~(bits_t)_BV(n); }
93
   bool test(const int n) const             { return TEST(b, n); }
93
   bool test(const int n) const             { return TEST(b, n); }
94
-        bool operator[](const int n)       { return test(n); }
95
-  const bool operator[](const int n) const { return test(n); }
96
-  const int size() const                   { return sizeof(b); }
94
+  bool operator[](const int n)             { return test(n); }
95
+  bool operator[](const int n) const       { return test(n); }
96
+  int size() const                         { return sizeof(b); }
97
 };
97
 };
98
 
98
 
99
 // Specialization for a single bool flag
99
 // Specialization for a single bool flag
105
   void set(const int)                     { b = true; }
105
   void set(const int)                     { b = true; }
106
   void clear(const int)                   { b = false; }
106
   void clear(const int)                   { b = false; }
107
   bool test(const int) const              { return b; }
107
   bool test(const int) const              { return b; }
108
-        bool operator[](const int)        { return b; }
109
-  const bool operator[](const int) const  { return b; }
110
-  const int size() const                  { return sizeof(b); }
108
+  bool operator[](const int)              { return b; }
109
+  bool operator[](const int) const        { return b; }
110
+  int size() const                        { return sizeof(b); }
111
 };
111
 };
112
 
112
 
113
 typedef Flags<8> flags_8_t;
113
 typedef Flags<8> flags_8_t;
124
   void set(const int n, const bool onoff)  { flags.set(n, onoff); }
124
   void set(const int n, const bool onoff)  { flags.set(n, onoff); }
125
   void clear(const int n)                  { flags.clear(n); }
125
   void clear(const int n)                  { flags.clear(n); }
126
   bool test(const int n) const             { return flags.test(n); }
126
   bool test(const int n) const             { return flags.test(n); }
127
-        bool operator[](const int n)       { return flags[n]; }
128
-  const bool operator[](const int n) const { return flags[n]; }
129
-  const int size() const                   { return sizeof(flags); }
127
+  bool operator[](const int n)             { return flags[n]; }
128
+  bool operator[](const int n) const       { return flags[n]; }
129
+  int size() const                         { return sizeof(flags); }
130
 } axis_flags_t;
130
 } axis_flags_t;
131
 
131
 
132
 //
132
 //

+ 4
- 4
Marlin/src/gcode/config/M200-M205.cpp View File

126
 
126
 
127
   LOOP_LOGICAL_AXES(i) {
127
   LOOP_LOGICAL_AXES(i) {
128
     if (parser.seenval(AXIS_CHAR(i))) {
128
     if (parser.seenval(AXIS_CHAR(i))) {
129
-      const uint8_t a = TERN(HAS_EXTRUDERS, (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i), i);
130
-      planner.set_max_acceleration(a, parser.value_axis_units((AxisEnum)a));
129
+      const AxisEnum a = TERN(HAS_EXTRUDERS, (i == E_AXIS ? E_AXIS_N(target_extruder) : (AxisEnum)i), (AxisEnum)i);
130
+      planner.set_max_acceleration(a, parser.value_axis_units(a));
131
     }
131
     }
132
   }
132
   }
133
 }
133
 }
175
 
175
 
176
   LOOP_LOGICAL_AXES(i)
176
   LOOP_LOGICAL_AXES(i)
177
     if (parser.seenval(AXIS_CHAR(i))) {
177
     if (parser.seenval(AXIS_CHAR(i))) {
178
-      const uint8_t a = TERN(HAS_EXTRUDERS, (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i), i);
179
-      planner.set_max_feedrate(a, parser.value_axis_units((AxisEnum)a));
178
+      const AxisEnum a = TERN(HAS_EXTRUDERS, (i == E_AXIS ? E_AXIS_N(target_extruder) : (AxisEnum)i), (AxisEnum)i);
179
+      planner.set_max_feedrate(a, parser.value_axis_units(a));
180
     }
180
     }
181
 }
181
 }
182
 
182
 

+ 2
- 2
Marlin/src/lcd/extui/ui_api.cpp View File

656
   }
656
   }
657
 
657
 
658
   void setAxisMaxFeedrate_mm_s(const feedRate_t value, const axis_t axis) {
658
   void setAxisMaxFeedrate_mm_s(const feedRate_t value, const axis_t axis) {
659
-    planner.set_max_feedrate(axis, value);
659
+    planner.set_max_feedrate((AxisEnum)axis, value);
660
   }
660
   }
661
 
661
 
662
   void setAxisMaxFeedrate_mm_s(const feedRate_t value, const extruder_t extruder) {
662
   void setAxisMaxFeedrate_mm_s(const feedRate_t value, const extruder_t extruder) {
674
   }
674
   }
675
 
675
 
676
   void setAxisMaxAcceleration_mm_s2(const_float_t value, const axis_t axis) {
676
   void setAxisMaxAcceleration_mm_s2(const_float_t value, const axis_t axis) {
677
-    planner.set_max_acceleration(axis, value);
677
+    planner.set_max_acceleration((AxisEnum)axis, value);
678
   }
678
   }
679
 
679
 
680
   void setAxisMaxAcceleration_mm_s2(const_float_t value, const extruder_t extruder) {
680
   void setAxisMaxAcceleration_mm_s2(const_float_t value, const extruder_t extruder) {

+ 1
- 1
Marlin/src/module/motion.cpp View File

1399
   bool homing_needed_error(linear_axis_bits_t axis_bits/*=linear_bits*/) {
1399
   bool homing_needed_error(linear_axis_bits_t axis_bits/*=linear_bits*/) {
1400
     if ((axis_bits = axes_should_home(axis_bits))) {
1400
     if ((axis_bits = axes_should_home(axis_bits))) {
1401
       PGM_P home_first = GET_TEXT(MSG_HOME_FIRST);
1401
       PGM_P home_first = GET_TEXT(MSG_HOME_FIRST);
1402
-      char msg[strlen_P(home_first)+1];
1402
+      char msg[30];
1403
       sprintf_P(msg, home_first,
1403
       sprintf_P(msg, home_first,
1404
         NUM_AXIS_LIST(
1404
         NUM_AXIS_LIST(
1405
           TEST(axis_bits, X_AXIS) ? STR_A : "",
1405
           TEST(axis_bits, X_AXIS) ? STR_A : "",

+ 3
- 3
Marlin/src/module/planner.cpp View File

3303
 }
3303
 }
3304
 
3304
 
3305
 // Apply limits to a variable and give a warning if the value was out of range
3305
 // Apply limits to a variable and give a warning if the value was out of range
3306
-inline void limit_and_warn(float &val, const uint8_t axis, PGM_P const setting_name, const xyze_float_t &max_limit) {
3306
+inline void limit_and_warn(float &val, const AxisEnum axis, PGM_P const setting_name, const xyze_float_t &max_limit) {
3307
   const uint8_t lim_axis = TERN_(HAS_EXTRUDERS, axis > E_AXIS ? E_AXIS :) axis;
3307
   const uint8_t lim_axis = TERN_(HAS_EXTRUDERS, axis > E_AXIS ? E_AXIS :) axis;
3308
   const float before = val;
3308
   const float before = val;
3309
   LIMIT(val, 0.1, max_limit[lim_axis]);
3309
   LIMIT(val, 0.1, max_limit[lim_axis]);
3322
  *
3322
  *
3323
  * This hard limit is applied as a block is being added to the planner queue.
3323
  * This hard limit is applied as a block is being added to the planner queue.
3324
  */
3324
  */
3325
-void Planner::set_max_acceleration(const uint8_t axis, float inMaxAccelMMS2) {
3325
+void Planner::set_max_acceleration(const AxisEnum axis, float inMaxAccelMMS2) {
3326
   #if ENABLED(LIMITED_MAX_ACCEL_EDITING)
3326
   #if ENABLED(LIMITED_MAX_ACCEL_EDITING)
3327
     #ifdef MAX_ACCEL_EDIT_VALUES
3327
     #ifdef MAX_ACCEL_EDIT_VALUES
3328
       constexpr xyze_float_t max_accel_edit = MAX_ACCEL_EDIT_VALUES;
3328
       constexpr xyze_float_t max_accel_edit = MAX_ACCEL_EDIT_VALUES;
3345
  *
3345
  *
3346
  * This hard limit is applied as a block is being added to the planner queue.
3346
  * This hard limit is applied as a block is being added to the planner queue.
3347
  */
3347
  */
3348
-void Planner::set_max_feedrate(const uint8_t axis, float inMaxFeedrateMMS) {
3348
+void Planner::set_max_feedrate(const AxisEnum axis, float inMaxFeedrateMMS) {
3349
   #if ENABLED(LIMITED_MAX_FR_EDITING)
3349
   #if ENABLED(LIMITED_MAX_FR_EDITING)
3350
     #ifdef MAX_FEEDRATE_EDIT_VALUES
3350
     #ifdef MAX_FEEDRATE_EDIT_VALUES
3351
       constexpr xyze_float_t max_fr_edit = MAX_FEEDRATE_EDIT_VALUES;
3351
       constexpr xyze_float_t max_fr_edit = MAX_FEEDRATE_EDIT_VALUES;

+ 2
- 2
Marlin/src/module/planner.h View File

501
     static void refresh_positioning();
501
     static void refresh_positioning();
502
 
502
 
503
     // For an axis set the Maximum Acceleration in mm/s^2
503
     // For an axis set the Maximum Acceleration in mm/s^2
504
-    static void set_max_acceleration(const uint8_t axis, float inMaxAccelMMS2);
504
+    static void set_max_acceleration(const AxisEnum axis, float inMaxAccelMMS2);
505
 
505
 
506
     // For an axis set the Maximum Feedrate in mm/s
506
     // For an axis set the Maximum Feedrate in mm/s
507
-    static void set_max_feedrate(const uint8_t axis, float inMaxFeedrateMMS);
507
+    static void set_max_feedrate(const AxisEnum axis, float inMaxFeedrateMMS);
508
 
508
 
509
     // For an axis set the Maximum Jerk (instant change) in mm/s
509
     // For an axis set the Maximum Jerk (instant change) in mm/s
510
     #if HAS_CLASSIC_JERK
510
     #if HAS_CLASSIC_JERK

+ 12
- 2
Marlin/src/module/temperature.cpp View File

741
       // Report heater states every 2 seconds
741
       // Report heater states every 2 seconds
742
       if (ELAPSED(ms, next_temp_ms)) {
742
       if (ELAPSED(ms, next_temp_ms)) {
743
         #if HAS_TEMP_SENSOR
743
         #if HAS_TEMP_SENSOR
744
-          print_heater_states(ischamber ? active_extruder : (isbed ? active_extruder : heater_id));
744
+          print_heater_states(heater_id < 0 ? active_extruder : (int8_t)heater_id);
745
           SERIAL_EOL();
745
           SERIAL_EOL();
746
         #endif
746
         #endif
747
         next_temp_ms = ms + 2000UL;
747
         next_temp_ms = ms + 2000UL;
2809
 
2809
 
2810
 #if HAS_THERMAL_PROTECTION
2810
 #if HAS_THERMAL_PROTECTION
2811
 
2811
 
2812
+  #pragma GCC diagnostic push
2813
+  #pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
2814
+
2812
   Temperature::tr_state_machine_t Temperature::tr_state_machine[NR_HEATER_RUNAWAY]; // = { { TRInactive, 0 } };
2815
   Temperature::tr_state_machine_t Temperature::tr_state_machine[NR_HEATER_RUNAWAY]; // = { { TRInactive, 0 } };
2813
 
2816
 
2814
   /**
2817
   /**
2938
     }
2941
     }
2939
   }
2942
   }
2940
 
2943
 
2944
+  #pragma GCC diagnostic pop
2945
+
2941
 #endif // HAS_THERMAL_PROTECTION
2946
 #endif // HAS_THERMAL_PROTECTION
2942
 
2947
 
2943
 void Temperature::disable_all_heaters() {
2948
 void Temperature::disable_all_heaters() {
3652
 
3657
 
3653
   switch (adc_sensor_state) {
3658
   switch (adc_sensor_state) {
3654
 
3659
 
3660
+    #pragma GCC diagnostic push
3661
+    #pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
3662
+
3655
     case SensorsReady: {
3663
     case SensorsReady: {
3656
       // All sensors have been read. Stay in this state for a few
3664
       // All sensors have been read. Stay in this state for a few
3657
       // ISRs to save on calls to temp update/checking code below.
3665
       // ISRs to save on calls to temp update/checking code below.
3669
       }
3677
       }
3670
     }
3678
     }
3671
 
3679
 
3680
+    #pragma GCC diagnostic pop
3681
+
3672
     case StartSampling:                                   // Start of sampling loops. Do updates/checks.
3682
     case StartSampling:                                   // Start of sampling loops. Do updates/checks.
3673
       if (++temp_count >= OVERSAMPLENR) {                 // 10 * 16 * 1/(16000000/64/256)  = 164ms.
3683
       if (++temp_count >= OVERSAMPLENR) {                 // 10 * 16 * 1/(16000000/64/256)  = 164ms.
3674
         temp_count = 0;
3684
         temp_count = 0;
3900
     delay(2);
3910
     delay(2);
3901
   }
3911
   }
3902
 
3912
 
3903
-  void Temperature::print_heater_states(const uint8_t target_extruder
3913
+  void Temperature::print_heater_states(const int8_t target_extruder
3904
     OPTARG(HAS_TEMP_REDUNDANT, const bool include_r/*=false*/)
3914
     OPTARG(HAS_TEMP_REDUNDANT, const bool include_r/*=false*/)
3905
   ) {
3915
   ) {
3906
     #if HAS_TEMP_HOTEND
3916
     #if HAS_TEMP_HOTEND

+ 1
- 1
Marlin/src/module/temperature.h View File

986
     #endif // HEATER_IDLE_HANDLER
986
     #endif // HEATER_IDLE_HANDLER
987
 
987
 
988
     #if HAS_TEMP_SENSOR
988
     #if HAS_TEMP_SENSOR
989
-      static void print_heater_states(const uint8_t target_extruder
989
+      static void print_heater_states(const int8_t target_extruder
990
         OPTARG(HAS_TEMP_REDUNDANT, const bool include_r=false)
990
         OPTARG(HAS_TEMP_REDUNDANT, const bool include_r=false)
991
       );
991
       );
992
       #if ENABLED(AUTO_REPORT_TEMPERATURES)
992
       #if ENABLED(AUTO_REPORT_TEMPERATURES)

Loading…
Cancel
Save