X-Git-Url: http://olsr.org/git/?p=olsrd.git;a=blobdiff_plain;f=lib%2Fpud%2Fwireformat%2Fsrc%2FwireFormat.c;h=2f74038fe95d78f5e6d7bb8397184a95a98e7609;hp=07e986698c73d0a7dc10932f3d7e2c252cb8644a;hb=88e0dc2bf3b295dd84587c961a8a9e0edf17ca24;hpb=12f8eb2f17fd44d9ee0ea16311146feac3803083 diff --git a/lib/pud/wireformat/src/wireFormat.c b/lib/pud/wireformat/src/wireFormat.c index 07e98669..2f74038f 100644 --- a/lib/pud/wireformat/src/wireFormat.c +++ b/lib/pud/wireformat/src/wireFormat.c @@ -40,15 +40,10 @@ static unsigned char cachedNodeIdBuffer[PUD_CACHED_NODEID_BUFFER_SIZE]; static unsigned int cachedNodeIdBufferLength = 0; /** - Check a nodeId number for validity and if valid set it up in the - cachedNodeIdBuffer. The valid range for the number is [min, max]. + Setup a nodeId number in the cachedNodeIdBuffer. @param val The value to setup in the cache - @param min - The lower bound for a valid number - @param max - The upper bound for a valid number @param bytes The number of bytes used by the number in the wire format @@ -56,25 +51,23 @@ static unsigned int cachedNodeIdBufferLength = 0; - true when the number is valid - false otherwise */ -bool setupNodeIdNumberForOlsrCache(unsigned long long val, - unsigned long long min, unsigned long long max, unsigned int bytes) { - assert(bytes <= PUD_CACHED_NODEID_BUFFER_SIZE); - - if ((val >= min) && (val <= max)) { - int i = bytes - 1; - while (i >= 0) { - cachedNodeIdBuffer[i] = val & 0xff; - val >>= 8; - i--; - } +bool setupNodeIdNumberForOlsrCache(unsigned long long val, unsigned int bytes) { + int i = bytes - 1; - assert(val == 0); + if (bytes > PUD_CACHED_NODEID_BUFFER_SIZE) { + return false; + } - cachedNodeIdBufferLength = bytes; - return true; + while (i >= 0) { + cachedNodeIdBuffer[i] = val & 0xff; + val >>= 8; + i--; } - return false; + assert(val == 0); + + cachedNodeIdBufferLength = bytes; + return true; } /**