[hackers] [sbase] An additional size_t-fix in tail(1) || FRIGN

From: <git_AT_suckless.org>
Date: Mon, 9 Feb 2015 16:25:08 +0100 (CET)

commit da5343cf117f7c6e7439c45220ece18d8b691cea
Author: FRIGN <dev_AT_frign.de>
Date: Mon Feb 9 15:47:08 2015 +0100

    An additional size_t-fix in tail(1)

diff --git a/tail.c b/tail.c
index 760d676..36fec77 100644
--- a/tail.c
+++ b/tail.c
_AT_@ -15,9 +15,8 @@ static void
 dropinit(FILE *fp, const char *str, size_t n)
 {
         char *buf = NULL;
- size_t size = 0;
+ size_t size = 0, i = 0;
         ssize_t len;
- unsigned long i = 0;
 
         while (i < n && (len = getline(&buf, &size, fp)) != -1)
                 if (len > 0 && buf[len - 1] == '\n')
_AT_@ -30,14 +29,13 @@ static void
 taketail(FILE *fp, const char *str, size_t n)
 {
         char **ring = NULL;
- long i, j;
- size_t *size = NULL;
+ size_t i, j, *size = NULL;
 
         ring = ecalloc(n, sizeof *ring);
         size = ecalloc(n, sizeof *size);
 
- for (i = j = 0; getline(&ring[i], &size[i], fp) != -1; i = j = (i + 1) % n)
- ;
+ for (i = j = 0; getline(&ring[i], &size[i], fp) != -1; )
+ i = j = (i + 1) % n;
         if (ferror(fp))
                 eprintf("%s: read error:", str);
 
Received on Mon Feb 09 2015 - 16:25:08 CET

This archive was generated by hypermail 2.3.0 : Mon Feb 09 2015 - 16:36:15 CET