Blame SOURCES/0099-sfdisk-remove-useless-CDROM-detection-for-s.patch

05ad79
From 8229770ff79a383d7e5b133f94609e861aae4283 Mon Sep 17 00:00:00 2001
05ad79
From: Karel Zak <kzak@redhat.com>
05ad79
Date: Fri, 17 Mar 2017 15:03:28 +0100
05ad79
Subject: [PATCH 099/116] sfdisk: remove useless CDROM detection for -s
05ad79
05ad79
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1402825
05ad79
Signed-off-by: Karel Zak <kzak@redhat.com>
05ad79
---
05ad79
 fdisks/sfdisk.c | 16 ++++++----------
05ad79
 1 file changed, 6 insertions(+), 10 deletions(-)
05ad79
05ad79
diff --git a/fdisks/sfdisk.c b/fdisks/sfdisk.c
05ad79
index 93bca27..afb15fc 100644
05ad79
--- a/fdisks/sfdisk.c
05ad79
+++ b/fdisks/sfdisk.c
05ad79
@@ -2905,36 +2905,32 @@ do_pt_geom(char *dev, int silent) {
05ad79
 /* for compatibility with earlier fdisk: provide option -s */
05ad79
 static void
05ad79
 do_size(char *dev, int silent) {
05ad79
-    int fd;
05ad79
+    int fd, rc;
05ad79
     unsigned long long size;
05ad79
 
05ad79
     fd = my_open(dev, 0, silent);
05ad79
     if (fd < 0)
05ad79
 	return;
05ad79
 
05ad79
-    if (blkdev_get_sectors(fd, &size) == -1) {
05ad79
+    rc = blkdev_get_sectors(fd, &size);
05ad79
+    close(fd);
05ad79
+
05ad79
+    if (rc == -1) {
05ad79
 	if (!silent) {
05ad79
 	    perror(dev);
05ad79
 	    errx(EXIT_FAILURE, _("Cannot get size of %s"), dev);
05ad79
 	}
05ad79
-	goto done;
05ad79
+	return;
05ad79
     }
05ad79
 
05ad79
     size /= 2;			/* convert sectors to blocks */
05ad79
 
05ad79
-    /* a CDROM drive without mounted CD yields MAXINT */
05ad79
-    if (silent && size == ((1 << 30) - 1))
05ad79
-	goto done;
05ad79
-
05ad79
     if (silent)
05ad79
 	printf("%s: %9llu\n", dev, size);
05ad79
     else
05ad79
 	printf("%llu\n", size);
05ad79
 
05ad79
     total_size += size;
05ad79
-
05ad79
-done:
05ad79
-    close(fd);
05ad79
 }
05ad79
 
05ad79
 /*
05ad79
-- 
05ad79
2.9.3
05ad79