diff options
author | Jim Meyering <jim@meyering.net> | 2002-09-29 21:25:03 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2002-09-29 21:25:03 +0000 |
commit | 7e1ff0b4f823fb3ae890d7a66ff87566d31e535c (patch) | |
tree | f536f577e7bc9f5fd1501184ed832cead3404bd6 | |
parent | ca9b1df44b1d1904fac1d8d01421833d52d075f8 (diff) | |
download | coreutils-7e1ff0b4f823fb3ae890d7a66ff87566d31e535c.tar.xz |
(simple_cat): Use a temporary to avoid bogus warnings.
(cat): Declare insize and outsize to be of type size_t, not int.
Rearrange pointer/integer expressions to avoid bogus warnings.
(main): Declare insize and outsize to be of type size_t, not int.
-rw-r--r-- | src/cat.c | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -182,8 +182,12 @@ simple_cat ( /* Write this block out. */ - if (full_write (STDOUT_FILENO, buf, n_read) != n_read) - error (EXIT_FAILURE, errno, _("write error")); + { + /* The following is ok, since we know that 0 < n_read. */ + size_t n = n_read; + if (full_write (STDOUT_FILENO, buf, n) != n) + error (EXIT_FAILURE, errno, _("write error")); + } } } @@ -199,13 +203,13 @@ cat ( char *inbuf, /* Number of characters read in each read call. */ - int insize, + size_t insize, /* Pointer to the beginning of the output buffer. */ char *outbuf, /* Number of characters written by each write call. */ - int outsize, + size_t outsize, /* Variables that have values according to the specified options. */ int quote, @@ -258,7 +262,7 @@ cat ( { /* Write if there are at least OUTSIZE bytes in OUTBUF. */ - if (bpout - outbuf >= outsize) + if (outbuf + outsize <= bpout) { char *wp = outbuf; do @@ -267,7 +271,7 @@ cat ( error (EXIT_FAILURE, errno, _("write error")); wp += outsize; } - while (bpout - wp >= outsize); + while (wp + outsize <= bpout); /* Move the remaining bytes to the beginning of the buffer. */ @@ -497,10 +501,10 @@ int main (int argc, char **argv) { /* Optimal size of i/o operations of output. */ - int outsize; + size_t outsize; /* Optimal size of i/o operations of input. */ - int insize; + size_t insize; /* Pointer to the input buffer. */ char *inbuf; |