Pages: [1]   Go Down
Author Topic: bug in socket.cpp  (Read 854 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.





Logged

Belgium
Offline Offline
Edison Member
*
Karma: 68
Posts: 1910
Arduino rocks; but with my plugin it can fly rocking the world ;-)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

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 -

0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

socket.cpp is in libraries\Ethernet\utility
Logged

Belgium
Offline Offline
Edison Member
*
Karma: 68
Posts: 1910
Arduino rocks; but with my plugin it can fly rocking the world ;-)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

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 -

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
Logged

Rob Tillaart

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

Pages: [1]   Go Up
Jump to: