Skip to content

Commit e53f4be

Browse files
GMagicianthinkyhead
authored andcommitted
🩹 Bail on 'mc.zip' write error (MarlinFirmware#25695)
Co-authored-by: Scott Lahteine <[email protected]>
1 parent 5b32795 commit e53f4be

File tree

6 files changed

+6
-15
lines changed

6 files changed

+6
-15
lines changed

Marlin/src/gcode/eeprom/M500-M504.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void GcodeSuite::M502() {
7373
bool success = true;
7474
for (uint16_t i = 0; success && i < sizeof(mc_zip); ++i) {
7575
const uint8_t c = pgm_read_byte(&mc_zip[i]);
76-
file.write(c);
76+
success = (file.write(c) == 1);
7777
}
7878
success = file.close() && success;
7979

Marlin/src/sd/SdBaseFile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2169,7 +2169,7 @@ bool SdBaseFile::truncate(uint32_t length) {
21692169
* include write() is called before a file has been opened, write is called
21702170
* for a read-only file, device is full, a corrupt file system or an I/O error.
21712171
*/
2172-
int16_t SdBaseFile::write(const void *buf, uint16_t nbyte) {
2172+
int16_t SdBaseFile::write(const void *buf, const uint16_t nbyte) {
21732173
#if ENABLED(SDCARD_READONLY)
21742174
writeError = true; return -1;
21752175
#endif

Marlin/src/sd/SdBaseFile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ class SdBaseFile {
345345
* \return SdVolume that contains this file.
346346
*/
347347
SdVolume* volume() const { return vol_; }
348-
int16_t write(const void *buf, uint16_t nbyte);
348+
int16_t write(const void *buf, const uint16_t nbyte);
349349

350350
private:
351351
friend class SdFat; // allow SdFat to set cwd_

Marlin/src/sd/SdFile.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,7 @@ int16_t SdFile::write(const void * const buf, const uint16_t nbyte) { return SdB
6767
* \param[in] b the byte to be written.
6868
* Use writeError to check for errors.
6969
*/
70-
#if ARDUINO >= 100
71-
size_t SdFile::write(const uint8_t b) { return SdBaseFile::write(&b, 1); }
72-
#else
73-
void SdFile::write(const uint8_t b) { SdBaseFile::write(&b, 1); }
74-
#endif
70+
size_t SdFile::write(const uint8_t b) { return SdBaseFile::write(&b, 1); }
7571

7672
/**
7773
* Write a string to a file. Used by the Arduino Print class.

Marlin/src/sd/SdFile.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,7 @@ class SdFile : public SdBaseFile {
4242
public:
4343
SdFile() {}
4444
SdFile(const char * const name, const uint8_t oflag);
45-
#if ARDUINO >= 100
46-
size_t write(const uint8_t b);
47-
#else
48-
void write(const uint8_t b);
49-
#endif
50-
45+
size_t write(const uint8_t b);
5146
int16_t write(const void * const buf, const uint16_t nbyte);
5247
void write(const char * const str);
5348
void write_P(PGM_P str);

buildroot/tests/STM32F103RE_creality

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ opt_enable DWIN_CREALITY_LCD_JYERSUI AUTO_BED_LEVELING_BILINEAR PROBE_MANUALLY
1919
exec_test $1 $2 "Ender-3 v2 with JyersUI" "$3"
2020

2121
use_example_configs "Creality/Ender-3 S1/STM32F1"
22-
opt_disable DWIN_CREALITY_LCD Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN AUTO_BED_LEVELING_BILINEAR CONFIGURATION_EMBEDDING CANCEL_OBJECTS FWRETRACT
22+
opt_disable DWIN_CREALITY_LCD Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN AUTO_BED_LEVELING_BILINEAR CANCEL_OBJECTS FWRETRACT
2323
opt_enable DWIN_LCD_PROUI INDIVIDUAL_AXIS_HOMING_SUBMENU SET_PROGRESS_MANUALLY SET_PROGRESS_PERCENT STATUS_MESSAGE_SCROLLING \
2424
SOUND_MENU_ITEM PRINTCOUNTER NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE FILAMENT_RUNOUT_SENSOR \
2525
BLTOUCH Z_SAFE_HOMING AUTO_BED_LEVELING_UBL MESH_EDIT_MENU \

0 commit comments

Comments
 (0)