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

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

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