As made obvious by commit
123f53f, the type of ssize_t cannot be trusted
on Windows to actually be signed, so don't use '< 0', as the compiler
will optimize the test away. POSIX also specifies only that -1 signals
an error condition, not any other negative value.
Luckily, comparing an unsigned int to -1 still works as intended.
ssize_t len = utcp_send(c, "Hello world!\n", 13);
if(len != 13) {
- if(len < 0)
+ if(len == -1)
fprintf(stderr, "Error: %s\n", strerror(errno));
else
fprintf(stderr, "Short write %zd!\n", len);
len = utcp_send(c, "This is a test.\n", 16);
if(len != 16) {
- if(len < 0)
+ if(len == -1)
fprintf(stderr, "Error: %s\n", strerror(errno));
else
fprintf(stderr, "Short write %zd!\n", len);
return 1;
int s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
- if(s < 0)
+ if(s == -1)
return 1;
if(server) {
dir &= ~1;
if(c)
utcp_shutdown(c, SHUT_WR);
- if(len < 0)
+ if(len == -1)
break;
else
continue;