Linux bluetooth development
 help / color / mirror / Atom feed
From: Anderson Lizardo <anderson.lizardo@openbossa.org>
To: linux-bluetooth@vger.kernel.org
Cc: Anderson Lizardo <anderson.lizardo@openbossa.org>
Subject: [PATCH RFC BlueZ] serial: Fix bogus errno usage
Date: Thu, 17 Nov 2011 13:32:40 -0400	[thread overview]
Message-ID: <1321551160-8903-1-git-send-email-anderson.lizardo@openbossa.org> (raw)

There is no previous function setting errno, thus the original code may
return a undefined value.
---

NOTE:
Is bt_io_connect() supposed to set errno on error? If yes, then the code is
correct and this patch is invalid.

But in this case, bt_io_connect() needs to be modified as there are at least
two glib library calls before returning, and this may reset errno from the
underlying connect call. So I think it needs to be saved before calling these
library functions.


 serial/port.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/serial/port.c b/serial/port.c
index 3b36d44..1ceda7b 100644
--- a/serial/port.c
+++ b/serial/port.c
@@ -463,10 +463,8 @@ connect:
 				BT_IO_OPT_DEST_BDADDR, &device->dst,
 				BT_IO_OPT_CHANNEL, port->channel,
 				BT_IO_OPT_INVALID);
-	if (port->io)
-		return 0;
 
-	return -errno;
+	return 0;
 }
 
 static struct serial_port *create_port(struct serial_device *device,
-- 
1.7.0.4


             reply	other threads:[~2011-11-17 17:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-17 17:32 Anderson Lizardo [this message]
2011-11-18 11:27 ` [PATCH RFC BlueZ] serial: Fix bogus errno usage Johan Hedberg
2011-11-18 12:15   ` Anderson Lizardo

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=1321551160-8903-1-git-send-email-anderson.lizardo@openbossa.org \
    --to=anderson.lizardo@openbossa.org \
    --cc=linux-bluetooth@vger.kernel.org \
    /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