From 72955221cbb017fbc207925e5357073f9369bf51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Mon, 19 Jun 2023 11:41:50 +0200 Subject: [PATCH] fix dataman: treat 0 as valid return for read & ensure to init buffer This can happen e.g. when the item is cleared. --- src/modules/dataman/dataman.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/dataman/dataman.cpp b/src/modules/dataman/dataman.cpp index f4345cc685..eb25328a5b 100644 --- a/src/modules/dataman/dataman.cpp +++ b/src/modules/dataman/dataman.cpp @@ -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 {