Skip to content

Commit 4812ed5

Browse files
committed
🎨 Misc. code cleanup
1 parent f89fa4c commit 4812ed5

File tree

13 files changed

+53
-52
lines changed

13 files changed

+53
-52
lines changed

Marlin/src/HAL/DUE/MinSerial.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,18 @@ void install_min_serial() {
7373
}
7474

7575
#if DISABLED(DYNAMIC_VECTORTABLE)
76-
extern "C" {
77-
__attribute__((naked)) void JumpHandler_ASM() {
78-
__asm__ __volatile__ (
79-
"b CommonHandler_ASM\n"
80-
);
76+
extern "C" {
77+
__attribute__((naked)) void JumpHandler_ASM() {
78+
__asm__ __volatile__ (
79+
"b CommonHandler_ASM\n"
80+
);
81+
}
82+
void __attribute__((naked, alias("JumpHandler_ASM"))) HardFault_Handler();
83+
void __attribute__((naked, alias("JumpHandler_ASM"))) BusFault_Handler();
84+
void __attribute__((naked, alias("JumpHandler_ASM"))) UsageFault_Handler();
85+
void __attribute__((naked, alias("JumpHandler_ASM"))) MemManage_Handler();
86+
void __attribute__((naked, alias("JumpHandler_ASM"))) NMI_Handler();
8187
}
82-
void __attribute__((naked, alias("JumpHandler_ASM"))) HardFault_Handler();
83-
void __attribute__((naked, alias("JumpHandler_ASM"))) BusFault_Handler();
84-
void __attribute__((naked, alias("JumpHandler_ASM"))) UsageFault_Handler();
85-
void __attribute__((naked, alias("JumpHandler_ASM"))) MemManage_Handler();
86-
void __attribute__((naked, alias("JumpHandler_ASM"))) NMI_Handler();
87-
}
8888
#endif
8989

9090
#endif // POSTMORTEM_DEBUGGING

Marlin/src/HAL/LPC1768/MinSerial.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ static void TX(char c) { _DBC(c); }
3333
void install_min_serial() { HAL_min_serial_out = &TX; }
3434

3535
#if DISABLED(DYNAMIC_VECTORTABLE)
36-
extern "C" {
37-
__attribute__((naked)) void JumpHandler_ASM() {
38-
__asm__ __volatile__ (
39-
"b CommonHandler_ASM\n"
40-
);
36+
extern "C" {
37+
__attribute__((naked)) void JumpHandler_ASM() {
38+
__asm__ __volatile__ (
39+
"b CommonHandler_ASM\n"
40+
);
41+
}
42+
void __attribute__((naked, alias("JumpHandler_ASM"))) HardFault_Handler();
43+
void __attribute__((naked, alias("JumpHandler_ASM"))) BusFault_Handler();
44+
void __attribute__((naked, alias("JumpHandler_ASM"))) UsageFault_Handler();
45+
void __attribute__((naked, alias("JumpHandler_ASM"))) MemManage_Handler();
46+
void __attribute__((naked, alias("JumpHandler_ASM"))) NMI_Handler();
4147
}
42-
void __attribute__((naked, alias("JumpHandler_ASM"))) HardFault_Handler();
43-
void __attribute__((naked, alias("JumpHandler_ASM"))) BusFault_Handler();
44-
void __attribute__((naked, alias("JumpHandler_ASM"))) UsageFault_Handler();
45-
void __attribute__((naked, alias("JumpHandler_ASM"))) MemManage_Handler();
46-
void __attribute__((naked, alias("JumpHandler_ASM"))) NMI_Handler();
47-
}
4848
#endif
4949

5050
#endif // POSTMORTEM_DEBUGGING

Marlin/src/HAL/STM32/MinSerial.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,18 @@ void install_min_serial() {
135135
}
136136

137137
#if NONE(DYNAMIC_VECTORTABLE, STM32F0xx, STM32G0xx) // Cortex M0 can't jump to a symbol that's too far from the current function, so we work around this in exception_arm.cpp
138-
extern "C" {
139-
__attribute__((naked)) void JumpHandler_ASM() {
140-
__asm__ __volatile__ (
141-
"b CommonHandler_ASM\n"
142-
);
138+
extern "C" {
139+
__attribute__((naked)) void JumpHandler_ASM() {
140+
__asm__ __volatile__ (
141+
"b CommonHandler_ASM\n"
142+
);
143+
}
144+
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) HardFault_Handler();
145+
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) BusFault_Handler();
146+
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) UsageFault_Handler();
147+
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) MemManage_Handler();
148+
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) NMI_Handler();
143149
}
144-
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) HardFault_Handler();
145-
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) BusFault_Handler();
146-
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) UsageFault_Handler();
147-
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) MemManage_Handler();
148-
void __attribute__((naked, alias("JumpHandler_ASM"), nothrow)) NMI_Handler();
149-
}
150150
#endif
151151

