Re: __attribute__((warn_unused_result)) for NetBSD?
Aleksey Cheusov <[email protected]>
| Newsgroups | gmane.os.netbsd.devel.general |
|---|---|
| Message-ID | <[email protected]> |
> In general EBADF is meaningless on close.
Yes, EBADF is not a big problem.
> Isn't it only possible to get EINTR on non-blocking I/O? Otherwise
> isn't this an auto-restarted call?
AFAIK SA_RESTART is BSD-ism and is absent on many systems.
> Anyways, for the most part all common usages of close don't need
> warnings about missing the return value that I can see.
I personally disagree. The following is much more robust approach.
void xclose (int fd)
{
int ret;
do {
ret = close (fd);
}while (ret == -1 && errno == EINTR);
if (ret == -1){
perror("perror failed");
exit (1);
}
}
The same for read(2), write(2) and many others.
--
Best regards, Aleksey Cheusov.