]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
swapon: fix compiler warnings [-Wsign-compare]
authorKarel Zak <kzak@redhat.com>
Mon, 1 Aug 2011 11:40:41 +0000 (13:40 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 1 Aug 2011 11:40:41 +0000 (13:40 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
mount/swapon.c

index 8dd9222486128810670902c1cbe054d82895180e..2956a8e8300bf4ad488e952d7e7701f69e8b2f4a 100644 (file)
@@ -355,7 +355,7 @@ swap_get_header(int fd, int *sig, unsigned int *pagesize)
                        continue;
                /* the smallest swap area is PAGE_SIZE*10, it means
                 * 40k, that's less than MAX_PAGESIZE */
-               if (datasz < (page - SWAP_SIGNATURE_SZ))
+               if (datasz < 0 || (size_t) datasz < (page - SWAP_SIGNATURE_SZ))
                        break;
                if (swap_detect_signature(buf + page - SWAP_SIGNATURE_SZ, sig)) {
                        *pagesize = page;
@@ -458,6 +458,8 @@ swapon_checks(const char *special)
        if (sig == SIG_SWAPSPACE && pagesize) {
                unsigned long long swapsize =
                                swap_get_size(hdr, special, pagesize);
+               int syspg = getpagesize();
+
                if (verbose)
                        warnx(_("%s: pagesize=%d, swapsize=%llu, devsize=%llu"),
                                special, pagesize, swapsize, devsize);
@@ -467,7 +469,7 @@ swapon_checks(const char *special)
                                warnx(_("%s: last_page 0x%08llx is larger"
                                        " than actual size of swapspace"),
                                        special, swapsize);
-               } else if (getpagesize() != pagesize) {
+               } else if (syspg < 0 || (unsigned) syspg != pagesize) {
                        if (fixpgsz) {
                                warnx(_("%s: swap format pagesize does not match."),
                                        special);