Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] Simplify bachk function
@ 2011-03-02 10:19 Szymon Janc
  2011-03-04 18:45 ` Johan Hedberg
  0 siblings, 1 reply; 2+ messages in thread
From: Szymon Janc @ 2011-03-02 10:19 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: par-gunnar.p.hjalmdahl, henrik.possung, Szymon Janc

---
 lib/bluetooth.c |   21 ++++++---------------
 1 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/lib/bluetooth.c b/lib/bluetooth.c
index 4af2ef6..875119b 100644
--- a/lib/bluetooth.c
+++ b/lib/bluetooth.c
@@ -118,33 +118,24 @@ int ba2oui(const bdaddr_t *ba, char *str)
 
 int bachk(const char *str)
 {
-	char tmp[18], *ptr = tmp;
-
 	if (!str)
 		return -1;
 
 	if (strlen(str) != 17)
 		return -1;
 
-	memcpy(tmp, str, 18);
-
-	while (*ptr) {
-		*ptr = toupper(*ptr);
-		if (*ptr < '0'|| (*ptr > '9' && *ptr < 'A') || *ptr > 'F')
+	while (*str) {
+		if (!isxdigit(*str++))
 			return -1;
-		ptr++;
 
-		*ptr = toupper(*ptr);
-		if (*ptr < '0'|| (*ptr > '9' && *ptr < 'A') || *ptr > 'F')
+		if (!isxdigit(*str++))
 			return -1;
-		ptr++;
 
-		*ptr = toupper(*ptr);
-		if (*ptr == 0)
+		if (*str == 0)
 			break;
-		if (*ptr != ':')
+
+		if (*str++ != ':')
 			return -1;
-		ptr++;
 	}
 
 	return 0;
-- 
1.7.0.4
on behalf of ST-Ericsson

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

end of thread, other threads:[~2011-03-04 18:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-02 10:19 [PATCH] Simplify bachk function Szymon Janc
2011-03-04 18:45 ` Johan Hedberg

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