summaryrefslogtreecommitdiff
path: root/lib/bluetooth.c
diff options
context:
space:
mode:
authorSzymon Janc <szymon.janc@tieto.com>2011-03-02 11:19:27 +0100
committerJohan Hedberg <johan.hedberg@nokia.com>2011-03-04 15:42:25 -0300
commite41eccc12323d6a7eafbdfdf0715283a5282f14c (patch)
tree621a6fc23dbb6ced0d8051a926e9c73719c392e9 /lib/bluetooth.c
parenta1d241d41f354b56fe9ef1174cc08f5eedf2cbb1 (diff)
Simplify bachk function
By using isxdigit() the function can be considerably simplified.
Diffstat (limited to 'lib/bluetooth.c')
-rw-r--r--lib/bluetooth.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/lib/bluetooth.c b/lib/bluetooth.c
index 4af2ef693..875119bb8 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;