aboutsummaryrefslogtreecommitdiff
path: root/qlop.c
diff options
context:
space:
mode:
authorFabian Groffen <grobian@gentoo.org>2018-03-23 12:55:26 +0100
committerFabian Groffen <grobian@gentoo.org>2018-03-23 12:55:26 +0100
commitbeb68b28d4694aa576d0e06fc37deb31d83cef80 (patch)
tree610858617ea2e86ccb75c85f1faf6af0c29579eb /qlop.c
parentis_prelink_elf: squash unused variable warning (diff)
downloadportage-utils-beb68b28d4694aa576d0e06fc37deb31d83cef80.tar.gz
portage-utils-beb68b28d4694aa576d0e06fc37deb31d83cef80.tar.bz2
portage-utils-beb68b28d4694aa576d0e06fc37deb31d83cef80.zip
getline: fix comparison of integers of different signs
Just use an int to store getline return, then ensure it is positive, such that a cast to size_t is guaranteed to result in the same value.
Diffstat (limited to 'qlop.c')
-rw-r--r--qlop.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/qlop.c b/qlop.c
index f0c35b73..5be2ddd3 100644
--- a/qlop.c
+++ b/qlop.c
@@ -232,7 +232,8 @@ show_emerge_history(int listflag, array_t *atoms, const char *logfile,
time_t start_time, time_t end_time)
{
FILE *fp;
- size_t buflen, linelen;
+ int linelen;
+ size_t buflen;
char *buf, merged;
char *p, *q;
bool showit;
@@ -246,16 +247,17 @@ show_emerge_history(int listflag, array_t *atoms, const char *logfile,
}
buf = NULL;
- while ((linelen = getline(&buf, &buflen, fp)) != -1) {
+ while ((linelen = getline(&buf, &buflen, fp)) >= 0) {
if (linelen < 30)
continue;
- rmspace_len(buf, linelen);
+ rmspace_len(buf, (size_t)linelen);
if ((p = strchr(buf, ':')) == NULL)
continue;
*p = 0;
q = p + 3;
- /* Make sure there's leading white space and not a truncated string. #573106 */
+ /* Make sure there's leading white space and not a truncated
+ * string. #573106 */
if (p[1] != ' ' || p[2] != ' ')
continue;
@@ -331,7 +333,8 @@ static void
show_sync_history(const char *logfile, time_t start_time, time_t end_time)
{
FILE *fp;
- size_t buflen, linelen;
+ int linelen;
+ size_t buflen;
char *buf, *p;
time_t t;
@@ -342,7 +345,7 @@ show_sync_history(const char *logfile, time_t start_time, time_t end_time)
buf = NULL;
/* Just find the finish lines. */
- while ((linelen = getline(&buf, &buflen, fp)) != -1) {
+ while ((linelen = getline(&buf, &buflen, fp)) >= 0) {
/* This cuts out like ~10% of the log. */
if (linelen < 35)
continue;
@@ -356,7 +359,7 @@ show_sync_history(const char *logfile, time_t start_time, time_t end_time)
continue;
p += 19;
- rmspace_len(buf, linelen);
+ rmspace_len(buf, (size_t)linelen);
t = (time_t)atol(buf);
if (t < start_time || t > end_time)