]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
mkswap: remove unused variable for non-nocow systems
authorKarel Zak <kzak@redhat.com>
Mon, 3 Feb 2025 11:11:24 +0000 (12:11 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 3 Feb 2025 11:11:24 +0000 (12:11 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/mkswap.c

index d73c3f0aa55e6cdd743ae19dc687a12e8ba5764c..609ecadd08634b8bffb8c634b439726f6097bad3 100644 (file)
@@ -417,11 +417,11 @@ static void open_device(struct mkswap_control *ctl)
                err(EXIT_FAILURE, _("cannot open %s"), ctl->devname);
 
        if (ctl->file && ctl->filesz) {
-               int attr = 0;
-
+#ifdef USE_NOCOW
                /* Let's attempt to set the "nocow" attribute for Btrfs, etc.
                 * Ignore if unsupported. */
-#ifdef USE_NOCOW
+               int attr = 0;
+
                if (ioctl(ctl->fd, FS_IOC_GETFLAGS, &attr) == 0) {
                        attr |= FS_NOCOW_FL;
                        if (ioctl(ctl->fd, FS_IOC_SETFLAGS, &attr) < 0 &&
@@ -429,7 +429,6 @@ static void open_device(struct mkswap_control *ctl)
                                warn(_("failed to set 'nocow' attribute"));
                }
 #endif
-
                if (ftruncate(ctl->fd, ctl->filesz) < 0)
                        err(EXIT_FAILURE, _("couldn't allocate swap file %s"), ctl->devname);
 #ifdef HAVE_POSIX_FALLOCATE