utils: Resolve warnings of unused write() result
For example:
```
utils/mctp-pipe.c:19:9: error: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
19 | write(STDOUT_FILENO, msg, len);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I57041dc85b551f9bb694638642b677b737be21eb
diff --git a/utils/mctp-in.c b/utils/mctp-in.c
index 43d96ec..c2792b6 100644
--- a/utils/mctp-in.c
+++ b/utils/mctp-in.c
@@ -13,9 +13,15 @@
static void rx_message(uint8_t eid, void *data, void *msg, size_t len)
{
+ ssize_t rc;
(void)eid;
(void)data;
- write(STDOUT_FILENO, msg, len);
+
+ rc = write(STDOUT_FILENO, msg, len);
+ if (rc < 0)
+ warn("Write failed");
+ else if ((size_t)rc < len)
+ warnx("Short write of length %zd, requested %zd", rc, len);
}
int main(void)
diff --git a/utils/mctp-pipe.c b/utils/mctp-pipe.c
index 3c4c316..91389aa 100644
--- a/utils/mctp-pipe.c
+++ b/utils/mctp-pipe.c
@@ -13,9 +13,15 @@
static void rx_message(uint8_t eid, void *data, void *msg, size_t len)
{
+ ssize_t rc;
(void)eid;
(void)data;
- write(STDOUT_FILENO, msg, len);
+
+ rc = write(STDOUT_FILENO, msg, len);
+ if (rc < 0)
+ warn("Write failed");
+ else if ((size_t)rc < len)
+ warnx("Short write of length %zd, requested %zd", rc, len);
}
int main(void)