Skip to content

Commit faf0789

Browse files
committed
fix(fdc): avoid read/write execution phases if no data available
1 parent 22f5e30 commit faf0789

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/fdc.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,11 @@ static void pre_exec_write_data(void) {
260260
static uint8_t exec_write_data(uint8_t value) {
261261
rw_args_t *rw_args = (rw_args_t *)args;
262262

263+
if (rwcount_max == 0) {
264+
LOG_WARN("Write execution happened when no data can be written");
265+
return 0;
266+
}
267+
263268
exec_buffer[rwcount++] = value;
264269

265270
if (rwcount == rwcount_max) {
@@ -337,6 +342,11 @@ static void pre_exec_read_data(void) {
337342
static uint8_t exec_read_data(uint8_t value) {
338343
rw_args_t *rw_args = (rw_args_t *)args;
339344

345+
if (rwcount_max == 0) {
346+
LOG_WARN("Read execution happened when no data can be read");
347+
return 0;
348+
}
349+
340350
// read doesn't care of in value
341351
(void)value;
342352
uint8_t ret = exec_buffer[rwcount++];

0 commit comments

Comments
 (0)