Open edwin-oetelaar opened 5 years ago
The macro is incorrect.
Suppose we have a W5500 with 8 sockets ... these are numbered 0..7
8 is not a valid socket number.. This macro does not respect this, it does not return SOCKERR_SOCKNUM on an invalid socket number.
#define CHECK_SOCKNUM() \ do{ \ if(sn > _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \ }while(0); \
I personally find all this way of coding (macros which assume parameters to be named a certain way, like sn) very ugly and I am rewriting all wiznet code for my own project into clean C code.
Here is a quick fix, just as ugly
#define CHECK_SOCKNUM() do{ if(!(sn < _WIZCHIP_SOCK_NUM_)) return SOCKERR_SOCKNUM; } while(0);
I think a more visual and easy way is to use >=
#define CHECK_SOCKNUM() \ do{ \ if(sn >= _WIZCHIP_SOCK_NUM_) return SOCKERR_SOCKNUM; \ }while(0); \
The macro is incorrect.
Suppose we have a W5500 with 8 sockets ... these are numbered 0..7
8 is not a valid socket number.. This macro does not respect this, it does not return SOCKERR_SOCKNUM on an invalid socket number.
I personally find all this way of coding (macros which assume parameters to be named a certain way, like sn) very ugly and I am rewriting all wiznet code for my own project into clean C code.
Here is a quick fix, just as ugly