summaryrefslogtreecommitdiff
path: root/src/libstddjb/sanitize_read.c
blob: 136f7ee9d01d77969f17a9dc17549bbc6751f51e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
/* ISC license. */

#include <sys/types.h>
#include <errno.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/error.h>

ssize_t sanitize_read (ssize_t r)
{
  return r == -1 ? error_isagain(errno) ? (errno = 0, 0) : -1 :
         !r ? (errno = EPIPE, -1) : r ;
}