commit:     bf111d7d5464f8a6b3a251d3d12fe9e39357bc6e
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 23 13:16:31 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Mar 23 13:16:31 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=bf111d7d

fix signedness warnings

 main.c     | 8 +++++---
 qcheck.c   | 2 +-
 qdepends.c | 2 +-
 qgrep.c    | 5 +++--
 qlop.c     | 7 ++++---
 qsearch.c  | 2 +-
 qsize.c    | 2 +-
 qxpak.c    | 8 +++++---
 8 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/main.c b/main.c
index b11fe83..44226db 100644
--- a/main.c
+++ b/main.c
@@ -1420,9 +1420,11 @@ get_vdb_atoms(int fullcpv)
                if ((dfd = scandirat(ctx->vdb_fd, cat[j]->d_name, &pf, 
q_vdb_filter_pkg, alphasort)) < 0)
                        continue;
                for (i = 0; i < dfd; i++) {
-                       int blen = snprintf(buf, sizeof(buf), "%s/%s/SLOT", 
cat[j]->d_name, pf[i]->d_name);
-                       if (blen >= sizeof(buf)) {
-                               warnf("unable to parse long package: %s/%s", 
cat[j]->d_name, pf[i]->d_name);
+                       int blen = snprintf(buf, sizeof(buf), "%s/%s/SLOT",
+                                       cat[j]->d_name, pf[i]->d_name);
+                       if (blen < 0 || (size_t)blen >= sizeof(buf)) {
+                               warnf("unable to parse long package: %s/%s",
+                                               cat[j]->d_name, pf[i]->d_name);
                                continue;
                        }
 

diff --git a/qcheck.c b/qcheck.c
index 26b820e..66589a3 100644
--- a/qcheck.c
+++ b/qcheck.c
@@ -375,7 +375,7 @@ int qcheck_main(int argc, char **argv)
 
        argc -= optind;
        argv += optind;
-       for (i = 0; i < argc; ++i) {
+       for (i = 0; i < (size_t)argc; ++i) {
                atom = atom_explode(argv[i]);
                if (!atom)
                        warn("invalid atom: %s", argv[i]);

diff --git a/qdepends.c b/qdepends.c
index a614704..e8b2190 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -579,7 +579,7 @@ int qdepends_main(int argc, char **argv)
        else {
                cb = qdepends_main_vdb_cb;
 
-               for (i = 0; i < argc; ++i) {
+               for (i = 0; i < (size_t)argc; ++i) {
                        atom = atom_explode(argv[i]);
                        if (!atom)
                                warn("invalid atom: %s", argv[i]);

diff --git a/qgrep.c b/qgrep.c
index 0680035..fe53ea2 100644
--- a/qgrep.c
+++ b/qgrep.c
@@ -153,9 +153,10 @@ qgrep_print_line(qgrep_buf_t *current, const char *label,
                int regexec_flags = 0;
                while ((*p != '\0') && !regexec(preg, p, 1, &match, 
regexec_flags)) {
                        if (match.rm_so > 0)
-                               printf("%.*s", match.rm_so, p);
+                               printf("%.*s", (int)match.rm_so, p);
                        if (match.rm_eo > match.rm_so) {
-                               printf("%s%.*s%s", RED, match.rm_eo - 
match.rm_so, p + match.rm_so, NORM);
+                               printf("%s%.*s%s", RED, (int)(match.rm_eo - 
match.rm_so),
+                                               p + match.rm_so, NORM);
                                p += match.rm_eo;
                        } else {
                                p += match.rm_eo;

diff --git a/qlop.c b/qlop.c
index 5be2ddd..410a94b 100644
--- a/qlop.c
+++ b/qlop.c
@@ -580,7 +580,8 @@ void show_current_emerge(void)
                        raip = realloc(ip, sizeof(struct kinfo_proc) * size);
                        if (raip == NULL) {
                                free(ip);
-                               warnp("Could not extend allocated block to %d 
bytes for process information",
+                               warnp("Could not extend allocated block to "
+                                               "%zd bytes for process 
information",
                                                sizeof(struct kinfo_proc) * 
size);
                                return;
                        }
@@ -798,7 +799,7 @@ int qlop_main(int argc, char **argv)
 
        argc -= optind;
        argv += optind;
-       for (i = 0; i < argc; ++i) {
+       for (i = 0; i < (size_t)argc; ++i) {
                atom = atom_explode(argv[i]);
                if (!atom)
                        warn("invalid atom: %s", argv[i]);
@@ -820,7 +821,7 @@ int qlop_main(int argc, char **argv)
                show_sync_history(logfile, start_time, end_time);
 
        if (do_time) {
-               for (i = 0; i < argc; ++i)
+               for (i = 0; i < (size_t)argc; ++i)
                        show_merge_times(argv[i], logfile, average, 
do_human_readable,
                                start_time, end_time);
        }

diff --git a/qsearch.c b/qsearch.c
index c2b2ebe..a620f95 100644
--- a/qsearch.c
+++ b/qsearch.c
@@ -104,7 +104,7 @@ qsearch_ebuild_ebuild(int overlay_fd, const char *ebuild, 
const char *search_me,
        int linelen;
        size_t buflen;
        while ((linelen = getline(&buf, &buflen, ebuildfp)) >= 0) {
-               if (linelen <= search_len)
+               if ((size_t)linelen <= search_len)
                        continue;
                if (strncmp(buf, search_var, search_len) != 0)
                        continue;

diff --git a/qsize.c b/qsize.c
index b92f533..acf74bf 100644
--- a/qsize.c
+++ b/qsize.c
@@ -176,7 +176,7 @@ int qsize_main(int argc, char **argv)
 
        argc -= optind;
        argv += optind;
-       for (i = 0; i < argc; ++i) {
+       for (i = 0; i < (size_t)argc; ++i) {
                atom = atom_explode(argv[i]);
                if (!atom)
                        warn("invalid atom: %s", argv[i]);

diff --git a/qxpak.c b/qxpak.c
index 95fb779..ada9767 100644
--- a/qxpak.c
+++ b/qxpak.c
@@ -341,9 +341,11 @@ xpak_create(int dir_fd, const char *file, int argc, char 
**argv)
                        if ((numfiles = scandir(argv[i], &dir, filter_hidden, 
alphasort)) < 0)
                                warn("Directory '%s' is empty; skipping", 
argv[i]);
                        for (fidx = 0; fidx < numfiles; ++fidx) {
-                               int ret = snprintf(path, sizeof(path), "%s/%s", 
argv[i], dir[fidx]->d_name);
-                               if (ret >= sizeof(path)) {
-                                       warn("skipping path too long: %s/%s", 
argv[i], dir[fidx]->d_name);
+                               int ret = snprintf(path, sizeof(path), "%s/%s",
+                                               argv[i], dir[fidx]->d_name);
+                               if (ret < 0 || (size_t)ret >= sizeof(path)) {
+                                       warn("skipping path too long: %s/%s",
+                                                       argv[i], 
dir[fidx]->d_name);
                                        continue;
                                }
                                if (stat(path, &st) < 0) {

Reply via email to