diff options
author | Markus Rinne | 2010-09-22 21:11:54 +0200 |
---|---|---|
committer | Karel Zak | 2010-09-30 22:52:42 +0200 |
commit | 263644840f3376c7d44d7f2bdf0daee902908165 (patch) | |
tree | ed4e01c2979c46db188dc118a7d93004da690adb | |
parent | mount: Don't call canonicalize_*(SPEC) for 9p (diff) | |
download | kernel-qcow2-util-linux-263644840f3376c7d44d7f2bdf0daee902908165.tar.gz kernel-qcow2-util-linux-263644840f3376c7d44d7f2bdf0daee902908165.tar.xz kernel-qcow2-util-linux-263644840f3376c7d44d7f2bdf0daee902908165.zip |
fdisk: eliminate redundant call to open()
Don't use open() in get_boot() if it's called with an argument try_only,
because the file has already been opened by the caller.
Signed-off-by: Markus Rinne <markus.ka.rinne@gmail.com>
-rw-r--r-- | fdisk/fdisk.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c index 68293213c..1f841d17d 100644 --- a/fdisk/fdisk.c +++ b/fdisk/fdisk.c @@ -1213,14 +1213,14 @@ get_boot(enum action what) { if (what == create_empty_dos) goto got_dos_table; /* skip reading disk */ - if ((fd = open(disk_device, type_open)) < 0) { - if ((fd = open(disk_device, O_RDONLY)) < 0) { - if (what == try_only) - return 1; - fatal(unable_to_open); - } else - printf(_("You will not be able to write " - "the partition table.\n")); + if (what != try_only) { + if ((fd = open(disk_device, type_open)) < 0) { + if ((fd = open(disk_device, O_RDONLY)) < 0) + fatal(unable_to_open); + else + printf(_("You will not be able to write " + "the partition table.\n")); + } } if (512 != read(fd, MBRbuffer, 512)) { |