Skip to content

Commit

Permalink
Convert a lot of apr_ssize_t to apr_size_t. We don't ever accept or r…
Browse files Browse the repository at this point in the history
…eturn

signed values in these integers, and we return the error codes directly,
so we should always report the number of bytes read/written correctly.  If
we have an error, that is 0 bytes.  If that is true, then using signed
values doesn't make any sense.


git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@60642 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Ryan Bloom committed Nov 7, 2000
1 parent 3177e18 commit d5cbec7
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 52 deletions.
10 changes: 5 additions & 5 deletions file_io/os2/readwrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#include <os2.h>
#include <malloc.h>

apr_status_t apr_read(apr_file_t *thefile, void *buf, apr_ssize_t *nbytes)
apr_status_t apr_read(apr_file_t *thefile, void *buf, apr_size_t *nbytes)
{
ULONG rc = 0;
ULONG bytesread;
Expand Down Expand Up @@ -138,7 +138,7 @@ apr_status_t apr_read(apr_file_t *thefile, void *buf, apr_ssize_t *nbytes)



apr_status_t apr_write(apr_file_t *thefile, const void *buf, apr_ssize_t *nbytes)
apr_status_t apr_write(apr_file_t *thefile, const void *buf, apr_size_t *nbytes)
{
ULONG rc = 0;
ULONG byteswritten;
Expand Down Expand Up @@ -194,7 +194,7 @@ apr_status_t apr_write(apr_file_t *thefile, const void *buf, apr_ssize_t *nbytes

#ifdef HAVE_WRITEV

apr_status_t apr_writev(apr_file_t *thefile, const struct iovec *vec, apr_size_t nvec, apr_ssize_t *nbytes)
apr_status_t apr_writev(apr_file_t *thefile, const struct iovec *vec, apr_size_t nvec, apr_size_t *nbytes)
{
int bytes;
if ((bytes = writev(thefile->filedes, vec, nvec)) < 0) {
Expand Down Expand Up @@ -266,7 +266,7 @@ apr_status_t apr_getc(char *ch, apr_file_t *thefile)

apr_status_t apr_puts(const char *str, apr_file_t *thefile)
{
apr_ssize_t len;
apr_size_t len;

len = strlen(str);
return apr_write(thefile, str, &len);
Expand Down Expand Up @@ -301,7 +301,7 @@ apr_status_t apr_flush(apr_file_t *thefile)

apr_status_t apr_fgets(char *str, int len, apr_file_t *thefile)
{
ssize_t readlen;
size_t readlen;
apr_status_t rv = APR_SUCCESS;
int i;

Expand Down
4 changes: 2 additions & 2 deletions file_io/unix/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ apr_status_t apr_remove_dir(const char *path, apr_pool_t *cont)
}
}

apr_status_t apr_dir_entry_size(apr_ssize_t *size, apr_dir_t *thedir)
apr_status_t apr_dir_entry_size(apr_size_t *size, apr_dir_t *thedir)
{
struct stat filestat;
char *fname = NULL;
Expand All @@ -175,7 +175,7 @@ apr_status_t apr_dir_entry_size(apr_ssize_t *size, apr_dir_t *thedir)
fname = apr_pstrcat(thedir->cntxt, thedir->dirname, "/",
thedir->entry->d_name, NULL);
if (stat(fname, &filestat) == -1) {
*size = -1;
*size = 0;
return errno;
}

Expand Down
16 changes: 8 additions & 8 deletions file_io/unix/readwrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ static apr_status_t wait_for_io_or_timeout(apr_file_t *file, int for_read)
/* problems:
* 1) ungetchar not used for buffered files
*/
apr_status_t apr_read(apr_file_t *thefile, void *buf, apr_ssize_t *nbytes)
apr_status_t apr_read(apr_file_t *thefile, void *buf, apr_size_t *nbytes)
{
apr_ssize_t rv;
apr_ssize_t bytes_read;
apr_size_t bytes_read;

if (*nbytes <= 0) {
*nbytes = 0;
Expand Down Expand Up @@ -205,7 +205,7 @@ apr_status_t apr_read(apr_file_t *thefile, void *buf, apr_ssize_t *nbytes)
}
}

apr_status_t apr_write(apr_file_t *thefile, const void *buf, apr_ssize_t *nbytes)
apr_status_t apr_write(apr_file_t *thefile, const void *buf, apr_size_t *nbytes)
{
apr_size_t rv;

Expand Down Expand Up @@ -277,7 +277,7 @@ apr_status_t apr_write(apr_file_t *thefile, const void *buf, apr_ssize_t *nbytes
}

apr_status_t apr_writev(apr_file_t *thefile, const struct iovec *vec,
apr_size_t nvec, apr_ssize_t *nbytes)
apr_size_t nvec, apr_size_t *nbytes)
{
#ifdef HAVE_WRITEV
int bytes;
Expand All @@ -298,7 +298,7 @@ apr_status_t apr_writev(apr_file_t *thefile, const struct iovec *vec,

apr_status_t apr_putc(char ch, apr_file_t *thefile)
{
apr_ssize_t nbytes = 1;
apr_size_t nbytes = 1;

return apr_write(thefile, &ch, &nbytes);
}
Expand All @@ -311,14 +311,14 @@ apr_status_t apr_ungetc(char ch, apr_file_t *thefile)

apr_status_t apr_getc(char *ch, apr_file_t *thefile)
{
apr_ssize_t nbytes = 1;
apr_size_t nbytes = 1;

return apr_read(thefile, ch, &nbytes);
}

apr_status_t apr_puts(const char *str, apr_file_t *thefile)
{
apr_ssize_t nbytes = strlen(str);
apr_size_t nbytes = strlen(str);

return apr_write(thefile, str, &nbytes);
}
Expand Down Expand Up @@ -348,7 +348,7 @@ apr_status_t apr_flush(apr_file_t *thefile)
apr_status_t apr_fgets(char *str, int len, apr_file_t *thefile)
{
apr_status_t rv = APR_SUCCESS; /* get rid of gcc warning */
apr_ssize_t nbytes;
apr_size_t nbytes;
char *final = str + len - 1;

if (len <= 1) {
Expand Down
20 changes: 10 additions & 10 deletions file_io/win32/readwrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
* read_with_timeout()
* Uses async i/o to emulate unix non-blocking i/o with timeouts.
*/
static apr_status_t read_with_timeout(apr_file_t *file, void *buf, apr_ssize_t len, apr_ssize_t *nbytes)
static apr_status_t read_with_timeout(apr_file_t *file, void *buf, apr_size_t len, apr_size_t *nbytes)
{
apr_status_t rv;
*nbytes = 0;
Expand Down Expand Up @@ -148,9 +148,9 @@ static apr_status_t read_with_timeout(apr_file_t *file, void *buf, apr_ssize_t l
return rv;
}

apr_status_t apr_read(apr_file_t *thefile, void *buf, apr_ssize_t *len)
apr_status_t apr_read(apr_file_t *thefile, void *buf, apr_size_t *len)
{
apr_ssize_t rv;
apr_size_t rv;
DWORD bytes_read = 0;

if (*len <= 0) {
Expand All @@ -172,8 +172,8 @@ apr_status_t apr_read(apr_file_t *thefile, void *buf, apr_ssize_t *len)
}
if (thefile->buffered) {
char *pos = (char *)buf;
apr_ssize_t blocksize;
apr_ssize_t size = *len;
apr_size_t blocksize;
apr_size_t size = *len;

apr_lock(thefile->mutex);

Expand Down Expand Up @@ -213,15 +213,15 @@ apr_status_t apr_read(apr_file_t *thefile, void *buf, apr_ssize_t *len)
apr_unlock(thefile->mutex);
} else {
/* Unbuffered i/o */
apr_ssize_t nbytes;
apr_size_t nbytes;
rv = read_with_timeout(thefile, buf, *len, &nbytes);
*len = nbytes;
}

return rv;
}

apr_status_t apr_write(apr_file_t *thefile, const void *buf, apr_ssize_t *nbytes)
apr_status_t apr_write(apr_file_t *thefile, const void *buf, apr_size_t *nbytes)
{
apr_status_t rv;
DWORD bwrote;
Expand All @@ -235,7 +235,7 @@ apr_status_t apr_write(apr_file_t *thefile, const void *buf, apr_ssize_t *nbytes

if (thefile->direction == 0) {
// Position file pointer for writing at the offset we are logically reading from
apr_ssize_t offset = thefile->filePtr - thefile->dataRead + thefile->bufpos;
apr_size_t offset = thefile->filePtr - thefile->dataRead + thefile->bufpos;
if (offset != thefile->filePtr)
SetFilePointer(thefile->filehand, offset, NULL, FILE_BEGIN);
thefile->bufpos = thefile->dataRead = 0;
Expand Down Expand Up @@ -276,7 +276,7 @@ apr_status_t apr_write(apr_file_t *thefile, const void *buf, apr_ssize_t *nbytes
* Too bad WriteFileGather() is not supported on 95&98 (or NT prior to SP2)
*/
apr_status_t apr_writev(apr_file_t *thefile, const struct iovec *vec, apr_size_t nvec,
apr_ssize_t *nbytes)
apr_size_t *nbytes)
{
apr_status_t rv = APR_SUCCESS;
int i;
Expand Down Expand Up @@ -337,7 +337,7 @@ apr_status_t apr_puts(const char *str, apr_file_t *thefile)

apr_status_t apr_fgets(char *str, int len, apr_file_t *thefile)
{
apr_ssize_t readlen;
apr_size_t readlen;
apr_status_t rv = APR_SUCCESS;
int i;

Expand Down
8 changes: 4 additions & 4 deletions include/apr_file_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ apr_status_t apr_open_stderr(apr_file_t **thefile, apr_pool_t *cont);
*
* APR_EINTR is never returned.
*/
apr_status_t apr_read(apr_file_t *thefile, void *buf, apr_ssize_t *nbytes);
apr_status_t apr_read(apr_file_t *thefile, void *buf, apr_size_t *nbytes);

/**
* Write data to the specified file.
Expand All @@ -373,7 +373,7 @@ apr_status_t apr_read(apr_file_t *thefile, void *buf, apr_ssize_t *nbytes);
*
* APR_EINTR is never returned.
*/
apr_status_t apr_write(apr_file_t *thefile, const void *buf, apr_ssize_t *nbytes);
apr_status_t apr_write(apr_file_t *thefile, const void *buf, apr_size_t *nbytes);

/**
* Write data from iovec array to the specified file.
Expand All @@ -391,7 +391,7 @@ apr_status_t apr_write(apr_file_t *thefile, const void *buf, apr_ssize_t *nbytes
* doesn't provide writev().
*/
apr_status_t apr_writev(apr_file_t *thefile, const struct iovec *vec,
apr_size_t nvec, apr_ssize_t *nbytes);
apr_size_t nvec, apr_size_t *nbytes);

/**
* Read data from the specified file.
Expand Down Expand Up @@ -648,7 +648,7 @@ apr_status_t apr_set_filedata(apr_file_t *file, void *data, const char *key,
* @param size the size of the directory entry.
* @param thedir the currently open directory.
*/
apr_status_t apr_dir_entry_size(apr_ssize_t *size, apr_dir_t *thedir);
apr_status_t apr_dir_entry_size(apr_size_t *size, apr_dir_t *thedir);

/**
* Get the last modified time of the current directory entry.
Expand Down
8 changes: 4 additions & 4 deletions include/apr_network_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ apr_status_t apr_set_socketdata(apr_socket_t *sock, void *data, const char *key,
* APR_EINTR is never returned.
* </PRE>
*/
apr_status_t apr_send(apr_socket_t *sock, const char *buf, apr_ssize_t *len);
apr_status_t apr_send(apr_socket_t *sock, const char *buf, apr_size_t *len);

/**
* Send multiple packets of data over a network.
Expand All @@ -291,7 +291,7 @@ apr_status_t apr_send(apr_socket_t *sock, const char *buf, apr_ssize_t *len);
* </PRE>
*/
apr_status_t apr_sendv(apr_socket_t *sock, const struct iovec *vec,
apr_int32_t nvec, apr_ssize_t *len);
apr_int32_t nvec, apr_size_t *len);

#if APR_HAS_SENDFILE
/**
Expand All @@ -308,7 +308,7 @@ apr_status_t apr_sendv(apr_socket_t *sock, const struct iovec *vec,
* The number of bytes actually sent is stored in argument 5.
*/
apr_status_t apr_sendfile(apr_socket_t *sock, apr_file_t *file, apr_hdtr_t *hdtr,
apr_off_t *offset, apr_ssize_t *len, apr_int32_t flags);
apr_off_t *offset, apr_size_t *len, apr_int32_t flags);
#endif

/**
Expand All @@ -329,7 +329,7 @@ apr_status_t apr_sendfile(apr_socket_t *sock, apr_file_t *file, apr_hdtr_t *hdtr
* APR_EINTR is never returned.
* </PRE>
*/
apr_status_t apr_recv(apr_socket_t *sock, char *buf, apr_ssize_t *len);
apr_status_t apr_recv(apr_socket_t *sock, char *buf, apr_size_t *len);

/**
* Setup socket options for the specified socket
Expand Down
6 changes: 3 additions & 3 deletions network_io/beos/sendrecv.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static apr_status_t wait_for_io_or_timeout(apr_socket_t *sock, int for_read)
return APR_SUCCESS;
}

apr_status_t apr_send(apr_socket_t *sock, const char *buf, apr_ssize_t *len)
apr_status_t apr_send(apr_socket_t *sock, const char *buf, apr_size_t *len)
{
ssize_t rv;

Expand Down Expand Up @@ -120,7 +120,7 @@ apr_status_t apr_send(apr_socket_t *sock, const char *buf, apr_ssize_t *len)
return APR_SUCCESS;
}

apr_status_t apr_recv(apr_socket_t *sock, char *buf, apr_ssize_t *len)
apr_status_t apr_recv(apr_socket_t *sock, char *buf, apr_size_t *len)
{
apr_ssize_t rv;

Expand Down Expand Up @@ -151,7 +151,7 @@ apr_status_t apr_recv(apr_socket_t *sock, char *buf, apr_ssize_t *len)
/* BeOS doesn't have writev for sockets so we use the following instead...
*/
apr_status_t apr_sendv(apr_socket_t * sock, const struct iovec *vec,
apr_int32_t nvec, apr_ssize_t *len)
apr_int32_t nvec, apr_size_t *len)
{
*len = vec[0].iov_len;
return apr_send(sock, vec[0].iov_base, len);
Expand Down
4 changes: 2 additions & 2 deletions network_io/os2/sendrecv.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#include "apr_lib.h"
#include <sys/time.h>

apr_status_t apr_send(apr_socket_t *sock, const char *buf, apr_ssize_t *len)
apr_status_t apr_send(apr_socket_t *sock, const char *buf, apr_size_t *len)
{
ssize_t rv;
int fds, err = 0;
Expand Down Expand Up @@ -98,7 +98,7 @@ apr_status_t apr_send(apr_socket_t *sock, const char *buf, apr_ssize_t *len)



apr_status_t apr_recv(apr_socket_t *sock, char *buf, apr_ssize_t *len)
apr_status_t apr_recv(apr_socket_t *sock, char *buf, apr_size_t *len)
{
ssize_t rv;
int fds, err = 0;
Expand Down
Loading

0 comments on commit d5cbec7

Please sign in to comment.