bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnulib] safe-read.[ch] (safe_read): what do you think?


From: Bruno Haible
Subject: Re: [Bug-gnulib] safe-read.[ch] (safe_read): what do you think?
Date: Fri, 22 Nov 2002 17:31:15 +0100 (CET)

Paul Eggert writes:
> Perhaps we should add block_read to gnulib?  It could call safe-read
> to do most of its work.  We would keep safe-read for the few places
> where the code really needs partial reads.

Since I see nothing changed in gnulib/lib today, I've moved forward
and made a set of orthogonal {safe,full}-{read,write}.[hc] files that

  - should work right with large counts and EINTR,
  - use size_t as return value,

safe_xxxx is the variant which allows partial returns, full_xxxx is
the variant where partial return indicates failure.

The symmetry between read and write is nearly complete; the only
difference is that in case of EOF full_read sets errno to 0, whereas
full_write sets it to ENOSPC.

ATTENTION: Users of safe_read() beware of the return type change!!

Bruno


2002-11-22  Bruno Haible  <address@hidden>

        * safe-read.h: Assume C89. Add comments.
        (safe_read): Change return type to size_t.
        * safe-read.c (safe_read): Change return type to size_t. Handle byte
        counts > SSIZE_MAX correctly.
        * safe-write.h: New file.
        * safe-write.c: New file.
        * full-read.h: New file.
        * full-read.c: New file.
        * full-write.h: Assume C89. Add comments.
        * full-write.c: Include safe-write.h.
        (full_write): Rewritten to use safe_write.
        Suggested by Jim Meyering and Paul Eggert.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]