diff options
author | Anderson Lizardo <anderson.lizardo@openbossa.org> | 2011-11-16 09:20:01 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2012-01-17 11:41:30 +0100 |
commit | 0a29072527e6265e94ae5dc0c67c635c485037de (patch) | |
tree | 50437f9a80f0aa3f5c1b44b62713be1e26e380e6 /btio | |
parent | 177f45bb915adba911ba7ea7a446099eb610fcf2 (diff) | |
download | ofono-0a29072527e6265e94ae5dc0c67c635c485037de.tar.gz |
btio: Fix errno handling convention
Variables which are assigned to the errno variable (usually called
"err") should be negative, and "-err" should be used where a positive
value is needed.
Diffstat (limited to 'btio')
-rw-r--r-- | btio/btio.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/btio/btio.c b/btio/btio.c index 6db17568..a129bf98 100644 --- a/btio/btio.c +++ b/btio/btio.c @@ -153,16 +153,18 @@ static gboolean connect_cb(GIOChannel *io, GIOCondition cond, return FALSE; if (cond & G_IO_OUT) { - int err = 0, sock = g_io_channel_unix_get_fd(io); - socklen_t len = sizeof(err); + int err, sk_err = 0, sock = g_io_channel_unix_get_fd(io); + socklen_t len = sizeof(sk_err); - if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &err, &len) < 0) - err = errno; + if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &sk_err, &len) < 0) + err = -errno; + else + err = -sk_err; - if (err) + if (err < 0) g_set_error(&gerr, BT_IO_ERROR, BT_IO_ERROR_CONNECT_FAILED, "%s (%d)", - strerror(err), err); + strerror(-err), -err); } else if (cond & (G_IO_HUP | G_IO_ERR)) g_set_error(&gerr, BT_IO_ERROR, BT_IO_ERROR_CONNECT_FAILED, "HUP or ERR on socket"); |