diff options
author | Anderson Lizardo <anderson.lizardo@openbossa.org> | 2011-11-16 09:19:59 -0400 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2011-11-17 13:57:53 +0200 |
commit | 4879b9d75cb8be48a7c639bfdcd497be398bdccc (patch) | |
tree | 1daa491bb6f9f239edd100e6486e61f4f04f3605 /network | |
parent | 18f92a51a27d5f3bbe06067e3c9728a989551464 (diff) | |
download | bluez-4879b9d75cb8be48a7c639bfdcd497be398bdccc.tar.gz |
network: 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 'network')
-rw-r--r-- | network/common.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/network/common.c b/network/common.c index 6da9f0a19..c498c25ca 100644 --- a/network/common.c +++ b/network/common.c @@ -108,10 +108,10 @@ int bnep_init(void) ctl = socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_BNEP); if (ctl < 0) { - int err = errno; + int err = -errno; error("Failed to open control socket: %s (%d)", - strerror(err), err); - return -err; + strerror(-err), -err); + return err; } return 0; @@ -131,10 +131,10 @@ int bnep_kill_connection(bdaddr_t *dst) baswap((bdaddr_t *)&req.dst, dst); req.flags = 0; if (ioctl(ctl, BNEPCONNDEL, &req)) { - int err = errno; + int err = -errno; error("Failed to kill connection: %s (%d)", - strerror(err), err); - return -err; + strerror(-err), -err); + return err; } return 0; } @@ -150,10 +150,10 @@ int bnep_kill_all_connections(void) req.cnum = 7; req.ci = ci; if (ioctl(ctl, BNEPGETCONNLIST, &req)) { - err = errno; + err = -errno; error("Failed to get connection list: %s (%d)", - strerror(err), err); - return -err; + strerror(-err), -err); + return err; } for (i = 0; i < req.cnum; i++) { @@ -177,10 +177,10 @@ int bnep_connadd(int sk, uint16_t role, char *dev) req.sock = sk; req.role = role; if (ioctl(ctl, BNEPCONNADD, &req) < 0) { - int err = errno; + int err = -errno; error("Failed to add device %s: %s(%d)", - dev, strerror(err), err); - return -err; + dev, strerror(-err), -err); + return err; } strncpy(dev, req.device, 16); |