Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage-utils:master commit in: libq/
Date: Fri, 23 Mar 2018 11:30:00
Message-Id: 1521804511.5d86f949a513fb19cf3bc68c78bd3848edac0529.grobian@gentoo
1 commit: 5d86f949a513fb19cf3bc68c78bd3848edac0529
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Fri Mar 23 11:28:31 2018 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Fri Mar 23 11:28:31 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=5d86f949
7
8 color_remap: fix comparison of integers of different signs
9
10 Just use an int to store getline return, then ensure it is positive,
11 such that a cast to size_t is guaranteed to result in the same value.
12
13 libq/colors.c | 7 ++++---
14 1 file changed, 4 insertions(+), 3 deletions(-)
15
16 diff --git a/libq/colors.c b/libq/colors.c
17 index f90be0d..33f6d89 100644
18 --- a/libq/colors.c
19 +++ b/libq/colors.c
20 @@ -50,7 +50,8 @@ color_remap(void)
21 {
22 FILE *fp;
23 unsigned int i;
24 - size_t buflen, linelen;
25 + int linelen;
26 + size_t buflen;
27 char *buf;
28 char *p;
29 unsigned int lineno = 0;
30 @@ -59,13 +60,13 @@ color_remap(void)
31 return;
32
33 buf = NULL;
34 - while ((linelen = getline(&buf, &buflen, fp)) != -1) {
35 + while ((linelen = getline(&buf, &buflen, fp)) >= 0) {
36 lineno++;
37 /* eat comments */
38 if ((p = strchr(buf, '#')) != NULL)
39 *p = '\0';
40
41 - rmspace_len(buf, linelen);
42 + rmspace_len(buf, (size_t)linelen);
43
44 p = strchr(buf, '=');
45 if (p == NULL)