Go Down

Topic: bug in socket.cpp (Read 918 times) previous topic - next topic

lampmaker

I may have found a bug in socket.cpp

uint8_t recv(SOCKET s, uint8_t *buf, uint16_t len)

I believe this should be a int instead of uint8_t.
Same for uint_8 ret.

reason: if the connection is still up but there is no data to be read, ret is set to -1.   for a uint_8_t, this will result in a positive number. 
Later in the same routine,   if ( ret > 0 ) yield true in this case, though it is not what you would want.

Anyone please confirm if I got this right.  My knowledge of C++ is still fairly limited.






Jantje

lampmaker
What you are describing is a logical bug. I mean from code reading point of view it is wrong.
I'm however not sure whether the compiler will generate bad code. If not you save a byte of memory by sticking to 8 bit.

I've tried to look at the code but I can not find any socket.cpp delivered with arduino. Where did you get the code from?

Best regards
Jantje
Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

lampmaker

socket.cpp is in libraries\Ethernet\utility

Jantje

lampmaker
I've double checked and indeed this is a bug.
you have perfectly understood the code.
The code will however not fail but the desired optimization will not happen.
Best regards
Jantje

Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

robtillaart

LampMaker, which version of Arduino IDE are you using?

You can post (serious) bugreports here, - http://code.google.com/p/arduino/issues/list -
think this is serious enough
(If you don't wanna post I can do it, just PM me with a link to this thread)
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up