* [PATCH BlueZ v0 1/2] btio: Replace g_set_error by ERROR_FAILED macro
@ 2012-07-26 14:11 Claudio Takahasi
2012-07-26 14:11 ` [PATCH BlueZ v0 2/2] btio: Connect callback errors handling cleanup Claudio Takahasi
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Claudio Takahasi @ 2012-07-26 14:11 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
This patch replaces the calls of g_set_error function by the local
defined macro "ERROR_FAILED".
---
btio/btio.c | 19 +++++++------------
1 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/btio/btio.c b/btio/btio.c
index f2a9d4b..792123f 100644
--- a/btio/btio.c
+++ b/btio/btio.c
@@ -140,8 +140,7 @@ static gboolean accept_cb(GIOChannel *io, GIOCondition cond,
err = -sk_err;
if (err < 0)
- g_set_error(&gerr, BT_IO_ERROR, -err,
- "HUP or ERR on socket");
+ ERROR_FAILED(&gerr, "HUP or ERR on socket", -err);
}
accept->connect(io, gerr, accept->user_data);
@@ -172,8 +171,7 @@ static gboolean connect_cb(GIOChannel *io, GIOCondition cond,
err = -sk_err;
if (err < 0)
- g_set_error(&gerr, BT_IO_ERROR, -err, "%s (%d)",
- strerror(-err), -err);
+ ERROR_FAILED(&gerr, "connect", -err);
} else if (cond & (G_IO_HUP | G_IO_ERR)) {
sock = g_io_channel_unix_get_fd(io);
@@ -183,8 +181,7 @@ static gboolean connect_cb(GIOChannel *io, GIOCondition cond,
err = -sk_err;
if (err < 0)
- g_set_error(&gerr, BT_IO_ERROR, -err,
- "HUP or ERR on socket");
+ ERROR_FAILED(&gerr, "HUP or ERR on socket", -err);
}
conn->connect(io, gerr, conn->user_data);
@@ -901,8 +898,7 @@ static gboolean l2cap_get(int sock, GError **err, BtIOOption opt1,
bacpy(va_arg(args, bdaddr_t *), &dst.l2_bdaddr);
break;
case BT_IO_OPT_DEST_TYPE:
- g_set_error(err, BT_IO_ERROR, EINVAL,
- "Not implemented");
+ ERROR_FAILED(err, "Not implemented", EINVAL);
return FALSE;
case BT_IO_OPT_DEFER_TIMEOUT:
len = sizeof(int);
@@ -1416,8 +1412,7 @@ GIOChannel *bt_io_connect(BtIOType type, BtIOConnect connect,
}
if (err < 0) {
- g_set_error(gerr, BT_IO_ERROR, -err, "connect: %s (%d)",
- strerror(-err), -err);
+ ERROR_FAILED(gerr, "connect", -err);
g_io_channel_unref(io);
return NULL;
}
@@ -1439,8 +1434,8 @@ GIOChannel *bt_io_listen(BtIOType type, BtIOConnect connect,
gboolean ret;
if (type == BT_IO_L2RAW) {
- g_set_error(err, BT_IO_ERROR, EINVAL,
- "Server L2CAP RAW sockets not supported");
+ ERROR_FAILED(err, "Server L2CAP RAW sockets not supported",
+ EINVAL);
return NULL;
}
--
1.7.8.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH BlueZ v0 2/2] btio: Connect callback errors handling cleanup
2012-07-26 14:11 [PATCH BlueZ v0 1/2] btio: Replace g_set_error by ERROR_FAILED macro Claudio Takahasi
@ 2012-07-26 14:11 ` Claudio Takahasi
2012-07-26 15:25 ` [PATCH BlueZ v0 1/2] btio: Replace g_set_error by ERROR_FAILED macro Anderson Lizardo
2012-07-29 15:04 ` Johan Hedberg
2 siblings, 0 replies; 4+ messages in thread
From: Claudio Takahasi @ 2012-07-26 14:11 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
Condition verification is not required for this watch since the
condition to watch for was previously informed when it was added
in the mainloop.
---
btio/btio.c | 26 +++++++-------------------
1 files changed, 7 insertions(+), 19 deletions(-)
diff --git a/btio/btio.c b/btio/btio.c
index 792123f..730bdb3 100644
--- a/btio/btio.c
+++ b/btio/btio.c
@@ -162,27 +162,15 @@ static gboolean connect_cb(GIOChannel *io, GIOCondition cond,
if ((cond & G_IO_NVAL) || check_nval(io))
return FALSE;
- if (cond & G_IO_OUT) {
- sock = g_io_channel_unix_get_fd(io);
-
- if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &sk_err, &len) < 0)
- err = -errno;
- else
- err = -sk_err;
-
- if (err < 0)
- ERROR_FAILED(&gerr, "connect", -err);
- } else if (cond & (G_IO_HUP | G_IO_ERR)) {
- sock = g_io_channel_unix_get_fd(io);
+ sock = g_io_channel_unix_get_fd(io);
- if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &sk_err, &len) < 0)
- err = -errno;
- else
- err = -sk_err;
+ if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &sk_err, &len) < 0)
+ err = -errno;
+ else
+ err = -sk_err;
- if (err < 0)
- ERROR_FAILED(&gerr, "HUP or ERR on socket", -err);
- }
+ if (err < 0)
+ ERROR_FAILED(&gerr, "connect error", -err);
conn->connect(io, gerr, conn->user_data);
--
1.7.8.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH BlueZ v0 1/2] btio: Replace g_set_error by ERROR_FAILED macro
2012-07-26 14:11 [PATCH BlueZ v0 1/2] btio: Replace g_set_error by ERROR_FAILED macro Claudio Takahasi
2012-07-26 14:11 ` [PATCH BlueZ v0 2/2] btio: Connect callback errors handling cleanup Claudio Takahasi
@ 2012-07-26 15:25 ` Anderson Lizardo
2012-07-29 15:04 ` Johan Hedberg
2 siblings, 0 replies; 4+ messages in thread
From: Anderson Lizardo @ 2012-07-26 15:25 UTC (permalink / raw)
To: Claudio Takahasi; +Cc: linux-bluetooth
Hi Claudio,
On Thu, Jul 26, 2012 at 10:11 AM, Claudio Takahasi
<claudio.takahasi@openbossa.org> wrote:
> This patch replaces the calls of g_set_error function by the local
> defined macro "ERROR_FAILED".
> ---
> btio/btio.c | 19 +++++++------------
> 1 files changed, 7 insertions(+), 12 deletions(-)
I'm not sure replacing every g_set_error() occurrence by
ERROR_FAILED() is a good idea (some will show errors like "Server
L2CAP RAW sockets not supported: Invalid argument (22)"), but it is a
minor problem so the patch is fine for me.
Best Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH BlueZ v0 1/2] btio: Replace g_set_error by ERROR_FAILED macro
2012-07-26 14:11 [PATCH BlueZ v0 1/2] btio: Replace g_set_error by ERROR_FAILED macro Claudio Takahasi
2012-07-26 14:11 ` [PATCH BlueZ v0 2/2] btio: Connect callback errors handling cleanup Claudio Takahasi
2012-07-26 15:25 ` [PATCH BlueZ v0 1/2] btio: Replace g_set_error by ERROR_FAILED macro Anderson Lizardo
@ 2012-07-29 15:04 ` Johan Hedberg
2 siblings, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2012-07-29 15:04 UTC (permalink / raw)
To: Claudio Takahasi; +Cc: linux-bluetooth
Hi Claudio,
On Thu, Jul 26, 2012, Claudio Takahasi wrote:
> This patch replaces the calls of g_set_error function by the local
> defined macro "ERROR_FAILED".
> ---
> btio/btio.c | 19 +++++++------------
> 1 files changed, 7 insertions(+), 12 deletions(-)
Both patches have been applied. Thanks.
Johan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-07-29 15:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-26 14:11 [PATCH BlueZ v0 1/2] btio: Replace g_set_error by ERROR_FAILED macro Claudio Takahasi
2012-07-26 14:11 ` [PATCH BlueZ v0 2/2] btio: Connect callback errors handling cleanup Claudio Takahasi
2012-07-26 15:25 ` [PATCH BlueZ v0 1/2] btio: Replace g_set_error by ERROR_FAILED macro Anderson Lizardo
2012-07-29 15:04 ` Johan Hedberg
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).