Browse Source

misc. pointer formatting

Scott Lahteine 3 years ago
parent
commit
8b6718c632

+ 2
- 2
Marlin/src/HAL/DUE/eeprom_flash.cpp View File

@@ -135,7 +135,7 @@ static uint8_t buffer[256] = {0},   // The RAM buffer to accumulate writes
135 135
 #define DEBUG_OUT ENABLED(EE_EMU_DEBUG)
136 136
 #include "../../core/debug_out.h"
137 137
 
138
-static void ee_Dump(const int page, const void* data) {
138
+static void ee_Dump(const int page, const void *data) {
139 139
 
140 140
   #ifdef EE_EMU_DEBUG
141 141
 
@@ -181,7 +181,7 @@ static void ee_Dump(const int page, const void* data) {
181 181
  * @param data    (pointer to the data buffer)
182 182
  */
183 183
 __attribute__ ((long_call, section (".ramfunc")))
184
-static bool ee_PageWrite(uint16_t page, const void* data) {
184
+static bool ee_PageWrite(uint16_t page, const void *data) {
185 185
 
186 186
   uint16_t i;
187 187
   uint32_t addrflash = uint32_t(getFlashStorage(page));

+ 1
- 1
Marlin/src/HAL/ESP32/i2s.cpp View File

@@ -139,7 +139,7 @@ static void IRAM_ATTR i2s_intr_handler_default(void *arg) {
139 139
   I2S0.int_clr.val = I2S0.int_st.val; //clear pending interrupt
140 140
 }
141 141
 
142
-void stepperTask(void* parameter) {
142
+void stepperTask(void *parameter) {
143 143
   uint32_t remaining = 0;
144 144
 
145 145
   while (1) {

+ 1
- 1
Marlin/src/HAL/STM32/MarlinSerial.h View File

@@ -29,7 +29,7 @@
29 29
 typedef void (*usart_rx_callback_t)(serial_t * obj);
30 30
 
31 31
 struct MarlinSerial : public HardwareSerial {
32
-  MarlinSerial(void* peripheral, usart_rx_callback_t rx_callback) :
32
+  MarlinSerial(void *peripheral, usart_rx_callback_t rx_callback) :
33 33
       HardwareSerial(peripheral), _rx_callback(rx_callback)
34 34
   { }
35 35
 

+ 1
- 1
Marlin/src/HAL/STM32F1/onboard_sd.h View File

@@ -48,7 +48,7 @@ DRESULT disk_read(BYTE pdrv, BYTE* buff, DWORD sector, UINT count);
48 48
   DRESULT disk_write(BYTE pdrv, const BYTE* buff, DWORD sector, UINT count);
49 49
 #endif
50 50
 #if _DISKIO_IOCTL
51
-  DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void* buff);
51
+  DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void *buff);
52 52
 #endif
53 53
 
54 54
 /* Disk Status Bits (DSTATUS) */

+ 1
- 1
Marlin/src/HAL/shared/backtrace/backtrace.cpp View File

@@ -29,7 +29,7 @@
29 29
 #include <stdarg.h>
30 30
 
31 31
 // Dump a backtrace entry
32
-static bool UnwReportOut(void* ctx, const UnwReport* bte) {
32
+static bool UnwReportOut(void *ctx, const UnwReport *bte) {
33 33
   int *p = (int*)ctx;
34 34
 
35 35
   (*p)++;

+ 1
- 1
Marlin/src/HAL/shared/backtrace/unwinder.h View File

@@ -114,7 +114,7 @@ typedef struct {
114 114
  * report function maybe called again in future.  If false is returned,
115 115
  * unwinding will stop with UnwindStart() returning UNWIND_TRUNCATED.
116 116
  */
117
-typedef bool (*UnwindReportFunc)(void* data, const UnwReport* bte);
117
+typedef bool (*UnwindReportFunc)(void *data, const UnwReport *bte);
118 118
 
119 119
 /** Structure that holds memory callback function pointers.
120 120
  */

+ 1
- 1
Marlin/src/feature/spindle_laser.h View File

@@ -215,7 +215,7 @@ public:
215 215
   static inline void disable() { isReady = false; set_enabled(false); }
216 216
 
217 217
   #if HAS_LCD_MENU
218
-      static inline void enable_with_dir(const bool reverse) {
218
+    static inline void enable_with_dir(const bool reverse) {
219 219
       isReady = true;
220 220
       const uint8_t ocr = TERN(SPINDLE_LASER_PWM, upower_to_ocr(menuPower), 255);
221 221
       if (menuPower)

+ 2
- 2
Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp View File

@@ -70,7 +70,7 @@ void DGUSDisplay::InitDisplay() {
70 70
   RequestScreen(TERN(SHOW_BOOTSCREEN, DGUSLCD_SCREEN_BOOT, DGUSLCD_SCREEN_MAIN));
71 71
 }
72 72
 
73
-void DGUSDisplay::WriteVariable(uint16_t adr, const void* values, uint8_t valueslen, bool isstr) {
73
+void DGUSDisplay::WriteVariable(uint16_t adr, const void *values, uint8_t valueslen, bool isstr) {
74 74
   const char* myvalues = static_cast<const char*>(values);
75 75
   bool strend = !myvalues;
76 76
   WriteHeader(adr, DGUS_CMD_WRITEVAR, valueslen);
@@ -120,7 +120,7 @@ void DGUSDisplay::WriteVariable(uint16_t adr, long value) {
120 120
   WriteVariable(adr, static_cast<const void*>(&tmp), sizeof(long));
121 121
 }
122 122
 
123
-void DGUSDisplay::WriteVariablePGM(uint16_t adr, const void* values, uint8_t valueslen, bool isstr) {
123
+void DGUSDisplay::WriteVariablePGM(uint16_t adr, const void *values, uint8_t valueslen, bool isstr) {
124 124
   const char* myvalues = static_cast<const char*>(values);
125 125
   bool strend = !myvalues;
126 126
   WriteHeader(adr, DGUS_CMD_WRITEVAR, valueslen);

+ 2
- 2
Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h View File

@@ -56,8 +56,8 @@ public:
56 56
   static void InitDisplay();
57 57
 
58 58
   // Variable access.
59
-  static void WriteVariable(uint16_t adr, const void* values, uint8_t valueslen, bool isstr=false);
60
-  static void WriteVariablePGM(uint16_t adr, const void* values, uint8_t valueslen, bool isstr=false);
59
+  static void WriteVariable(uint16_t adr, const void *values, uint8_t valueslen, bool isstr=false);
60
+  static void WriteVariablePGM(uint16_t adr, const void *values, uint8_t valueslen, bool isstr=false);
61 61
   static void WriteVariable(uint16_t adr, int16_t value);
62 62
   static void WriteVariable(uint16_t adr, uint16_t value);
63 63
   static void WriteVariable(uint16_t adr, uint8_t value);

+ 1
- 1
Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp View File

@@ -75,7 +75,7 @@ void DGUSScreenHandler::sendinfoscreen_en_mks(const char *line1, const char *lin
75 75
   dgusdisplay.WriteVariable(VP_MSGSTR4, line4, 32, true);
76 76
 }
77 77
 
78
-void DGUSScreenHandler::sendinfoscreen_mks(const void* line1, const void* line2, const void* line3, const void* line4, uint16_t language) {
78
+void DGUSScreenHandler::sendinfoscreen_mks(const void *line1, const void *line2, const void *line3, const void *line4, uint16_t language) {
79 79
   if (language == MKS_English)
80 80
     DGUSScreenHandler::sendinfoscreen_en_mks((char *)line1, (char *)line2, (char *)line3, (char *)line4);
81 81
   else if (language == MKS_SimpleChinese)

+ 1
- 1
Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h View File

@@ -44,7 +44,7 @@ public:
44 44
   #if 0
45 45
   static void sendinfoscreen_ch_mks(const uint16_t *line1, const uint16_t *line2, const uint16_t *line3, const uint16_t *line4);
46 46
   static void sendinfoscreen_en_mks(const char *line1, const char *line2, const char *line3, const char *line4) ;
47
-  static void sendinfoscreen_mks(const void* line1, const void* line2, const void* line3, const void* line4,uint16_t language);
47
+  static void sendinfoscreen_mks(const void *line1, const void *line2, const void *line3, const void *line4, uint16_t language);
48 48
   #endif
49 49
 
50 50
   // "M117" Message -- msg is a RAM ptr.

+ 1
- 1
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp View File

@@ -229,7 +229,7 @@ void CLCD::CommandFifo::cmd(uint32_t cmd32) {
229 229
   write((void*)&cmd32, sizeof(uint32_t));
230 230
 }
231 231
 
232
-void CLCD::CommandFifo::cmd(void* data, uint16_t len) {
232
+void CLCD::CommandFifo::cmd(void *data, uint16_t len) {
233 233
   write(data, len);
234 234
 }
235 235
 

+ 1
- 1
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.h View File

@@ -196,7 +196,7 @@ class CLCD::CommandFifo {
196 196
     void execute();
197 197
 
198 198
     void cmd(uint32_t cmd32);
199
-    void cmd(void* data, uint16_t len);
199
+    void cmd(void *data, uint16_t len);
200 200
 
201 201
     void dlstart()      {cmd(FTDI::CMD_DLSTART);}
202 202
     void swap()         {cmd(FTDI::CMD_SWAP);}

+ 1
- 1
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/command_processor.h View File

@@ -149,7 +149,7 @@ class CommandProcessor : public CLCD::CommandFifo {
149 149
     // Wrap all the CommandFifo routines to allow method chaining
150 150
 
151 151
     inline CommandProcessor& cmd      (uint32_t cmd32)            {CLCD::CommandFifo::cmd(cmd32); return *this;}
152
-    inline CommandProcessor& cmd      (void* data, uint16_t len)  {CLCD::CommandFifo::cmd(data, len); return *this;}
152
+    inline CommandProcessor& cmd      (void *data, uint16_t len)  {CLCD::CommandFifo::cmd(data, len); return *this;}
153 153
     inline CommandProcessor& execute()                            {CLCD::CommandFifo::execute(); return *this;}
154 154
 
155 155
     inline CommandProcessor& fgcolor  (uint32_t rgb)              {CLCD::CommandFifo::fgcolor(rgb); return *this;}

+ 1
- 1
Marlin/src/sd/Sd2Card.cpp View File

@@ -477,7 +477,7 @@ bool Sd2Card::readData(uint8_t *dst, const uint16_t count) {
477 477
 }
478 478
 
479 479
 /** read CID or CSR register */
480
-bool Sd2Card::readRegister(const uint8_t cmd, void* buf) {
480
+bool Sd2Card::readRegister(const uint8_t cmd, void *buf) {
481 481
   uint8_t *dst = reinterpret_cast<uint8_t*>(buf);
482 482
   if (cardCommand(cmd, 0)) {
483 483
     error(SD_CARD_ERROR_READ_REG);

+ 1
- 1
Marlin/src/sd/Sd2Card.h View File

@@ -177,7 +177,7 @@ private:
177 177
   uint8_t cardCommand(const uint8_t cmd, const uint32_t arg);
178 178
 
179 179
   bool readData(uint8_t *dst, const uint16_t count);
180
-  bool readRegister(const uint8_t cmd, void* buf);
180
+  bool readRegister(const uint8_t cmd, void *buf);
181 181
   void chipDeselect();
182 182
   void chipSelect();
183 183
   inline void type(const uint8_t value) { type_ = value; }

+ 34
- 48
Marlin/src/sd/SdBaseFile.cpp View File

@@ -40,7 +40,7 @@
40 40
 #include "SdBaseFile.h"
41 41
 
42 42
 #include "../MarlinCore.h"
43
-SdBaseFile* SdBaseFile::cwd_ = 0;   // Pointer to Current Working Directory
43
+SdBaseFile *SdBaseFile::cwd_ = 0;   // Pointer to Current Working Directory
44 44
 
45 45
 // callback function for date/time
46 46
 void (*SdBaseFile::dateTime_)(uint16_t *date, uint16_t *time) = 0;
@@ -155,7 +155,7 @@ bool SdBaseFile::contiguousRange(uint32_t *bgnBlock, uint32_t *endBlock) {
155 155
  * a file is already open, the file already exists, the root
156 156
  * directory is full or an I/O error.
157 157
  */
158
-bool SdBaseFile::createContiguous(SdBaseFile* dirFile, const char *path, uint32_t size) {
158
+bool SdBaseFile::createContiguous(SdBaseFile *dirFile, const char *path, uint32_t size) {
159 159
   if (ENABLED(SDCARD_READONLY)) return false;
160 160
 
161 161
   uint32_t count;
@@ -187,12 +187,11 @@ bool SdBaseFile::createContiguous(SdBaseFile* dirFile, const char *path, uint32_
187 187
  * \return true for success, false for failure.
188 188
  */
189 189
 bool SdBaseFile::dirEntry(dir_t *dir) {
190
-  dir_t *p;
191 190
   // make sure fields on SD are correct
192 191
   if (!sync()) return false;
193 192
 
194 193
   // read entry
195
-  p = cacheDirEntry(SdVolume::CACHE_FOR_READ);
194
+  dir_t *p = cacheDirEntry(SdVolume::CACHE_FOR_READ);
196 195
   if (!p) return false;
197 196
 
198 197
   // copy to caller's struct
@@ -207,7 +206,7 @@ bool SdBaseFile::dirEntry(dir_t *dir) {
207 206
  * \param[in] dir The directory structure containing the name.
208 207
  * \param[out] name A 13 byte char array for the formatted name.
209 208
  */
210
-void SdBaseFile::dirName(const dir_t& dir, char *name) {
209
+void SdBaseFile::dirName(const dir_t &dir, char *name) {
211 210
   uint8_t j = 0;
212 211
   LOOP_L_N(i, 11) {
213 212
     if (dir.name[i] == ' ')continue;
@@ -386,7 +385,7 @@ int8_t SdBaseFile::lsPrintNext(uint8_t flags, uint8_t indent) {
386 385
 }
387 386
 
388 387
 // Format directory name field from a 8.3 name string
389
-bool SdBaseFile::make83Name(const char *str, uint8_t *name, const char** ptr) {
388
+bool SdBaseFile::make83Name(const char *str, uint8_t *name, const char **ptr) {
390 389
   uint8_t n = 7,                      // Max index until a dot is found
391 390
           i = 11;
392 391
   while (i) name[--i] = ' ';          // Set whole FILENAME.EXT to spaces
@@ -423,13 +422,13 @@ bool SdBaseFile::make83Name(const char *str, uint8_t *name, const char** ptr) {
423 422
  * Reasons for failure include this file is already open, \a parent is not a
424 423
  * directory, \a path is invalid or already exists in \a parent.
425 424
  */
426
-bool SdBaseFile::mkdir(SdBaseFile* parent, const char *path, bool pFlag) {
425
+bool SdBaseFile::mkdir(SdBaseFile *parent, const char *path, bool pFlag) {
427 426
   if (ENABLED(SDCARD_READONLY)) return false;
428 427
 
429 428
   uint8_t dname[11];
430 429
   SdBaseFile dir1, dir2;
431
-  SdBaseFile* sub = &dir1;
432
-  SdBaseFile* start = parent;
430
+  SdBaseFile *sub = &dir1;
431
+  SdBaseFile *start = parent;
433 432
 
434 433
   if (!parent || isOpen()) return false;
435 434
 
@@ -455,13 +454,9 @@ bool SdBaseFile::mkdir(SdBaseFile* parent, const char *path, bool pFlag) {
455 454
   return mkdir(parent, dname);
456 455
 }
457 456
 
458
-bool SdBaseFile::mkdir(SdBaseFile* parent, const uint8_t dname[11]) {
457
+bool SdBaseFile::mkdir(SdBaseFile *parent, const uint8_t dname[11]) {
459 458
   if (ENABLED(SDCARD_READONLY)) return false;
460 459
 
461
-  uint32_t block;
462
-  dir_t d;
463
-  dir_t *p;
464
-
465 460
   if (!parent->isDir()) return false;
466 461
 
467 462
   // create a normal file
@@ -478,19 +473,20 @@ bool SdBaseFile::mkdir(SdBaseFile* parent, const uint8_t dname[11]) {
478 473
   if (!sync()) return false;
479 474
 
480 475
   // cache entry - should already be in cache due to sync() call
481
-  p = cacheDirEntry(SdVolume::CACHE_FOR_WRITE);
476
+  dir_t *p = cacheDirEntry(SdVolume::CACHE_FOR_WRITE);
482 477
   if (!p) return false;
483 478
 
484 479
   // change directory entry  attribute
485 480
   p->attributes = DIR_ATT_DIRECTORY;
486 481
 
487 482
   // make entry for '.'
483
+  dir_t d;
488 484
   memcpy(&d, p, sizeof(d));
489 485
   d.name[0] = '.';
490 486
   LOOP_S_L_N(i, 1, 11) d.name[i] = ' ';
491 487
 
492 488
   // cache block for '.'  and '..'
493
-  block = vol_->clusterStartBlock(firstCluster_);
489
+  uint32_t block = vol_->clusterStartBlock(firstCluster_);
494 490
   if (!vol_->cacheRawBlock(block, SdVolume::CACHE_FOR_WRITE)) return false;
495 491
 
496 492
   // copy '.' to block
@@ -577,7 +573,7 @@ bool SdBaseFile::open(const char *path, uint8_t oflag) {
577 573
  * a directory, \a path is invalid, the file does not exist
578 574
  * or can't be opened in the access mode specified by oflag.
579 575
  */
580
-bool SdBaseFile::open(SdBaseFile* dirFile, const char *path, uint8_t oflag) {
576
+bool SdBaseFile::open(SdBaseFile *dirFile, const char *path, uint8_t oflag) {
581 577
   uint8_t dname[11];
582 578
   SdBaseFile dir1, dir2;
583 579
   SdBaseFile *parent = dirFile, *sub = &dir1;
@@ -605,7 +601,7 @@ bool SdBaseFile::open(SdBaseFile* dirFile, const char *path, uint8_t oflag) {
605 601
 }
606 602
 
607 603
 // open with filename in dname
608
-bool SdBaseFile::open(SdBaseFile* dirFile, const uint8_t dname[11], uint8_t oflag) {
604
+bool SdBaseFile::open(SdBaseFile *dirFile, const uint8_t dname[11], uint8_t oflag) {
609 605
   bool emptyFound = false, fileFound = false;
610 606
   uint8_t index;
611 607
   dir_t *p;
@@ -696,9 +692,7 @@ bool SdBaseFile::open(SdBaseFile* dirFile, const uint8_t dname[11], uint8_t ofla
696 692
  * See open() by path for definition of flags.
697 693
  * \return true for success or false for failure.
698 694
  */
699
-bool SdBaseFile::open(SdBaseFile* dirFile, uint16_t index, uint8_t oflag) {
700
-  dir_t *p;
701
-
695
+bool SdBaseFile::open(SdBaseFile *dirFile, uint16_t index, uint8_t oflag) {
702 696
   vol_ = dirFile->vol_;
703 697
 
704 698
   // error if already open
@@ -711,7 +705,7 @@ bool SdBaseFile::open(SdBaseFile* dirFile, uint16_t index, uint8_t oflag) {
711 705
   if (!dirFile->seekSet(32 * index)) return false;
712 706
 
713 707
   // read entry into cache
714
-  p = dirFile->readDirCache();
708
+  dir_t *p = dirFile->readDirCache();
715 709
   if (!p) return false;
716 710
 
717 711
   // error if empty slot or '.' or '..'
@@ -784,10 +778,7 @@ bool SdBaseFile::openCachedEntry(uint8_t dirIndex, uint8_t oflag) {
784 778
  * See open() by path for definition of flags.
785 779
  * \return true for success or false for failure.
786 780
  */
787
-bool SdBaseFile::openNext(SdBaseFile* dirFile, uint8_t oflag) {
788
-  dir_t *p;
789
-  uint8_t index;
790
-
781
+bool SdBaseFile::openNext(SdBaseFile *dirFile, uint8_t oflag) {
791 782
   if (!dirFile) return false;
792 783
 
793 784
   // error if already open
@@ -796,10 +787,10 @@ bool SdBaseFile::openNext(SdBaseFile* dirFile, uint8_t oflag) {
796 787
   vol_ = dirFile->vol_;
797 788
 
798 789
   while (1) {
799
-    index = 0xF & (dirFile->curPosition_ >> 5);
790
+    uint8_t index = 0xF & (dirFile->curPosition_ >> 5);
800 791
 
801 792
     // read entry into cache
802
-    p = dirFile->readDirCache();
793
+    dir_t *p = dirFile->readDirCache();
803 794
     if (!p) return false;
804 795
 
805 796
     // done if last entry
@@ -825,9 +816,8 @@ bool SdBaseFile::openNext(SdBaseFile* dirFile, uint8_t oflag) {
825 816
  *
826 817
  * \return true for success, false for failure.
827 818
  */
828
-bool SdBaseFile::openParent(SdBaseFile* dir) {
819
+bool SdBaseFile::openParent(SdBaseFile *dir) {
829 820
   dir_t entry;
830
-  dir_t *p;
831 821
   SdBaseFile file;
832 822
   uint32_t c;
833 823
   uint32_t cluster;
@@ -850,7 +840,7 @@ bool SdBaseFile::openParent(SdBaseFile* dir) {
850 840
   // first block of parent dir
851 841
   if (!vol_->cacheRawBlock(lbn, SdVolume::CACHE_FOR_READ)) return false;
852 842
 
853
-  p = &vol_->cacheBuffer_.dir[1];
843
+  dir_t *p = &vol_->cacheBuffer_.dir[1];
854 844
   // verify name for '../..'
855 845
   if (p->name[0] != '.' || p->name[1] != '.') return false;
856 846
   // '..' is pointer to first cluster of parent. open '../..' to find parent
@@ -881,7 +871,7 @@ bool SdBaseFile::openParent(SdBaseFile* dir) {
881 871
  * Reasons for failure include the file is already open, the FAT volume has
882 872
  * not been initialized or it a FAT12 volume.
883 873
  */
884
-bool SdBaseFile::openRoot(SdVolume* vol) {
874
+bool SdBaseFile::openRoot(SdVolume *vol) {
885 875
   // error if file is already open
886 876
   if (isOpen()) return false;
887 877
 
@@ -1008,7 +998,7 @@ int16_t SdBaseFile::read() {
1008 998
  * read() called before a file has been opened, corrupt file system
1009 999
  * or an I/O error occurred.
1010 1000
  */
1011
-int16_t SdBaseFile::read(void* buf, uint16_t nbyte) {
1001
+int16_t SdBaseFile::read(void *buf, uint16_t nbyte) {
1012 1002
   uint8_t *dst = reinterpret_cast<uint8_t*>(buf);
1013 1003
   uint16_t offset, toRead;
1014 1004
   uint32_t block;  // raw device block number
@@ -1136,7 +1126,7 @@ int8_t SdBaseFile::readDir(dir_t *dir, char *longFilename) {
1136 1126
           // Reset n to the start of the long name
1137 1127
           n = 0;
1138 1128
           for (uint16_t idx = 0; idx < (LONG_FILENAME_LENGTH) / 2; idx += 2) {    // idx is fixed since FAT LFN always contains UTF-16LE encoding
1139
-            uint16_t utf16_ch = longFilename[idx] | (longFilename[idx + 1] << 8);
1129
+            const uint16_t utf16_ch = longFilename[idx] | (longFilename[idx + 1] << 8);
1140 1130
             if (0xD800 == (utf16_ch & 0xF800))                                    // Surrogate pair - encode as '_'
1141 1131
               longFilename[n++] = '_';
1142 1132
             else if (0 == (utf16_ch & 0xFF80))                                    // Encode as 1-byte UTF-8 char
@@ -1199,12 +1189,11 @@ dir_t* SdBaseFile::readDirCache() {
1199 1189
 bool SdBaseFile::remove() {
1200 1190
   if (ENABLED(SDCARD_READONLY)) return false;
1201 1191
 
1202
-  dir_t *d;
1203 1192
   // free any clusters - will fail if read-only or directory
1204 1193
   if (!truncate(0)) return false;
1205 1194
 
1206 1195
   // cache directory entry
1207
-  d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE);
1196
+  dir_t *d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE);
1208 1197
   if (!d) return false;
1209 1198
 
1210 1199
   // mark entry deleted
@@ -1235,7 +1224,7 @@ bool SdBaseFile::remove() {
1235 1224
  * \a dirFile is not a directory, \a path is not found
1236 1225
  * or an I/O error occurred.
1237 1226
  */
1238
-bool SdBaseFile::remove(SdBaseFile* dirFile, const char *path) {
1227
+bool SdBaseFile::remove(SdBaseFile *dirFile, const char *path) {
1239 1228
   if (ENABLED(SDCARD_READONLY)) return false;
1240 1229
 
1241 1230
   SdBaseFile file;
@@ -1252,13 +1241,10 @@ bool SdBaseFile::remove(SdBaseFile* dirFile, const char *path) {
1252 1241
  * Reasons for failure include \a dirFile is not open or is not a directory
1253 1242
  * file, newPath is invalid or already exists, or an I/O error occurs.
1254 1243
  */
1255
-bool SdBaseFile::rename(SdBaseFile* dirFile, const char *newPath) {
1244
+bool SdBaseFile::rename(SdBaseFile *dirFile, const char *newPath) {
1256 1245
   if (ENABLED(SDCARD_READONLY)) return false;
1257 1246
 
1258
-  dir_t entry;
1259 1247
   uint32_t dirCluster = 0;
1260
-  SdBaseFile file;
1261
-  dir_t *d;
1262 1248
 
1263 1249
   // must be an open file or subdirectory
1264 1250
   if (!(isFile() || isSubDir())) return false;
@@ -1268,16 +1254,18 @@ bool SdBaseFile::rename(SdBaseFile* dirFile, const char *newPath) {
1268 1254
 
1269 1255
   // sync() and cache directory entry
1270 1256
   sync();
1271
-  d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE);
1257
+  dir_t *d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE);
1272 1258
   if (!d) return false;
1273 1259
 
1274 1260
   // save directory entry
1261
+  dir_t entry;
1275 1262
   memcpy(&entry, d, sizeof(entry));
1276 1263
 
1277 1264
   // mark entry deleted
1278 1265
   d->name[0] = DIR_NAME_DELETED;
1279 1266
 
1280 1267
   // make directory entry for new path
1268
+  SdBaseFile file;
1281 1269
   if (isFile()) {
1282 1270
     if (!file.open(dirFile, newPath, O_CREAT | O_EXCL | O_WRITE)) {
1283 1271
       goto restore;
@@ -1536,8 +1524,7 @@ bool SdBaseFile::sync() {
1536 1524
  *
1537 1525
  * \return true for success, false for failure.
1538 1526
  */
1539
-bool SdBaseFile::timestamp(SdBaseFile* file) {
1540
-  dir_t *d;
1527
+bool SdBaseFile::timestamp(SdBaseFile *file) {
1541 1528
   dir_t dir;
1542 1529
 
1543 1530
   // get timestamps
@@ -1546,7 +1533,7 @@ bool SdBaseFile::timestamp(SdBaseFile* file) {
1546 1533
   // update directory fields
1547 1534
   if (!sync()) return false;
1548 1535
 
1549
-  d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE);
1536
+  dir_t *d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE);
1550 1537
   if (!d) return false;
1551 1538
 
1552 1539
   // copy timestamps
@@ -1599,7 +1586,6 @@ bool SdBaseFile::timestamp(uint8_t flags, uint16_t year, uint8_t month,
1599 1586
   if (ENABLED(SDCARD_READONLY)) return false;
1600 1587
 
1601 1588
   uint16_t dirDate, dirTime;
1602
-  dir_t *d;
1603 1589
 
1604 1590
   if (!isOpen()
1605 1591
       || year < 1980
@@ -1616,7 +1602,7 @@ bool SdBaseFile::timestamp(uint8_t flags, uint16_t year, uint8_t month,
1616 1602
   // update directory entry
1617 1603
   if (!sync()) return false;
1618 1604
 
1619
-  d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE);
1605
+  dir_t *d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE);
1620 1606
   if (!d) return false;
1621 1607
 
1622 1608
   dirDate = FAT_DATE(year, month, day);
@@ -1710,7 +1696,7 @@ bool SdBaseFile::truncate(uint32_t length) {
1710 1696
  * include write() is called before a file has been opened, write is called
1711 1697
  * for a read-only file, device is full, a corrupt file system or an I/O error.
1712 1698
  */
1713
-int16_t SdBaseFile::write(const void* buf, uint16_t nbyte) {
1699
+int16_t SdBaseFile::write(const void *buf, uint16_t nbyte) {
1714 1700
   #if ENABLED(SDCARD_READONLY)
1715 1701
     writeError = true; return -1;
1716 1702
   #endif

+ 18
- 18
Marlin/src/sd/SdBaseFile.h View File

@@ -189,7 +189,7 @@ class SdBaseFile {
189 189
 
190 190
   bool close();
191 191
   bool contiguousRange(uint32_t *bgnBlock, uint32_t *endBlock);
192
-  bool createContiguous(SdBaseFile* dirFile,
192
+  bool createContiguous(SdBaseFile *dirFile,
193 193
                         const char *path, uint32_t size);
194 194
   /**
195 195
    * \return The current cluster number for a file or directory.
@@ -204,7 +204,7 @@ class SdBaseFile {
204 204
   /**
205 205
    * \return Current working directory
206 206
    */
207
-  static SdBaseFile* cwd() { return cwd_; }
207
+  static SdBaseFile *cwd() { return cwd_; }
208 208
 
209 209
   /**
210 210
    * Set the date/time callback function
@@ -286,27 +286,27 @@ class SdBaseFile {
286 286
   bool getDosName(char * const name);
287 287
   void ls(uint8_t flags = 0, uint8_t indent = 0);
288 288
 
289
-  bool mkdir(SdBaseFile* dir, const char *path, bool pFlag = true);
290
-  bool open(SdBaseFile* dirFile, uint16_t index, uint8_t oflag);
291
-  bool open(SdBaseFile* dirFile, const char *path, uint8_t oflag);
289
+  bool mkdir(SdBaseFile *dir, const char *path, bool pFlag = true);
290
+  bool open(SdBaseFile *dirFile, uint16_t index, uint8_t oflag);
291
+  bool open(SdBaseFile *dirFile, const char *path, uint8_t oflag);
292 292
   bool open(const char *path, uint8_t oflag = O_READ);
293
-  bool openNext(SdBaseFile* dirFile, uint8_t oflag);
294
-  bool openRoot(SdVolume* vol);
293
+  bool openNext(SdBaseFile *dirFile, uint8_t oflag);
294
+  bool openRoot(SdVolume *vol);
295 295
   int peek();
296 296
   static void printFatDate(uint16_t fatDate);
297 297
   static void printFatTime(uint16_t fatTime);
298 298
   bool printName();
299 299
   int16_t read();
300
-  int16_t read(void* buf, uint16_t nbyte);
300
+  int16_t read(void *buf, uint16_t nbyte);
301 301
   int8_t readDir(dir_t *dir, char *longFilename);
302
-  static bool remove(SdBaseFile* dirFile, const char *path);
302
+  static bool remove(SdBaseFile *dirFile, const char *path);
303 303
   bool remove();
304 304
 
305 305
   /**
306 306
    * Set the file's current position to zero.
307 307
    */
308 308
   void rewind() { seekSet(0); }
309
-  bool rename(SdBaseFile* dirFile, const char *newPath);
309
+  bool rename(SdBaseFile *dirFile, const char *newPath);
310 310
   bool rmdir();
311 311
   bool rmRfStar();
312 312
 
@@ -325,7 +325,7 @@ class SdBaseFile {
325 325
   bool seekEnd(const int32_t offset = 0) { return seekSet(fileSize_ + offset); }
326 326
   bool seekSet(const uint32_t pos);
327 327
   bool sync();
328
-  bool timestamp(SdBaseFile* file);
328
+  bool timestamp(SdBaseFile *file);
329 329
   bool timestamp(uint8_t flag, uint16_t year, uint8_t month, uint8_t day,
330 330
                  uint8_t hour, uint8_t minute, uint8_t second);
331 331
 
@@ -341,11 +341,11 @@ class SdBaseFile {
341 341
    * \return SdVolume that contains this file.
342 342
    */
343 343
   SdVolume* volume() const { return vol_; }
344
-  int16_t write(const void* buf, uint16_t nbyte);
344
+  int16_t write(const void *buf, uint16_t nbyte);
345 345
 
346 346
  private:
347 347
   friend class SdFat;           // allow SdFat to set cwd_
348
-  static SdBaseFile* cwd_;      // global pointer to cwd dir
348
+  static SdBaseFile *cwd_;      // global pointer to cwd dir
349 349
 
350 350
   // data time callback function
351 351
   static void (*dateTime_)(uint16_t *date, uint16_t *time);
@@ -364,21 +364,21 @@ class SdBaseFile {
364 364
   uint8_t   dirIndex_;      // index of directory entry in dirBlock
365 365
   uint32_t  fileSize_;      // file size in bytes
366 366
   uint32_t  firstCluster_;  // first cluster of file
367
-  SdVolume* vol_;           // volume where file is located
367
+  SdVolume  *vol_;          // volume where file is located
368 368
 
369 369
   /**
370 370
    * EXPERIMENTAL - Don't use!
371 371
    */
372
-  //bool openParent(SdBaseFile* dir);
372
+  //bool openParent(SdBaseFile *dir);
373 373
 
374 374
   // private functions
375 375
   bool addCluster();
376 376
   bool addDirCluster();
377 377
   dir_t* cacheDirEntry(uint8_t action);
378 378
   int8_t lsPrintNext(uint8_t flags, uint8_t indent);
379
-  static bool make83Name(const char *str, uint8_t *name, const char** ptr);
380
-  bool mkdir(SdBaseFile* parent, const uint8_t dname[11]);
381
-  bool open(SdBaseFile* dirFile, const uint8_t dname[11], uint8_t oflag);
379
+  static bool make83Name(const char *str, uint8_t *name, const char **ptr);
380
+  bool mkdir(SdBaseFile *parent, const uint8_t dname[11]);
381
+  bool open(SdBaseFile *dirFile, const uint8_t dname[11], uint8_t oflag);
382 382
   bool openCachedEntry(uint8_t cacheIndex, uint8_t oflags);
383 383
   dir_t* readDirCache();
384 384
 };

+ 1
- 1
Marlin/src/sd/SdFile.cpp View File

@@ -60,7 +60,7 @@ SdFile::SdFile(const char *path, uint8_t oflag) : SdBaseFile(path, oflag) { }
60 60
  * include write() is called before a file has been opened, write is called
61 61
  * for a read-only file, device is full, a corrupt file system or an I/O error.
62 62
  */
63
-int16_t SdFile::write(const void* buf, uint16_t nbyte) { return SdBaseFile::write(buf, nbyte); }
63
+int16_t SdFile::write(const void *buf, uint16_t nbyte) { return SdBaseFile::write(buf, nbyte); }
64 64
 
65 65
 /**
66 66
  * Write a byte to a file. Required by the Arduino Print class.

+ 2
- 2
Marlin/src/sd/SdFile.h View File

@@ -46,10 +46,10 @@ class SdFile : public SdBaseFile {
46 46
   #if ARDUINO >= 100
47 47
     size_t write(uint8_t b);
48 48
   #else
49
-   void write(uint8_t b);
49
+    void write(uint8_t b);
50 50
   #endif
51 51
 
52
-  int16_t write(const void* buf, uint16_t nbyte);
52
+  int16_t write(const void *buf, uint16_t nbyte);
53 53
   void write(const char *str);
54 54
   void write_P(PGM_P str);
55 55
   void writeln_P(PGM_P str);

+ 4
- 4
Marlin/src/sd/SdVolume.h View File

@@ -90,8 +90,8 @@ class SdVolume {
90 90
    * Reasons for failure include not finding a valid partition, not finding
91 91
    * a valid FAT file system or an I/O error.
92 92
    */
93
-  bool init(Sd2Card* dev) { return init(dev, 1) ? true : init(dev, 0); }
94
-  bool init(Sd2Card* dev, uint8_t part);
93
+  bool init(Sd2Card *dev) { return init(dev, 1) ? true : init(dev, 0); }
94
+  bool init(Sd2Card *dev, uint8_t part);
95 95
 
96 96
   // inline functions that return volume info
97 97
   uint8_t blocksPerCluster() const { return blocksPerCluster_; } //> \return The volume's cluster size in blocks.
@@ -138,13 +138,13 @@ class SdVolume {
138 138
   #if USE_MULTIPLE_CARDS
139 139
     cache_t cacheBuffer_;        // 512 byte cache for device blocks
140 140
     uint32_t cacheBlockNumber_;  // Logical number of block in the cache
141
-    Sd2Card* sdCard_;            // Sd2Card object for cache
141
+    Sd2Card *sdCard_;            // Sd2Card object for cache
142 142
     bool cacheDirty_;            // cacheFlush() will write block if true
143 143
     uint32_t cacheMirrorBlock_;  // block number for mirror FAT
144 144
   #else
145 145
     static cache_t cacheBuffer_;        // 512 byte cache for device blocks
146 146
     static uint32_t cacheBlockNumber_;  // Logical number of block in the cache
147
-    static Sd2Card* sdCard_;            // Sd2Card object for cache
147
+    static Sd2Card *sdCard_;            // Sd2Card object for cache
148 148
     static bool cacheDirty_;            // cacheFlush() will write block if true
149 149
     static uint32_t cacheMirrorBlock_;  // block number for mirror FAT
150 150
   #endif

+ 4
- 4
Marlin/src/sd/cardreader.cpp View File

@@ -723,9 +723,9 @@ void CardReader::report_status() {
723 723
 }
724 724
 
725 725
 void CardReader::write_command(char * const buf) {
726
-  char* begin = buf;
727
-  char* npos = nullptr;
728
-  char* end = buf + strlen(buf) - 1;
726
+  char *begin = buf;
727
+  char *npos = nullptr;
728
+  char *end = buf + strlen(buf) - 1;
729 729
 
730 730
   file.writeError = false;
731 731
   if ((npos = strchr(buf, 'N'))) {
@@ -845,7 +845,7 @@ uint16_t CardReader::countFilesInWorkDir() {
845 845
  *
846 846
  * A nullptr result indicates an unrecoverable error.
847 847
  */
848
-const char* CardReader::diveToFile(const bool update_cwd, SdFile*& diveDir, const char * const path, const bool echo/*=false*/) {
848
+const char* CardReader::diveToFile(const bool update_cwd, SdFile* &diveDir, const char * const path, const bool echo/*=false*/) {
849 849
   // Track both parent and subfolder
850 850
   static SdFile newDir1, newDir2;
851 851
   SdFile *sub = &newDir1, *startDir;

+ 3
- 3
Marlin/src/sd/cardreader.h View File

@@ -141,7 +141,7 @@ public:
141 141
   static inline uint8_t percentDone() { return (isFileOpen() && filesize) ? sdpos / ((filesize + 99) / 100) : 0; }
142 142
 
143 143
   // Helper for open and remove
144
-  static const char* diveToFile(const bool update_cwd, SdFile*& curDir, const char * const path, const bool echo=false);
144
+  static const char* diveToFile(const bool update_cwd, SdFile* &curDir, const char * const path, const bool echo=false);
145 145
 
146 146
   #if ENABLED(SDCARD_SORT_ALPHA)
147 147
     static void presort();
@@ -168,8 +168,8 @@ public:
168 168
   static inline void setIndex(const uint32_t index) { file.seekSet((sdpos = index)); }
169 169
   static inline char* getWorkDirName() { workDir.getDosName(filename); return filename; }
170 170
   static inline int16_t get() { int16_t out = (int16_t)file.read(); sdpos = file.curPosition(); return out; }
171
-  static inline int16_t read(void* buf, uint16_t nbyte) { return file.isOpen() ? file.read(buf, nbyte) : -1; }
172
-  static inline int16_t write(void* buf, uint16_t nbyte) { return file.isOpen() ? file.write(buf, nbyte) : -1; }
171
+  static inline int16_t read(void *buf, uint16_t nbyte) { return file.isOpen() ? file.read(buf, nbyte) : -1; }
172
+  static inline int16_t write(void *buf, uint16_t nbyte) { return file.isOpen() ? file.write(buf, nbyte) : -1; }
173 173
 
174 174
   static Sd2Card& getSd2Card() { return sd2card; }
175 175
 

Loading…
Cancel
Save