Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] bnep: Add extra debug information for bnep_up
@ 2014-10-09 10:17 Andrei Emeltchenko
  2014-10-09 11:30 ` Szymon Janc
  0 siblings, 1 reply; 4+ messages in thread
From: Andrei Emeltchenko @ 2014-10-09 10:17 UTC (permalink / raw)
  To: linux-bluetooth

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

Adding extra debug information helps to investigate failing cases
---
 profiles/network/bnep.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/profiles/network/bnep.c b/profiles/network/bnep.c
index 136709d..a6b8728 100644
--- a/profiles/network/bnep.c
+++ b/profiles/network/bnep.c
@@ -210,7 +210,8 @@ static int bnep_if_up(const char *devname)
 	close(sk);
 
 	if (err < 0) {
-		error("Could not bring up %s", devname);
+		error("Could not bring up %s: %s(%d)", devname, strerror(errno),
+									errno);
 		return err;
 	}
 
-- 
1.9.1


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

* Re: [PATCH] bnep: Add extra debug information for bnep_up
  2014-10-09 10:17 [PATCH] bnep: Add extra debug information for bnep_up Andrei Emeltchenko
@ 2014-10-09 11:30 ` Szymon Janc
  2014-10-09 12:48   ` Szymon Janc
  0 siblings, 1 reply; 4+ messages in thread
From: Szymon Janc @ 2014-10-09 11:30 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth

Hi Andrei,

On Thursday 09 of October 2014 13:17:43 Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> 
> Adding extra debug information helps to investigate failing cases
> ---
>  profiles/network/bnep.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/profiles/network/bnep.c b/profiles/network/bnep.c
> index 136709d..a6b8728 100644
> --- a/profiles/network/bnep.c
> +++ b/profiles/network/bnep.c
> @@ -210,7 +210,8 @@ static int bnep_if_up(const char *devname)
>  	close(sk);
>  
>  	if (err < 0) {
> -		error("Could not bring up %s", devname);
> +		error("Could not bring up %s: %s(%d)", devname, strerror(errno),
> +									errno);
>  		return err;
>  	}

You should use -err no errno here. Errno might be already overwritten by call
to close().
 

-- 
Best regards, 
Szymon Janc

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

* Re: [PATCH] bnep: Add extra debug information for bnep_up
  2014-10-09 11:30 ` Szymon Janc
@ 2014-10-09 12:48   ` Szymon Janc
  2014-10-10  7:18     ` [PATCHv2] " Andrei Emeltchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Szymon Janc @ 2014-10-09 12:48 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth

On Thursday 09 of October 2014 13:30:44 Szymon Janc wrote:
> Hi Andrei,
> 
> On Thursday 09 of October 2014 13:17:43 Andrei Emeltchenko wrote:
> > From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> > 
> > Adding extra debug information helps to investigate failing cases
> > ---
> >  profiles/network/bnep.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/profiles/network/bnep.c b/profiles/network/bnep.c
> > index 136709d..a6b8728 100644
> > --- a/profiles/network/bnep.c
> > +++ b/profiles/network/bnep.c
> > @@ -210,7 +210,8 @@ static int bnep_if_up(const char *devname)
> >  	close(sk);
> >  
> >  	if (err < 0) {
> > -		error("Could not bring up %s", devname);
> > +		error("Could not bring up %s: %s(%d)", devname, strerror(errno),
> > +									errno);
> >  		return err;
> >  	}
> 
> You should use -err no errno here. Errno might be already overwritten by call
> to close().

Well, not exactly, errno should be also stored to err before calling close().

-- 
Best regards, 
Szymon Janc

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

* [PATCHv2] bnep: Add extra debug information for bnep_up
  2014-10-09 12:48   ` Szymon Janc
@ 2014-10-10  7:18     ` Andrei Emeltchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Andrei Emeltchenko @ 2014-10-10  7:18 UTC (permalink / raw)
  To: linux-bluetooth

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

Adding extra debug information helps to investigate failing cases
Return meaningful error code.
---
 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 136709d..070c22e 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("Could not bring up %s: %s(%d)", devname, strerror(-err),
+									-err);
+	}
 
 	close(sk);
 
-	if (err < 0) {
-		error("Could not bring up %s", devname);
-		return err;
-	}
-
-	return 0;
+	return err;
 }
 
 static int bnep_if_down(const char *devname)
-- 
1.9.1


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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-09 10:17 [PATCH] bnep: Add extra debug information for bnep_up Andrei Emeltchenko
2014-10-09 11:30 ` Szymon Janc
2014-10-09 12:48   ` Szymon Janc
2014-10-10  7:18     ` [PATCHv2] " Andrei Emeltchenko

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