From 2d14aa612e57abb7c4bad91acceb420774c7f3ba Mon Sep 17 00:00:00 2001 From: Michael Moon Date: Fri, 24 Jan 2014 13:42:44 +1100 Subject: [PATCH] Pin: code cleanup, no functionality changes --- src/libs/Pin.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/libs/Pin.cpp b/src/libs/Pin.cpp index 5845e6e4..bc234d2a 100644 --- a/src/libs/Pin.cpp +++ b/src/libs/Pin.cpp @@ -30,7 +30,7 @@ Pin* Pin::from_string(std::string value){ this->pin = strtol(cs, &cn, 10); // if strtol read some numbers, cn will point to the first non-digit - if ((cn > cs) & (pin < 32)){ + if ((cn > cs) && (pin < 32)){ this->port->FIOMASK &= ~(1 << this->pin); // now check for modifiers:- @@ -40,8 +40,7 @@ Pin* Pin::from_string(std::string value){ // v = set pin to pull down // - = set pin to no pull up or down // @ = set pin to repeater mode - bool done= false; - while(!done) { + for (;*cn;cn++) { switch(*cn) { case '!': this->inverting = true; @@ -64,13 +63,9 @@ Pin* Pin::from_string(std::string value){ default: // skip any whitespace following the pin index if (!is_whitespace(*cn)) - done = true; + return this; } - if (!done) - cn++; } - - return this; } } -- 2.20.1