Re: [PATCH 2/2] Fix return value in send_message

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

 



Hi Waldek,

On Thu, May 26, 2011, Waldemar Rymarkiewicz wrote:
> send_message returns the number of sent bytes and -EIO in case of
> IO error now
> ---
>  sap/server.c |   14 ++++++++------
>  1 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/sap/server.c b/sap/server.c
> index 711361d..4f47882 100644
> --- a/sap/server.c
> +++ b/sap/server.c
> @@ -254,22 +254,24 @@ static int send_message(struct sap_connection *conn, void *buf, size_t size)
>  	if (!conn || !buf)
>  		return -EINVAL;
>  
> -	DBG("size %zu", size);
> +	DBG("conn %p, size %zu", conn, size);
>  
>  	gstatus = g_io_channel_write_chars(conn->io, buf, size, &written,
> -						&gerr);
> +									&gerr);
>  	if (gstatus != G_IO_STATUS_NORMAL) {
>  		if (gerr)
>  			g_error_free(gerr);
>  
>  		error("write error (0x%02x).", gstatus);
> -		return -EINVAL;
> +		return -EIO;
>  	}
>  
> -	if (written != size)
> -		error("write error.(written %zu size %zu)", written, size);
> +	if (written != size) {
> +		error("written %zu bytes out of %zu", written, size);
> +		return -1;
> +	}

Since you're returning -<POSIX errno> in all the other error cases I
don't think -1 is appropriate here. Come up with some suitable errno
value.

Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux