commit: 5d86f949a513fb19cf3bc68c78bd3848edac0529
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 23 11:28:31 2018 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Mar 23 11:28:31 2018 +0000
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=5d86f949
color_remap: 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.
libq/colors.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/libq/colors.c b/libq/colors.c
index f90be0d..33f6d89 100644
--- a/libq/colors.c
+++ b/libq/colors.c
@@ -50,7 +50,8 @@ color_remap(void)
{
FILE *fp;
unsigned int i;
- size_t buflen, linelen;
+ int linelen;
+ size_t buflen;
char *buf;
char *p;
unsigned int lineno = 0;
@@ -59,13 +60,13 @@ color_remap(void)
return;
buf = NULL;
- while ((linelen = getline(&buf, &buflen, fp)) != -1) {
+ while ((linelen = getline(&buf, &buflen, fp)) >= 0) {
lineno++;
/* eat comments */
if ((p = strchr(buf, '#')) != NULL)
*p = '\0';
- rmspace_len(buf, linelen);
+ rmspace_len(buf, (size_t)linelen);
p = strchr(buf, '=');
if (p == NULL)