diff options
author | Andrei Emeltchenko <andrei.emeltchenko@intel.com> | 2014-10-17 15:54:07 +0300 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2014-10-20 15:28:04 +0300 |
commit | 62e18423450cee11d9bd4517860aa675c0227027 (patch) | |
tree | fd2b3ef787f3132b49b99b8e983bcfb3e9ff463c /profiles/network | |
parent | c73724d80f8b4918582accff3985eba7eddcd311 (diff) | |
download | bluez-62e18423450cee11d9bd4517860aa675c0227027.tar.gz |
bnep: Refactor bnep_if_up() returning -errno
Some functions are using bnep_if_up() like bnep_server_add() referring
directly to errno which may be overwritten already.
Diffstat (limited to 'profiles/network')
-rw-r--r-- | profiles/network/bnep.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/profiles/network/bnep.c b/profiles/network/bnep.c index e17a130ff..3a6e3a4a4 100644 --- a/profiles/network/bnep.c +++ b/profiles/network/bnep.c @@ -195,7 +195,7 @@ static int bnep_connadd(int sk, uint16_t role, char *dev) static int bnep_if_up(const char *devname) { struct ifreq ifr; - int sk, err; + int sk, err = 0; sk = socket(AF_INET, SOCK_DGRAM, 0); @@ -205,16 +205,15 @@ static int bnep_if_up(const char *devname) ifr.ifr_flags |= IFF_UP; ifr.ifr_flags |= IFF_MULTICAST; - err = ioctl(sk, SIOCSIFFLAGS, (void *) &ifr); + if (ioctl(sk, SIOCSIFFLAGS, (void *) &ifr) < 0) { + err = -errno; + error("bnep: Could not bring up %s: %s(%d)", + devname, strerror(-err), -err); + } close(sk); - if (err < 0) { - error("bnep: Could not bring up %s", devname); - return err; - } - - return 0; + return err; } static int bnep_if_down(const char *devname) |