[Spice-devel] [PATCH] spicy: port_data: check write return value

Uri Lublin uril at redhat.com
Sun Dec 9 04:50:34 PST 2012


Fixes the following build warning (but does not really check write return value):
spicy.c: In function ‘port_data’:
spicy.c:1711:10: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]

Reported by Yaniv Kaul <ykaul at redhat.com>
---

Alternatively, if we really care about writing port data to stdout:

-    write(fileno(stdout), data, size);
+    if (write(fileno(stdout), data, size) != size)
+        g_warning("Failed to write %d bytes to stdout", size);


---
 gtk/spicy.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/gtk/spicy.c b/gtk/spicy.c
index dd8c970..077ef52 100644
--- a/gtk/spicy.c
+++ b/gtk/spicy.c
@@ -1708,7 +1708,7 @@ static void port_data(SpicePortChannel *port,
     if (port != stdin_port)
         return;
 
-    write(fileno(stdout), data, size);
+    size = write(fileno(stdout), data, size);
 }
 
 static void channel_new(SpiceSession *s, SpiceChannel *channel, gpointer data)
-- 
1.7.1



More information about the Spice-devel mailing list