Skip to content

Commit fc56f1d

Browse files
thinkyheadJeremy Fairbanks
authored andcommitted
🚨 Fix some compiler warnings
1 parent f758073 commit fc56f1d

10 files changed

Lines changed: 41 additions & 25 deletions

File tree

Marlin/src/HAL/AVR/HAL.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
*/
2020
#pragma once
2121

22+
/**
23+
* HAL for Arduino AVR
24+
*/
25+
2226
#include "../shared/Marduino.h"
2327
#include "../shared/HAL_SPI.h"
2428
#include "fastio.h"

Marlin/src/core/serial_hook.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ class SerialMask {
4343
}
4444

4545
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; }
4749

4850
static constexpr uint8_t All = 0xFF;
4951
};

Marlin/src/core/types.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ struct Flags {
9191
void set(const int n) { b |= (bits_t)_BV(n); }
9292
void clear(const int n) { b &= ~(bits_t)_BV(n); }
9393
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); }
9797
};
9898

9999
// Specialization for a single bool flag
@@ -105,9 +105,9 @@ struct Flags<1> {
105105
void set(const int) { b = true; }
106106
void clear(const int) { b = false; }
107107
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); }
111111
};
112112

113113
typedef Flags<8> flags_8_t;
@@ -124,9 +124,9 @@ typedef struct AxisFlags {
124124
void set(const int n, const bool onoff) { flags.set(n, onoff); }
125125
void clear(const int n) { flags.clear(n); }
126126
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); }
130130
} axis_flags_t;
131131

132132
//

Marlin/src/gcode/config/M200-M205.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ void GcodeSuite::M201() {
135135

136136
LOOP_LOGICAL_AXES(i) {
137137
if (parser.seenval(AXIS_CHAR(i))) {
138-
const uint8_t a = TERN(HAS_EXTRUDERS, (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i), i);
139-
planner.set_max_acceleration(a, parser.value_axis_units((AxisEnum)a));
138+
const AxisEnum a = TERN(HAS_EXTRUDERS, (i == E_AXIS ? E_AXIS_N(target_extruder) : (AxisEnum)i), (AxisEnum)i);
139+
planner.set_max_acceleration(a, parser.value_axis_units(a));
140140
}
141141
}
142142
}
@@ -184,8 +184,8 @@ void GcodeSuite::M203() {
184184

185185
LOOP_LOGICAL_AXES(i)
186186
if (parser.seenval(AXIS_CHAR(i))) {
187-
const uint8_t a = TERN(HAS_EXTRUDERS, (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i), i);
188-
planner.set_max_feedrate(a, parser.value_axis_units((AxisEnum)a));
187+
const AxisEnum a = TERN(HAS_EXTRUDERS, (i == E_AXIS ? E_AXIS_N(target_extruder) : (AxisEnum)i), (AxisEnum)i);
188+
planner.set_max_feedrate(a, parser.value_axis_units(a));
189189
}
190190
}
191191

Marlin/src/lcd/extui/ui_api.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ namespace ExtUI {
656656
}
657657

658658
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);
660660
}
661661

662662
void setAxisMaxFeedrate_mm_s(const feedRate_t value, const extruder_t extruder) {
@@ -674,7 +674,7 @@ namespace ExtUI {
674674
}
675675

676676
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);
678678
}
679679

