libkvm: Suppress last -Wsign-compare warnings.
authorzrj <rimvydas.jasinskas@gmail.com>
Sat, 6 Apr 2019 18:26:48 +0000 (21:26 +0300)
committerzrj <zrj@dragonflybsd.org>
Sun, 7 Apr 2019 19:19:44 +0000 (22:19 +0300)
lib/libkvm/kvm.c
lib/libkvm/kvm_file.c
lib/libkvm/kvm_getloadavg.c
lib/libkvm/kvm_getswapinfo.c
lib/libkvm/kvm_minidump_x86_64.c

index 67bc8f6..ab2d9c2 100644 (file)
@@ -388,7 +388,7 @@ kvm_read(kvm_t *kd, u_long kva, void *buf, size_t len)
                if (cc < 0) {
                        _kvm_syserr(kd, 0, "kvm_read");
                        return (-1);
-               } else if (cc < len)
+               } else if (cc < (ssize_t)len)
                        _kvm_err(kd, kd->program, "short read");
                return (cc);
        } else {
@@ -399,7 +399,7 @@ kvm_read(kvm_t *kd, u_long kva, void *buf, size_t len)
                        cc = _kvm_kvatop(kd, kva, &pa);
                        if (cc == 0)
                                return (-1);
-                       if (cc > len)
+                       if (cc > (ssize_t)len)
                                cc = len;
                        errno = 0;
                        if (lseek(kd->pmfd, pa, 0) == -1 && errno != 0) {
@@ -465,7 +465,7 @@ kvm_readstr(kvm_t *kd, u_long kva, char *buf, size_t *lenp)
                                return NULL;
                        } else if (cc < 1)
                                _kvm_err(kd, kd->program, "short read");
-                       if (pos == asize) {
+                       if ((ssize_t)pos == asize) {
                                buf = realloc(buf, asize *= 2);
                                if (buf == NULL) {
                                        _kvm_syserr(kd, kd->program, "kvm_readstr");
@@ -504,7 +504,7 @@ kvm_readstr(kvm_t *kd, u_long kva, char *buf, size_t *lenp)
                                return NULL;
                        } else if (cc < 1)
                                _kvm_err(kd, kd->program, "short read");
-                       if (pos == asize) {
+                       if ((ssize_t)pos == asize) {
                                buf = realloc(buf, asize *= 2);
                                if (buf == NULL) {
                                        _kvm_syserr(kd, kd->program, "kvm_readstr");
@@ -544,7 +544,7 @@ kvm_write(kvm_t *kd, u_long kva, const void *buf, size_t len)
                if (cc < 0) {
                        _kvm_syserr(kd, 0, "kvm_write");
                        return (-1);
-               } else if (cc < len)
+               } else if (cc < (ssize_t)len)
                        _kvm_err(kd, kd->program, "short write");
                return (cc);
        } else {
index ec85524..7e4f4dc 100644 (file)
@@ -92,6 +92,7 @@ kvm_deadfiles(kvm_t *kd, struct kinfo_proc *kproc, int kproc_cnt, int nfiles)
 {
        struct kinfo_file *kinfo_file = (struct kinfo_file *)kd->argspc;
        struct fdnode *fd_files;
+       size_t size;
        int i, fd_nfiles, found = 0;
 
        fd_nfiles = NDFILE;
@@ -154,8 +155,6 @@ kvm_deadfiles(kvm_t *kd, struct kinfo_proc *kproc, int kproc_cnt, int nfiles)
                        found++;
 
                        if (found == nfiles) {
-                               size_t size;
-
                                nfiles *= 2;
                                size = nfiles * sizeof(struct kinfo_file);
 
@@ -194,7 +193,7 @@ kvm_getfiles(kvm_t *kd, int op __unused, int arg __unused, int *cnt)
                }
                if (kd->argspc == NULL)
                        kd->argspc = _kvm_malloc(kd, size);
-               else if (kd->arglen < size)
+               else if (kd->arglen < (ssize_t)size)
                        kd->argspc = _kvm_realloc(kd, kd->argspc, size);
                if (kd->argspc == NULL)
                        return NULL;
@@ -250,7 +249,7 @@ kvm_getfiles(kvm_t *kd, int op __unused, int arg __unused, int *cnt)
                size = nfiles * sizeof(struct kinfo_file);
                if (kd->argspc == NULL)
                        kd->argspc = _kvm_malloc(kd, size);
-               else if (kd->arglen < size)
+               else if (kd->arglen < (ssize_t)size)
                        kd->argspc = _kvm_realloc(kd, kd->argspc, size);
                if (kd->argspc == NULL) {
                        free(kproc);
index cd48b6f..2ab874d 100644 (file)
@@ -89,7 +89,7 @@ kvm_getloadavg(kvm_t *kd, double loadavg[], int nelem)
        if (!KREAD(kd, nl[X_FSCALE].n_value, &fscale))
                loadinfo.fscale = fscale;
 
-       nelem = MIN(nelem, sizeof(loadinfo.ldavg) / sizeof(fixpt_t));
+       nelem = MIN((size_t)nelem, sizeof(loadinfo.ldavg) / sizeof(fixpt_t));
        for (i = 0; i < nelem; i++)
                loadavg[i] = (double) loadinfo.ldavg[i] / loadinfo.fscale;
        return (nelem);
index 4437298..1637a24 100644 (file)
@@ -256,7 +256,8 @@ scanradix(
        blmeta_t meta;
        blmeta_t scan_array[BLIST_BMAP_RADIX];
        int64_t avail_tmp = 0;
-       int i, im;
+       unsigned int iu;
+       int im;
        int next_skip;
 
        if (scan_cache) {
@@ -296,8 +297,8 @@ scanradix(
                );
 
                if (meta.u.bmu_bitmap) {
-                       for (i = 0; i < BLIST_BMAP_RADIX; ++i) {
-                               if (meta.u.bmu_bitmap & (1 << i))
+                       for (iu = 0; iu < BLIST_BMAP_RADIX; ++iu) {
+                               if (meta.u.bmu_bitmap & (1 << iu))
                                        ++*availp;
                        }
                }
index 9b2c0ed..753d9ea 100644 (file)
@@ -249,7 +249,7 @@ _kvm_minidump_init_hdr2(kvm_t *kd, struct vmstate *vmst,
                return (-1);
        }
        if (pread(kd->pmfd, vmst->bitmap, hdr->bitmapsize, off) !=
-           hdr->bitmapsize) {
+           (intmax_t)hdr->bitmapsize) {
                _kvm_err(kd, kd->program,
                         "cannot read %jd bytes for page bitmap",
                         (intmax_t)hdr->bitmapsize);
@@ -265,7 +265,7 @@ _kvm_minidump_init_hdr2(kvm_t *kd, struct vmstate *vmst,
                return (-1);
        }
        if (pread(kd->pmfd, vmst->ptemap, hdr->ptesize, off) !=
-           hdr->ptesize) {
+           (intmax_t)hdr->ptesize) {
                _kvm_err(kd, kd->program,
                         "cannot read %jd bytes for ptemap",
                         (intmax_t)hdr->ptesize);