From: Johan Hedberg <johan.hedberg@gmail.com>
To: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 2/2] Fix return value in send_message
Date: Sun, 29 May 2011 22:15:08 +0300 [thread overview]
Message-ID: <20110529191508.GH32088@dell.ger.corp.intel.com> (raw)
In-Reply-To: <1306403760-22254-2-git-send-email-waldemar.rymarkiewicz@tieto.com>
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
next prev parent reply other threads:[~2011-05-29 19:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-26 9:55 [PATCH 1/2] Clean nad simplify SAP server error printouts Waldemar Rymarkiewicz
2011-05-26 9:56 ` [PATCH 2/2] Fix return value in send_message Waldemar Rymarkiewicz
2011-05-29 19:15 ` Johan Hedberg [this message]
2011-05-29 18:57 ` [PATCH 1/2] Clean nad simplify SAP server error printouts Johan Hedberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110529191508.GH32088@dell.ger.corp.intel.com \
--to=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=waldemar.rymarkiewicz@tieto.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).