[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] tools/9pfsd: Fix build error caused by strerror_r


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Henry Wang <xin.wang2@xxxxxxx>
  • Date: Thu, 7 Mar 2024 13:54:50 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=78w9s71NV2KazP+BbvasXgCjVEuk6yUlpVAXh+Du19M=; b=hgTjJG7uUOqAuLC/3XDHeBrNQjGSV4oJrROh4ErMwEeVMznFAHRS9agjXK3xf3sAslgPqKfHqSfLq4pltwXLLs2vIM8sBwv2/O0lkreS3pJBR+xoT765aB3Dk8jAYHSCOu5Xv50o2KecUCLDYzqLywrDZIbhGjdlkJ4PDlD2dpceoTvzwOizQdgXIC8QaHxDjY6FXbXHVlm2KY9cbzWF6tjg4c3YJxarNnLn2J6lb9HhVaAeKvF2eXsOGd/wFqME0NaRS7uIcCnurZFbFB+85utq0MIndRCgjY8KtGstAPh1aR/nquKwxLQvLL4BUu/xJ8xDQXPzFzXL9PEM0JNkIA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i3uF0LZ5mHUqL4lnhFMMXMWgtdMAuswDaXCrQszi8g3xssWak1GowtcbQ5D7GWN3yL7fX/gzCY23B12Mb4pkTSwyHPIempcHWd4i5YyTXCiHFp1j8XRghrRl6Aqy8UjR1vN9CK/EhbiA8GYWO657VLVty1DM3eOeF25l+KDORcOYNrSKBRdlJ05c66UodFRWVziTjOUDooLVARoMMwaSndKZ4fQnI0Va72FxpQqIyVsH+7YGqswDlM9sp3d9qkm9Fy4Kc0QNjPKyQFVrcaePOhiVX+QWxxaUK2iVR0qJ0WvDfTmiHPAZ0BRgp+vMlu1zNUgAAlSUfMVlnwiPuFM7mg==
  • Cc: Henry Wang <xin.wang2@xxxxxxx>, Wei Liu <wl@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Thu, 07 Mar 2024 05:55:32 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.