680680
void setAxisMaxAcceleration_mm_s2(const_float_t value, const extruder_t extruder) {

Marlin/src/module/motion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,7 @@ void prepare_line_to_destination() {
13991399
bool homing_needed_error(linear_axis_bits_t axis_bits/*=linear_bits*/) {
14001400
if ((axis_bits = axes_should_home(axis_bits))) {
14011401
PGM_P home_first = GET_TEXT(MSG_HOME_FIRST);
1402-
char msg[strlen_P(home_first)+1];
1402+
char msg[30];
14031403
sprintf_P(msg, home_first,
14041404
NUM_AXIS_LIST(
14051405
TEST(axis_bits, X_AXIS) ? STR_A : "",

Marlin/src/module/planner.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3292,7 +3292,7 @@ void Planner::refresh_positioning() {
32923292
}
32933293

32943294
// Apply limits to a variable and give a warning if the value was out of range
3295-
inline void limit_and_warn(float &val, const uint8_t axis, PGM_P const setting_name, const xyze_float_t &max_limit) {
3295+
inline void limit_and_warn(float &val, const AxisEnum axis, PGM_P const setting_name, const xyze_float_t &max_limit) {
32963296
const uint8_t lim_axis = TERN_(HAS_EXTRUDERS, axis > E_AXIS ? E_AXIS :) axis;
32973297
const float before = val;
32983298
LIMIT(val, 0.1, max_limit[lim_axis]);
@@ -3311,7 +3311,7 @@ inline void limit_and_warn(float &val, const uint8_t axis, PGM_P const setting_n
33113311
*
33123312
* This hard limit is applied as a block is being added to the planner queue.
33133313
*/
3314-
void Planner::set_max_acceleration(const uint8_t axis, float inMaxAccelMMS2) {
3314+
void Planner::set_max_acceleration(const AxisEnum axis, float inMaxAccelMMS2) {
33153315
#if ENABLED(LIMITED_MAX_ACCEL_EDITING)
33163316
#ifdef MAX_ACCEL_EDIT_VALUES
33173317
constexpr xyze_float_t max_accel_edit = MAX_ACCEL_EDIT_VALUES;
@@ -3334,7 +3334,7 @@ void Planner::set_max_acceleration(const uint8_t axis, float inMaxAccelMMS2) {
33343334
*
33353335
* This hard limit is applied as a block is being added to the planner queue.
33363336
*/
3337-
void Planner::set_max_feedrate(const uint8_t axis, float inMaxFeedrateMMS) {
3337+
void Planner::set_max_feedrate(const AxisEnum axis, float inMaxFeedrateMMS) {
33383338
#if ENABLED(LIMITED_MAX_FR_EDITING)
33393339
#ifdef MAX_FEEDRATE_EDIT_VALUES
33403340
constexpr xyze_float_t max_fr_edit = MAX_FEEDRATE_EDIT_VALUES;

Marlin/src/module/planner.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,10 +501,10 @@ class Planner {
501501
static void refresh_positioning();
502502

503503
// 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);
505505

506506
// 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);
508508

509509
// For an axis set the Maximum Jerk (instant change) in mm/s
510510
#if HAS_CLASSIC_JERK

Marlin/src/module/temperature.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ volatile bool Temperature::raw_temps_ready = false;
751751
// Report heater states every 2 seconds
752752
if (ELAPSED(ms, next_temp_ms)) {
753753
#if HAS_TEMP_SENSOR
754-
print_heater_states(ischamber ? active_extruder : (isbed ? active_extruder : heater_id));
754+
print_heater_states(heater_id < 0 ? active_extruder : (int8_t)heater_id);
755755
SERIAL_EOL();
756756
#endif
757757
next_temp_ms = ms + 2000UL;
@@ -2817,6 +2817,9 @@ void Temperature::init() {
28172817

28182818
#if HAS_THERMAL_PROTECTION
28192819

2820+
#pragma GCC diagnostic push
2821+
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
2822+
28202823
Temperature::tr_state_machine_t Temperature::tr_state_machine[NR_HEATER_RUNAWAY]; // = { { TRInactive, 0 } };
28212824

28222825
/**
@@ -2946,6 +2949,8 @@ void Temperature::init() {
29462949
}
29472950
}
29482951

2952+
#pragma GCC diagnostic pop
2953+
29492954
#endif // HAS_THERMAL_PROTECTION
29502955

29512956
void Temperature::disable_all_heaters() {
@@ -3669,6 +3674,9 @@ void Temperature::isr() {
36693674

36703675
switch (adc_sensor_state) {
36713676

3677+
#pragma GCC diagnostic push
3678+
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
3679+
36723680
case SensorsReady: {
36733681
// All sensors have been read. Stay in this state for a few
36743682
// ISRs to save on calls to temp update/checking code below.
@@ -3686,6 +3694,8 @@ void Temperature::isr() {
36863694
}
36873695
}
36883696

3697+
#pragma GCC diagnostic pop
3698+
36893699
case StartSampling: // Start of sampling loops. Do updates/checks.
36903700
if (++temp_count >= OVERSAMPLENR) { // 10 * 16 * 1/(16000000/64/256) = 164ms.
36913701
temp_count = 0;
@@ -3917,7 +3927,7 @@ void Temperature::isr() {
39173927
delay(2);
39183928
}
39193929

3920-
void Temperature::print_heater_states(const uint8_t target_extruder
3930+
void Temperature::print_heater_states(const int8_t target_extruder
39213931
OPTARG(HAS_TEMP_REDUNDANT, const bool include_r/*=false*/)
39223932
) {
39233933
#if HAS_TEMP_HOTEND

Marlin/src/module/temperature.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ class Temperature {
995995
#endif // HEATER_IDLE_HANDLER
996996

997997
#if HAS_TEMP_SENSOR
998-
static void print_heater_states(const uint8_t target_extruder
998+
static void print_heater_states(const int8_t target_extruder
999999
OPTARG(HAS_TEMP_REDUNDANT, const bool include_r=false)
10001000
);
10011001
#if ENABLED(AUTO_REPORT_TEMPERATURES)

0 commit comments

Comments
 (0)