aboutsummaryrefslogtreecommitdiffstats
path: root/disk-utils/sfdisk.c
diff options
context:
space:
mode:
authorWolfram Sang <wsa@kernel.org>2020-05-06 12:39:21 +0200
committerKarel Zak <kzak@redhat.com>2020-05-11 11:28:49 +0200
commit4a52959d18ecd57a90680961fc1e3c57c34bf145 (patch)
tree99a1b84c8b725c863c5747204c72f4c2c15e2e79 /disk-utils/sfdisk.c
parentb3a3b7eb1a15c5633ae890bec00fe5691b784d99 (diff)
downloadutil-linux-4a52959d18ecd57a90680961fc1e3c57c34bf145.tar.gz
(s)fdisk: avoid unneeded empty lines with '--list'
On my system, I got two superfluous empty lines because /dev/sr0 didn't contain a medium. Refactor the code to handle the seperator within print_device_pt() and print it only when assigning the device worked. This unifies handling between print_all_devices_pt and (s)fdisk because the latter did not consider the return code for the seperator while the former did. Also, it saves some lines of code. Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=814184 (first part) Signed-off-by: Wolfram Sang <wsa@kernel.org>
Diffstat (limited to 'disk-utils/sfdisk.c')
-rw-r--r--disk-utils/sfdisk.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c
index 07e8b2341a..6299cb49c7 100644
--- a/disk-utils/sfdisk.c
+++ b/disk-utils/sfdisk.c
@@ -653,15 +653,11 @@ static int command_list_partitions(struct sfdisk *sf, int argc, char **argv)
fdisk_enable_listonly(sf->cxt, 1);
if (argc) {
- int i, ct = 0;
+ int i;
- for (i = 0; i < argc; i++) {
- if (ct)
- fputs("\n\n", stdout);
- if (print_device_pt(sf->cxt, argv[i], 1, sf->verify) != 0)
+ for (i = 0; i < argc; i++)
+ if (print_device_pt(sf->cxt, argv[i], 1, sf->verify, i) != 0)
fail++;
- ct++;
- }
} else
print_all_devices_pt(sf->cxt, sf->verify);