From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id E562E1382C5 for ; Fri, 23 Mar 2018 11:30:00 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EC48BE0954; Fri, 23 Mar 2018 11:29:59 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id C8990E0954 for ; Fri, 23 Mar 2018 11:29:59 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 99810335C36 for ; Fri, 23 Mar 2018 11:29:58 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 2664E262 for ; Fri, 23 Mar 2018 11:29:56 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1521804511.5d86f949a513fb19cf3bc68c78bd3848edac0529.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: libq/ X-VCS-Repository: proj/portage-utils X-VCS-Files: libq/colors.c X-VCS-Directories: libq/ X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 5d86f949a513fb19cf3bc68c78bd3848edac0529 X-VCS-Branch: master Date: Fri, 23 Mar 2018 11:29:56 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: e68b2370-29d0-4444-869e-d8690152e276 X-Archives-Hash: 172339aa9685fb69c8aacea6ec50899f commit: 5d86f949a513fb19cf3bc68c78bd3848edac0529 Author: Fabian Groffen gentoo org> AuthorDate: Fri Mar 23 11:28:31 2018 +0000 Commit: Fabian Groffen gentoo 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)