gpgscm: Drop 'len' argument from splice.

* tests/gpgscm/ffi.c (do_splice): Drop 'len' argument, no-one uses it.
* tests/gpgscm/lib.scm (splice): Document foreign function.

Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
Justus Winter 2016-11-07 16:59:15 +01:00
parent a55393cb5f
commit 4d98a72b88
2 changed files with 5 additions and 11 deletions

View File

@ -1001,29 +1001,20 @@ do_splice (scheme *sc, pointer args)
FFI_PROLOG ();
int source;
int sink;
ssize_t len = -1;
char buffer[1024];
ssize_t bytes_read;
FFI_ARG_OR_RETURN (sc, int, source, number, args);
FFI_ARG_OR_RETURN (sc, int, sink, number, args);
if (args != sc->NIL)
FFI_ARG_OR_RETURN (sc, ssize_t, len, number, args);
FFI_ARGS_DONE_OR_RETURN (sc, args);
while (len == -1 || len > 0)
while (1)
{
size_t want = sizeof buffer;
if (len > 0 && (ssize_t) want > len)
want = (size_t) len;
bytes_read = read (source, buffer, want);
bytes_read = read (source, buffer, sizeof buffer);
if (bytes_read == 0)
break;
if (bytes_read < 0)
FFI_RETURN_ERR (sc, gpg_error_from_syserror ());
if (write (sink, buffer, bytes_read) != bytes_read)
FFI_RETURN_ERR (sc, gpg_error_from_syserror ());
if (len != -1)
len -= bytes_read;
}
FFI_RETURN (sc);
}

View File

@ -207,6 +207,9 @@
;; Get our process id.
(ffi-define (getpid))
;; Copy data from file descriptor SOURCE to SINK.
(ffi-define (splice source sink))
;;
;; Random numbers.
;;