# HG changeset patch # User Paul Boddie # Date 1621114719 -7200 # Node ID 9a0450379ec780ba9b8d87d651499fb194f33afe # Parent ab84389f975e9a0d1132f1ee404d4cd133bbda2d Return errors from region navigation functions instead of memory addresses. diff -r ab84389f975e -r 9a0450379ec7 libfsclient/include/fsclient/client.h --- a/libfsclient/include/fsclient/client.h Sat May 15 17:10:02 2021 +0200 +++ b/libfsclient/include/fsclient/client.h Sat May 15 23:38:39 2021 +0200 @@ -41,8 +41,8 @@ /* Pipe region operations. */ -void *client_current_region(file_t *file); -void *client_next_region(file_t *file); +long client_current_region(file_t *file); +long client_next_region(file_t *file); /* File data operations. */ diff -r ab84389f975e -r 9a0450379ec7 libfsclient/lib/src/client.cc --- a/libfsclient/lib/src/client.cc Sat May 15 17:10:02 2021 +0200 +++ b/libfsclient/lib/src/client.cc Sat May 15 23:38:39 2021 +0200 @@ -147,16 +147,18 @@ else if (position == file->end_pos) { - if (client_next_region(file) == NULL) - return -L4_EIO; + err = client_next_region(file); + if (err) + return err; } /* Within the current pipe region, synchronise with the pipe object. */ else { - if (client_current_region(file) == NULL) - return -L4_EIO; + err = client_current_region(file); + if (err) + return err; } } @@ -200,24 +202,24 @@ /* Obtain the current region of a pipe. */ -void *client_current_region(file_t *file) +long client_current_region(file_t *file) { - if ((file == NULL) || (pipe_current(file))) - return NULL; + if (file == NULL) + return -L4_EINVAL; - return file->memory; + return pipe_current(file); } /* Obtain the next region of a pipe. */ -void *client_next_region(file_t *file) +long client_next_region(file_t *file) { - if ((file == NULL) || (pipe_next(file))) - return NULL; + if (file == NULL) + return -L4_EINVAL; - return file->memory; + return pipe_next(file); }