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

Submitted by Uri Lublin on Dec. 9, 2012, 12:50 p.m.

Details

Message ID 98bd3aefe40297f4f07217d7e56a3ab345f3b0f3.1355057177.git.uril@redhat.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Uri Lublin Dec. 9, 2012, 12:50 p.m.
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@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(-)

Patch hide | download patch | download mbox

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)