Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 1/3] bnep: Add error print and return errno instead of -1
@ 2014-10-22 11:10 Andrei Emeltchenko
  2014-10-22 11:10 ` [PATCH 2/3] bnep: trivial: code cleanup Andrei Emeltchenko
  2014-10-22 11:10 ` [PATCH 3/3] bnep: Return errno instead of -1 and print error Andrei Emeltchenko
  0 siblings, 2 replies; 9+ messages in thread
From: Andrei Emeltchenko @ 2014-10-22 11:10 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

---
 profiles/network/bnep.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/profiles/network/bnep.c b/profiles/network/bnep.c
index 927367c..1024919 100644
--- a/profiles/network/bnep.c
+++ b/profiles/network/bnep.c
@@ -219,7 +219,7 @@ static int bnep_if_up(const char *devname)
 static int bnep_if_down(const char *devname)
 {
 	struct ifreq ifr;
-	int sk, err;
+	int sk, err = 0;
 
 	sk = socket(AF_INET, SOCK_DGRAM, 0);
 
@@ -229,16 +229,15 @@ static int bnep_if_down(const char *devname)
 	ifr.ifr_flags &= ~IFF_UP;
 
 	/* Bring down the interface */
-	err = ioctl(sk, SIOCSIFFLAGS, (void *) &ifr);
+	if (ioctl(sk, SIOCSIFFLAGS, (void *) &ifr) < 0) {
+		err = -errno;
+		error("bnep: Could not bring down %s: %s(%d)",
+				devname, strerror(-err), -err);
+	}
 
 	close(sk);
 
-	if (err < 0) {
-		error("bnep: Could not bring down %s", devname);
-		return err;
-	}
-
-	return 0;
+	return err;
 }
 
 static gboolean bnep_watchdog_cb(GIOChannel *chan, GIOCondition cond,
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-10-23 10:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-22 11:10 [PATCH 1/3] bnep: Add error print and return errno instead of -1 Andrei Emeltchenko
2014-10-22 11:10 ` [PATCH 2/3] bnep: trivial: code cleanup Andrei Emeltchenko
2014-10-22 11:10 ` [PATCH 3/3] bnep: Return errno instead of -1 and print error Andrei Emeltchenko
2014-10-22 12:55   ` Grzegorz Kolodziejczyk
2014-10-22 13:34     ` [PATCHv2 1/3] bnep: Add error print and return errno instead of -1 Andrei Emeltchenko
2014-10-22 13:34       ` [PATCHv2 2/3] bnep: trivial: code cleanup Andrei Emeltchenko
2014-10-22 13:34       ` [PATCHv2 3/3] bnep: Return errno instead of -1 and print error Andrei Emeltchenko
2014-10-23 10:23       ` [PATCHv2 1/3] bnep: Add error print and return errno instead of -1 Luiz Augusto von Dentz
2014-10-22 13:37     ` [PATCH 3/3] bnep: Return errno instead of -1 and print error Andrei Emeltchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox