mboxd: Fixup unused-result compilation warning
cc -Wall -O2 -g -I. -DPREFIX="\"MBOXD\"" mboxd.c common.o -o mboxd
mboxd.c: In function ‘dispatch_mbox’:
mboxd.c:170:5: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Wunused-result]
read(-context->fds[MTD_FD].fd, context->lpc_mem, context->size);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/mboxd.c b/mboxd.c
index e536cd2..1769537 100644
--- a/mboxd.c
+++ b/mboxd.c
@@ -33,6 +33,7 @@
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
+#include <inttypes.h>
#include <mtd/mtd-abi.h>
@@ -242,8 +243,13 @@
* the window...
* This approach is easiest.
*/
- if (context->dirty)
- read(-context->fds[MTD_FD].fd, context->lpc_mem, context->size);
+ if (context->dirty) {
+ r = read(-context->fds[MTD_FD].fd, context->lpc_mem, context->size);
+ if (r != context->size) {
+ MSG_ERR("Short read: %d expecting %"PRIu32"\n", r, context->size);
+ goto out;
+ }
+ }
basepg += get_u16(&req.msg.data[0]);
put_u16(&resp.msg.data[0], basepg);
resp.msg.response = MBOX_R_SUCCESS;