152152
#endif // POSTMORTEM_DEBUGGING

Marlin/src/feature/pause.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool
445445
// Wait for buffered blocks to complete
446446
planner.synchronize();
447447

448-
#if ENABLED(ADVANCED_PAUSE_FANS_PAUSE) && HAS_FAN
448+
#if BOTH(ADVANCED_PAUSE_FANS_PAUSE, HAS_FAN)
449449
thermalManager.set_fans_paused(true);
450450
#endif
451451

Marlin/src/feature/runout.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,13 @@ class FilamentSensorBase {
191191
public:
192192
static void setup() {
193193
#define _INIT_RUNOUT_PIN(P,S,U,D) do{ if (ENABLED(U)) SET_INPUT_PULLUP(P); else if (ENABLED(D)) SET_INPUT_PULLDOWN(P); else SET_INPUT(P); }while(0);
194-
#define INIT_RUNOUT_PIN(N) _INIT_RUNOUT_PIN(FIL_RUNOUT##N##_PIN, FIL_RUNOUT##N##_STATE, FIL_RUNOUT##N##_PULLUP, FIL_RUNOUT##N##_PULLDOWN)
195-
REPEAT_1(NUM_RUNOUT_SENSORS, INIT_RUNOUT_PIN);
194+
#define INIT_RUNOUT_PIN(N) _INIT_RUNOUT_PIN(FIL_RUNOUT##N##_PIN, FIL_RUNOUT##N##_STATE, FIL_RUNOUT##N##_PULLUP, FIL_RUNOUT##N##_PULLDOWN);
195+
REPEAT_1(NUM_RUNOUT_SENSORS, INIT_RUNOUT_PIN)
196196
#undef INIT_RUNOUT_PIN
197197

198198
#if ENABLED(FILAMENT_SWITCH_AND_MOTION)
199-
#define INIT_MOTION_PIN(N) _INIT_RUNOUT_PIN(FIL_MOTION##N##_PIN, FIL_MOTION##N##_STATE, FIL_MOTION##N##_PULLUP, FIL_MOTION##N##_PULLDOWN)
200-
REPEAT_1(NUM_MOTION_SENSORS, INIT_MOTION_PIN);
199+
#define INIT_MOTION_PIN(N) _INIT_RUNOUT_PIN(FIL_MOTION##N##_PIN, FIL_MOTION##N##_STATE, FIL_MOTION##N##_PULLUP, FIL_MOTION##N##_PULLDOWN);
200+
REPEAT_1(NUM_MOTION_SENSORS, INIT_MOTION_PIN)
201201
#undef INIT_MOTION_PIN
202202
#endif
203203
#undef _INIT_RUNOUT_PIN
@@ -212,9 +212,9 @@ class FilamentSensorBase {
212212

213213
// Return a bitmask of runout flag states (1 bits always indicates runout)
214214
static uint8_t poll_runout_states() {
215-
#define _OR_RUNOUT(N) | (FIL_RUNOUT##N##_STATE ? 0 : _BV(N - 1))
216-
return poll_runout_pins() ^ uint8_t(0 REPEAT_1(NUM_RUNOUT_SENSORS, _OR_RUNOUT));
217-
#undef _OR_RUNOUT
215+
#define _INVERT_BIT(N) | (FIL_RUNOUT##N##_STATE ? 0 : _BV(N - 1))
216+
return poll_runout_pins() ^ uint8_t(0 REPEAT_1(NUM_RUNOUT_SENSORS, _INVERT_BIT));
217+
#undef _INVERT_BIT
218218
}
219219

220220
#if ENABLED(FILAMENT_SWITCH_AND_MOTION)

Marlin/src/gcode/queue.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ PGM_P GCodeQueue::injected_commands_P; // = nullptr
9999
*/
100100
char GCodeQueue::injected_commands[64]; // = { 0 }
101101

102-
void GCodeQueue::RingBuffer::commit_command(bool skip_ok
102+
void GCodeQueue::RingBuffer::commit_command(const bool skip_ok
103103
OPTARG(HAS_MULTI_SERIAL, serial_index_t serial_ind/*=-1*/)
104104
) {
105105
commands[index_w].skip_ok = skip_ok;
@@ -113,7 +113,7 @@ void GCodeQueue::RingBuffer::commit_command(bool skip_ok
113113
* Return true if the command was successfully added.
114114
* Return false for a full buffer, or if the 'command' is a comment.
115115
*/
116-
bool GCodeQueue::RingBuffer::enqueue(const char *cmd, bool skip_ok/*=true*/
116+
bool GCodeQueue::RingBuffer::enqueue(const char *cmd, const bool skip_ok/*=true*/
117117
OPTARG(HAS_MULTI_SERIAL, serial_index_t serial_ind/*=-1*/)
118118
) {
119119
if (*cmd == ';' || length >= BUFSIZE) return false;

Marlin/src/gcode/queue.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ class GCodeQueue {
7979

8080
void advance_pos(uint8_t &p, const int inc) { if (++p >= BUFSIZE) p = 0; length += inc; }
8181

82-
void commit_command(bool skip_ok
82+
void commit_command(const bool skip_ok
8383
OPTARG(HAS_MULTI_SERIAL, serial_index_t serial_ind = serial_index_t())
8484
);
8585

86-
bool enqueue(const char *cmd, bool skip_ok = true
86+
bool enqueue(const char *cmd, const bool skip_ok=true
8787
OPTARG(HAS_MULTI_SERIAL, serial_index_t serial_ind = serial_index_t())
8888
);
8989

Marlin/src/lcd/extui/ia_creality/creality_extui.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ namespace ExtUI {
10661066
TPShowStatus = false;
10671067
ZERO(ChangeMaterialbuf);
10681068
ChangeMaterialbuf[1] = ChangeMaterialbuf[0] = 10;
1069-
RTS_SndData(10 * ChangeMaterialbuf[0], FilamentUnit1); // It's ChangeMaterialbuf for show,instead of current_position[E_AXIS] in them.
1069+
RTS_SndData(10 * ChangeMaterialbuf[0], FilamentUnit1); // It's ChangeMaterialbuf for show, instead of current_position.e in them.
10701070
RTS_SndData(10 * ChangeMaterialbuf[1], FilamentUnit2);
10711071
RTS_SndData(getActualTemp_celsius(H0), NozzleTemp);
10721072
RTS_SndData(getTargetTemp_celsius(H0), NozzlePreheat);
@@ -1381,7 +1381,7 @@ namespace ExtUI {
13811381
case 0xF0: // not to cancel heating
13821382
break;
13831383
}
1384-
RTS_SndData(10 * ChangeMaterialbuf[0], FilamentUnit1); // It's ChangeMaterialbuf for show,instead of current_position[E_AXIS] in them.
1384+
RTS_SndData(10 * ChangeMaterialbuf[0], FilamentUnit1); // It's ChangeMaterialbuf for show, instead of current_position.e in them.
13851385
RTS_SndData(10 * ChangeMaterialbuf[1], FilamentUnit2);
13861386
}
13871387
else if (recdat.addr == FilamentUnit1) {

Marlin/src/lcd/extui/ia_creality/ia_creality_extui.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@
3131
*
3232
* ***************************************/
3333

34-
#include "string.h"
3534
#include "../ui_api.h"
3635

36+
#include <string.h>
37+
3738
/*********************************/
3839
#define FHONE (0x5A)
3940
#define FHTWO (0xA5)

Marlin/src/lcd/extui/mks_ui/pic_manager.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
#if HAS_TFT_LVGL_UI
2626

27-
#include "string.h"
2827
#include "draw_ui.h"
2928
#include "pic_manager.h"
3029
#include "draw_ready_print.h"
@@ -34,6 +33,8 @@
3433
#include "../../../sd/cardreader.h"
3534
#include "../../../MarlinCore.h"
3635

36+
#include <string.h>
37+
3738
extern uint16_t DeviceCode;
3839

3940
#if HAS_MEDIA

buildroot/share/PlatformIO/variants/MARLIN_F103Rx/PeripheralPins.c

100755100644
File mode changed.

buildroot/share/PlatformIO/variants/MARLIN_F103Rx/PinNamesVar.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@
2727
#ifdef USBCON
2828
USB_DM = PA_11,
2929
USB_DP = PA_12,
30-
#endif
30+
#endif

buildroot/share/PlatformIO/variants/MARLIN_F407ZE/PeripheralPins.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ const PinMap PinMap_USB_OTG_HS[] = {
413413
*/
414414
{NC, NP, 0}
415415
};
416-
416+
#endif
417417

418418
#ifdef HAL_SD_MODULE_ENABLED
419419
WEAK const PinMap PinMap_SD[] = {
@@ -430,4 +430,3 @@ WEAK const PinMap PinMap_SD[] = {
430430
{NC, NP, 0}
431431
};
432432
#endif
433-
#endif

0 commit comments

Comments
 (0)