|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH] tools/9pfsd: Fix build error caused by strerror_r
Below error can be seen when doing Yocto build of the toolstack:
| io.c: In function 'p9_error':
| io.c:684:5: error: ignoring return value of 'strerror_r' declared
with attribute 'warn_unused_result' [-Werror=unused-result]
| 684 | strerror_r(err, ring->buffer, ring->ring_size);
| | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| cc1: all warnings being treated as errors
Fix it by adding a return value and check it properly.
Signed-off-by: Henry Wang <xin.wang2@xxxxxxx>
---
tools/9pfsd/io.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
index adb887c7d9..163eee6ecc 100644
--- a/tools/9pfsd/io.c
+++ b/tools/9pfsd/io.c
@@ -681,11 +681,17 @@ static void p9_error(struct ring *ring, uint16_t tag,
uint32_t err)
{
unsigned int erroff;
- strerror_r(err, ring->buffer, ring->ring_size);
- erroff = add_string(ring, ring->buffer, strlen(ring->buffer));
- fill_buffer(ring, P9_CMD_ERROR, tag, "SU",
- erroff != ~0 ? ring->str + erroff : "cannot allocate memory",
- &err);
+ char *ret = strerror_r(err, ring->buffer, ring->ring_size);
+
+ if ( ret )
+ {
+ erroff = add_string(ring, ring->buffer, strlen(ring->buffer));
+ fill_buffer(ring, P9_CMD_ERROR, tag, "SU",
+ erroff != ~0 ?
+ ring->str + erroff :
+ "cannot allocate memory",
+ &err);
+ }
}
static void p9_version(struct ring *ring, struct p9_header *hdr)
--
2.34.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |