mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-24 15:40:31 +08:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user