[PATCH] port-serial: fix gsize/gssize type mismatch

Ben Chan benchan at chromium.org
Thu Feb 13 21:42:11 CET 2014


This patch fixes the following type mismatch in MMPortSerial::port_serial_process_command():

mm-port-serial.c:612:21: error: comparison of unsigned expression < 0 is always false [-Werror,-Wtautological-compare]
        if (written < 0) {
            ~~~~~~~ ^ ~
---
 src/mm-port-serial.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/mm-port-serial.c b/src/mm-port-serial.c
index 47ce482..e41beef 100644
--- a/src/mm-port-serial.c
+++ b/src/mm-port-serial.c
@@ -606,10 +606,11 @@ port_serial_process_command (MMPortSerial *self,
     /* Socket based setup */
     else if (self->priv->socket) {
         GError *inner_error = NULL;
+        gssize bytes_sent;
 
         /* Send N bytes of the command */
-        written = g_socket_send (self->priv->socket, p, send_len, NULL, &inner_error);
-        if (written < 0) {
+        bytes_sent = g_socket_send (self->priv->socket, p, send_len, NULL, &inner_error);
+        if (bytes_sent < 0) {
             /* Non-EWOULDBLOCK error? */
             if (!g_error_matches (inner_error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) {
                 g_propagate_error (error, inner_error);
@@ -634,7 +635,8 @@ port_serial_process_command (MMPortSerial *self,
 
             /* Just keep on, will retry... */
             written = 0;
-        }
+        } else
+          written = bytes_sent;
 
         ctx->idx += written;
     } else
-- 
1.9.0.rc1.175.g0b1dcb5



More information about the ModemManager-devel mailing list