fw: Add destination buffer size to read()

Signed-off-by: Daniel Lublin <daniel@lublin.se>
This commit is contained in:
Michael Cardell Widerkrantz 2023-02-27 16:41:31 +01:00 committed by Daniel Lublin
parent b292c72534
commit f386cec1ed
No known key found for this signature in database
GPG key ID: 75BD0FEB8D3E7830
3 changed files with 13 additions and 3 deletions

View file

@ -148,9 +148,15 @@ uint8_t readbyte_ledflash(int ledvalue, int loopcount)
}
}
void read(uint8_t *buf, size_t nbytes)
int read(uint8_t *buf, size_t bufsize, size_t nbytes)
{
if (nbytes > bufsize) {
return -1;
}
for (int n = 0; n < nbytes; n++) {
buf[n] = readbyte();
}
return 0;
}