diff options
-rw-r--r-- | main.c | 8 | ||||
-rw-r--r-- | qcheck.c | 2 | ||||
-rw-r--r-- | qdepends.c | 2 | ||||
-rw-r--r-- | qgrep.c | 5 | ||||
-rw-r--r-- | qlop.c | 7 | ||||
-rw-r--r-- | qsearch.c | 2 | ||||
-rw-r--r-- | qsize.c | 2 | ||||
-rw-r--r-- | qxpak.c | 8 |
8 files changed, 21 insertions, 15 deletions
@@ -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; } @@ -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]); @@ -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]); @@ -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; @@ -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); } @@ -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; @@ -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]); @@ -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) { |