Browse Source

Eliminate M100 compiler warnings?

Scott Lahteine 8 years ago
parent
commit
8d961b51cc
2 changed files with 10 additions and 10 deletions
  1. 9
    9
      Marlin/M100_Free_Mem_Chk.cpp
  2. 1
    1
      Marlin/Marlin_main.cpp

+ 9
- 9
Marlin/M100_Free_Mem_Chk.cpp View File

78
 }
78
 }
79
 
79
 
80
 // Count the number of test bytes at the specified location.
80
 // Count the number of test bytes at the specified location.
81
-int16_t count_test_bytes(const uint8_t * const ptr) {
81
+int16_t count_test_bytes(const char * const ptr) {
82
   for (uint16_t i = 0; i < 32000; i++)
82
   for (uint16_t i = 0; i < 32000; i++)
83
     if (((char) ptr[i]) != TEST_BYTE)
83
     if (((char) ptr[i]) != TEST_BYTE)
84
       return i - 1;
84
       return i - 1;
100
    *  the block. If so, it may indicate memory corruption due to a bad pointer.
100
    *  the block. If so, it may indicate memory corruption due to a bad pointer.
101
    *  Unexpected bytes are flagged in the right column.
101
    *  Unexpected bytes are flagged in the right column.
102
    */
102
    */
103
-  void dump_free_memory(const uint8_t *ptr, const uint8_t *sp) {
103
+  void dump_free_memory(const char *ptr, const char *sp) {
104
     //
104
     //
105
     // Start and end the dump on a nice 16 byte boundary
105
     // Start and end the dump on a nice 16 byte boundary
106
     // (even though the values are not 16-byte aligned).
106
     // (even though the values are not 16-byte aligned).
107
     //
107
     //
108
-    ptr = (uint8_t *)((uint16_t)ptr & 0xFFF0); // Align to 16-byte boundary
109
-    sp  = (uint8_t *)((uint16_t)sp  | 0x000F); // Align sp to the 15th byte (at or above sp)
108
+    ptr = (char *)((uint16_t)ptr & 0xFFF0); // Align to 16-byte boundary
109
+    sp  = (char *)((uint16_t)sp  | 0x000F); // Align sp to the 15th byte (at or above sp)
110
 
110
 
111
     // Dump command main loop
111
     // Dump command main loop
112
     while (ptr < sp) {
112
     while (ptr < sp) {
121
       SERIAL_CHAR('|');                   // Point out non test bytes
121
       SERIAL_CHAR('|');                   // Point out non test bytes
122
       for (uint8_t i = 0; i < 16; i++) {
122
       for (uint8_t i = 0; i < 16; i++) {
123
         char ccc = (char)ptr[i]; // cast to char before automatically casting to char on assignment, in case the compiler is broken
123
         char ccc = (char)ptr[i]; // cast to char before automatically casting to char on assignment, in case the compiler is broken
124
-        if (&ptr[i] >= command_queue && &ptr[i] < &command_queue[BUFSIZE][MAX_CMD_SIZE]) { // Print out ASCII in the command buffer area
124
+        if (&ptr[i] >= (const char*)command_queue && &ptr[i] < (const char*)(command_queue + sizeof(command_queue))) { // Print out ASCII in the command buffer area
125
           if (!WITHIN(ccc, ' ', 0x7E)) ccc = ' ';
125
           if (!WITHIN(ccc, ' ', 0x7E)) ccc = ' ';
126
         }
126
         }
127
         else { // If not in the command buffer area, flag bytes that don't match the test byte
127
         else { // If not in the command buffer area, flag bytes that don't match the test byte
153
  *  Return the number of free bytes in the memory pool,
153
  *  Return the number of free bytes in the memory pool,
154
  *  with other vital statistics defining the pool.
154
  *  with other vital statistics defining the pool.
155
  */
155
  */
156
-void free_memory_pool_report(const char * const ptr, const uint16_t size) {
156
+void free_memory_pool_report(char * const ptr, const uint16_t size) {
157
   int16_t max_cnt = -1;
157
   int16_t max_cnt = -1;
158
   uint16_t block_cnt = 0;
158
   uint16_t block_cnt = 0;
159
   char *max_addr = NULL;
159
   char *max_addr = NULL;
160
   // Find the longest block of test bytes in the buffer
160
   // Find the longest block of test bytes in the buffer
161
   for (uint16_t i = 0; i < size; i++) {
161
   for (uint16_t i = 0; i < size; i++) {
162
-    char * const addr = ptr + i;
162
+    char *addr = ptr + i;
163
     if (*addr == TEST_BYTE) {
163
     if (*addr == TEST_BYTE) {
164
       const uint16_t j = count_test_bytes(addr);
164
       const uint16_t j = count_test_bytes(addr);
165
       if (j > 8) {
165
       if (j > 8) {
209
  * M100 I
209
  * M100 I
210
  *  Init memory for the M100 tests. (Automatically applied on the first M100.)
210
  *  Init memory for the M100 tests. (Automatically applied on the first M100.)
211
  */
211
  */
212
-void init_free_memory(uint8_t *ptr, int16_t size) {
212
+void init_free_memory(char *ptr, int16_t size) {
213
   SERIAL_ECHOLNPGM("Initializing free memory block.\n\n");
213
   SERIAL_ECHOLNPGM("Initializing free memory block.\n\n");
214
 
214
 
215
   size -= 250;    // -250 to avoid interrupt activity that's altered the stack.
215
   size -= 250;    // -250 to avoid interrupt activity that's altered the stack.
292
     //   idle();
292
     //   idle();
293
     safe_delay(20);
293
     safe_delay(20);
294
     #ifdef M100_FREE_MEMORY_DUMPER
294
     #ifdef M100_FREE_MEMORY_DUMPER
295
-      M100_dump_routine("   Memory corruption detected with sp<Heap\n", (char*)0x1B80, 0x21FF);
295
+      M100_dump_routine("   Memory corruption detected with sp<Heap\n", (char*)0x1B80, (char*)0x21FF);
296
     #endif
296
     #endif
297
   }
297
   }
298
 
298
 

+ 1
- 1
Marlin/Marlin_main.cpp View File

9731
     SERIAL_ECHOLN(current_command);
9731
     SERIAL_ECHOLN(current_command);
9732
     #if ENABLED(M100_FREE_MEMORY_WATCHER)
9732
     #if ENABLED(M100_FREE_MEMORY_WATCHER)
9733
       SERIAL_ECHOPAIR("slot:", cmd_queue_index_r);
9733
       SERIAL_ECHOPAIR("slot:", cmd_queue_index_r);
9734
-      M100_dump_routine("   Command Queue:", &command_queue[0][0], &command_queue[BUFSIZE][MAX_CMD_SIZE]);
9734
+      M100_dump_routine("   Command Queue:", (const char*)command_queue, (const char*)(command_queue + sizeof(command_queue)));
9735
     #endif
9735
     #endif
9736
   }
9736
   }
9737
 
9737
 

Loading…
Cancel
Save