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

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

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