mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-08-06 13:44:17 -04:00
fw: Add destination buffer size to read()
Signed-off-by: Daniel Lublin <daniel@lublin.se>
This commit is contained in:
parent
b292c72534
commit
f386cec1ed
3 changed files with 13 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue