named-data-iot/ndn-iot-package-over-posix

POSIX compatibility

Opened this issue · 6 comments

Pesa commented

This package is targeted at "POSIX compatible OS". However, looking at the code, I noticed several incompatibilities with POSIX. These are a couple of examples I saw so far, but I only took a quick look and there may be others:

size = recvfrom(ptr->sock, ptr->buf, sizeof(ptr->buf), MSG_DONTWAIT,
(struct sockaddr*)&client_addr, &addr_len);

MSG_DONTWAIT is not specified by POSIX.

}else if(size == -1 && errno == EWOULDBLOCK){

POSIX.1-2001 allows either EAGAIN or EWOULDBLOCK to be returned for this case, and does not guarantee that these constants have the same value, so a portable application should check for both.

if(ioctl(ptr->sock, FIONBIO, (char *)&iyes) == -1){

FIONBIO is non-standard. You should use fcntl(...O_NONBLOCK...) instead.

Fixed. Thank you for your comments!

Pesa commented

Well... there are several more instances of these or similar problems still present in the codebase... how do you plan to address them? The 3 cases I reported above were just a few examples I noticed from a quick look.

We are planning to review our design recently. I will figure it out then.

Pesa commented

Any updates?

No. Till now we haven't figured out what else is not compatible to POSIX.

Is there a linter that automatically find non POSIX complaint function calls?