Skip to content

Commit 92958ef

Browse files
committed
Merge pull request #1863 from matthijskooijman/ide-1.5.x-serial-int
In HardwareSerial, don't use int for buffer indices
2 parents 8504bca + 6372eb8 commit 92958ef

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: hardware/arduino/avr/cores/arduino/HardwareSerial.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ int HardwareSerial::read(void)
171171
return -1;
172172
} else {
173173
unsigned char c = _rx_buffer[_rx_buffer_tail];
174-
_rx_buffer_tail = (unsigned int)(_rx_buffer_tail + 1) % SERIAL_BUFFER_SIZE;
174+
_rx_buffer_tail = (uint8_t)(_rx_buffer_tail + 1) % SERIAL_BUFFER_SIZE;
175175
return c;
176176
}
177177
}
@@ -207,7 +207,7 @@ size_t HardwareSerial::write(uint8_t c)
207207
sbi(*_ucsra, TXC0);
208208
return 1;
209209
}
210-
int i = (_tx_buffer_head + 1) % SERIAL_BUFFER_SIZE;
210+
uint8_t i = (_tx_buffer_head + 1) % SERIAL_BUFFER_SIZE;
211211

212212
// If the output buffer is full, there's nothing for it other than to
213213
// wait for the interrupt handler to empty it a bit

0 commit comments

Comments
 (0)