Use correct signess for err variable
diff --git a/serial/port.c b/serial/port.c
index 1458f06..c18889d 100644
--- a/serial/port.c
+++ b/serial/port.c
@@ -245,10 +245,10 @@
struct serial_device *device = port->device;
DBusMessage *reply;
- if (err) {
+ if (err < 0) {
/* Max tries exceeded */
port_release(port);
- reply = btd_error_failed(port->msg, strerror(err));
+ reply = btd_error_failed(port->msg, strerror(-err));
} else {
port->fd = fd;
reply = g_dbus_create_reply(port->msg,
@@ -271,7 +271,7 @@
fd = open(port->dev, O_RDONLY | O_NOCTTY);
if (fd < 0) {
- int err = errno;
+ int err = -errno;
error("Could not open %s: %s (%d)",
port->dev, strerror(err), err);
if (!--ntries) {
@@ -333,9 +333,9 @@
sk = g_io_channel_unix_get_fd(chan);
port->id = ioctl(sk, RFCOMMCREATEDEV, &req);
if (port->id < 0) {
- int err = errno;
- error("ioctl(RFCOMMCREATEDEV): %s (%d)", strerror(err), err);
- reply = btd_error_failed(port->msg, strerror(err));
+ int err = -errno;
+ error("ioctl(RFCOMMCREATEDEV): %s (%d)", strerror(-err), -err);
+ reply = btd_error_failed(port->msg, strerror(-err));
g_io_channel_shutdown(chan, TRUE, NULL);
goto fail;
}