]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: fix fdisk_check_collisions return code
authorKarel Zak <kzak@redhat.com>
Thu, 11 May 2023 08:37:54 +0000 (10:37 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 11 May 2023 08:37:54 +0000 (10:37 +0200)
The return code (>0) is nowhere in the library used, but let's be
compatible with function comment ;-)

Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/context.c
libfdisk/src/wipe.c

index 083b255d3b01c26f1fae47c2b5f33fbf9c2bb1c1..0d221242e506271184a1a147bde4ecd0500683e1 100644 (file)
@@ -631,6 +631,7 @@ static int fdisk_assign_fd(struct fdisk_context *cxt, int fd,
        /* Don't report collision if there is already a valid partition table.
         * The bootbits are wiped when we create a *new* partition table only. */
        if (fdisk_is_ptcollision(cxt) && fdisk_has_label(cxt)) {
+               DBG(CXT, ul_debugobj(cxt, "ignore old %s", cxt->collision));
                cxt->pt_collision = 0;
                free(cxt->collision);
                cxt->collision = NULL;
index c3d5d754b208d5c404939e154eb5b62f5b35c086..54f42139599369a326e80a996f3d2bacce866f5f 100644 (file)
@@ -171,7 +171,7 @@ int fdisk_check_collisions(struct fdisk_context *cxt)
        assert(cxt);
        assert(cxt->dev_fd >= 0);
 
-       DBG(CXT, ul_debugobj(cxt, "wipe check: initialize libblkid prober"));
+       DBG(WIPE, ul_debugobj(cxt, "wipe check: initialize libblkid prober"));
 
        pr = blkid_new_probe();
        if (!pr)
@@ -208,6 +208,6 @@ int fdisk_check_collisions(struct fdisk_context *cxt)
        }
 
        blkid_free_probe(pr);
-       return rc;
+       return rc < 0 ? rc : cxt->collision ? 1 : 0;
 }
 #endif