fix dataman: treat 0 as valid return for read & ensure to init buffer

This can happen e.g. when the item is cleared.
This commit is contained in:
Beat Küng 2023-06-19 11:41:50 +02:00
parent 9aa355a08c
commit 72955221cb
1 changed files with 4 additions and 1 deletions

View File

@ -430,6 +430,9 @@ _file_read(dm_item_t item, unsigned index, void *buf, size_t count)
/* Looks good, copy it to the caller's buffer */
memcpy(buf, buffer + DM_SECTOR_HDR_SIZE, buffer[0]);
} else {
memset(buf, 0, count);
}
/* Return the number of bytes of caller data read */
@ -754,7 +757,7 @@ task_main(int argc, char *argv[])
perf_end(_dm_read_perf);
if (result > 0) {
if (result >= 0) {
response.status = dataman_response_s::STATUS_SUCCESS;
} else {