mirror of git://git.sysmocom.de/ofono
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.
This commit is contained in:
parent
177f45bb91
commit
0a29072527
14
btio/btio.c
14
btio/btio.c
|
@ -153,16 +153,18 @@ static gboolean connect_cb(GIOChannel *io, GIOCondition cond,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (cond & G_IO_OUT) {
|
if (cond & G_IO_OUT) {
|
||||||
int err = 0, sock = g_io_channel_unix_get_fd(io);
|
int err, sk_err = 0, sock = g_io_channel_unix_get_fd(io);
|
||||||
socklen_t len = sizeof(err);
|
socklen_t len = sizeof(sk_err);
|
||||||
|
|
||||||
if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &err, &len) < 0)
|
if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &sk_err, &len) < 0)
|
||||||
err = errno;
|
err = -errno;
|
||||||
|
else
|
||||||
|
err = -sk_err;
|
||||||
|
|
||||||
if (err)
|
if (err < 0)
|
||||||
g_set_error(&gerr, BT_IO_ERROR,
|
g_set_error(&gerr, BT_IO_ERROR,
|
||||||
BT_IO_ERROR_CONNECT_FAILED, "%s (%d)",
|
BT_IO_ERROR_CONNECT_FAILED, "%s (%d)",
|
||||||
strerror(err), err);
|
strerror(-err), -err);
|
||||||
} else if (cond & (G_IO_HUP | G_IO_ERR))
|
} else if (cond & (G_IO_HUP | G_IO_ERR))
|
||||||
g_set_error(&gerr, BT_IO_ERROR, BT_IO_ERROR_CONNECT_FAILED,
|
g_set_error(&gerr, BT_IO_ERROR, BT_IO_ERROR_CONNECT_FAILED,
|
||||||
"HUP or ERR on socket");
|
"HUP or ERR on socket");
|
||||||
|
|
Loading…
Reference in New Issue