From: Karel Zak Date: Mon, 3 Feb 2025 11:11:24 +0000 (+0100) Subject: mkswap: remove unused variable for non-nocow systems X-Git-Tag: v2.42-start~65^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2624b0c191027020f52ac000d9e5da1c00a0190f;p=thirdparty%2Futil-linux.git mkswap: remove unused variable for non-nocow systems Signed-off-by: Karel Zak --- diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c index d73c3f0aa..609ecadd0 100644 --- a/disk-utils/mkswap.c +++ b/disk-utils/mkswap.c @@ -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