Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ v3 1/3] rfcomm: Fix checking return value instead of errno
@ 2012-08-09 20:29 Lucas De Marchi
  2012-08-09 20:29 ` [PATCH BlueZ v3 2/3] rfcomm: Remove support for configuration file Lucas De Marchi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Lucas De Marchi @ 2012-08-09 20:29 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Lucas De Marchi

We were checking by a positive return value instead of checking by -1
and errno. However when there's no support for TTY kernel returns
EOPNOTSUPP as usual, which in the end will have a return value of -1
and errno will be set to EOPNOTSUPP.
---
 tools/rfcomm.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/tools/rfcomm.c b/tools/rfcomm.c
index e73b0ba..0a80670 100644
--- a/tools/rfcomm.c
+++ b/tools/rfcomm.c
@@ -182,10 +182,14 @@ static int create_dev(int ctl, int dev, uint32_t flags, bdaddr_t *bdaddr, int ar
 	}
 
 	err = ioctl(ctl, RFCOMMCREATEDEV, &req);
-	if (err == EOPNOTSUPP)
-		fprintf(stderr, "RFCOMM TTY support not available\n");
-	else if (err < 0)
-		perror("Can't create device");
+	if (err == -1) {
+		err = -errno;
+
+		if (err == -EOPNOTSUPP)
+			fprintf(stderr, "RFCOMM TTY support not available\n");
+		else
+			perror("Can't create device");
+	}
 
 	return err;
 }
-- 
1.7.11.4


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

end of thread, other threads:[~2012-08-10  5:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-09 20:29 [PATCH BlueZ v3 1/3] rfcomm: Fix checking return value instead of errno Lucas De Marchi
2012-08-09 20:29 ` [PATCH BlueZ v3 2/3] rfcomm: Remove support for configuration file Lucas De Marchi
2012-08-09 20:29 ` [PATCH BlueZ v3 3/3] rfcomm: Fix typo in man page Lucas De Marchi
2012-08-10  5:56 ` [PATCH BlueZ v3 1/3] rfcomm: Fix checking return value instead of errno Marcel Holtmann

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