[parted-devel] mklabel & mkfs warning

Debarshi 'Rishi' Ray debarshi.ray at gmail.com
Wed Nov 29 22:06:42 CET 2006


> Indeed. Please provide the patch and then we see what we do ;-)

Please find it attached.

Happy hacking,
Debarshi
-- 
I only work when I am not doing any assignments.
-------------- next part --------------
From 25ee4f8f41ffd5a50e26eb09e47e8778d96af857 Mon Sep 17 00:00:00 2001
From: Debarshi Ray <rishi at gnu.org>
Date: Thu, 30 Nov 2006 08:09:08 +0530
Subject: Cleanup _partition_warn_busy, _disk_warn_busy, _partition_warn_loss and _disk_warn_loss.

---
 parted/parted.c |   30 +++++++++++-------------------
 1 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/parted/parted.c b/parted/parted.c
index a810f20..e3ccfb6 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -164,67 +164,59 @@ _timer_handler (PedTimer* timer, void* c
 static int
 _partition_warn_busy (PedPartition* part)
 {
-        char* path = ped_partition_get_path (part);
+        char* path;
 
         if (ped_partition_is_busy (part)) {
+                path = ped_partition_get_path (part);
                 ped_exception_throw (
                         PED_EXCEPTION_ERROR,
                         PED_EXCEPTION_CANCEL,
-                        _("Partition %s is being used.  You must unmount it "
+                        _("Partition %s is being used. You must unmount it "
                           "before you modify it with Parted."),
                         path);
                 ped_free (path);
                 return 0;
         }
-        ped_free (path);
         return 1;
 }
 
 static int
 _disk_warn_busy (PedDisk* disk)
 {
-        if (ped_device_is_busy (disk->dev)) {
-                if (ped_exception_throw (
+        if (ped_device_is_busy (disk->dev))
+                return ped_exception_throw (
                         PED_EXCEPTION_WARNING,
                         PED_EXCEPTION_IGNORE_CANCEL,
                         _("Partition(s) on %s are being used."),
                         disk->dev->path)
-                                != PED_EXCEPTION_IGNORE)
-                        return 0;
-        }
+                                == PED_EXCEPTION_IGNORE;
+
         return 1;
 }
 
 static int
 _partition_warn_loss ()
 {
-        if (ped_exception_throw (
+        return ped_exception_throw (
                 PED_EXCEPTION_WARNING,
                 PED_EXCEPTION_YES_NO,
                 _("The existing file system will be destroyed and "
                   "all data on the partition will be lost. Do "
                   "you want to continue?"), 
-                NULL)
-                       != PED_EXCEPTION_YES)
-                return 0;
-
-        return 1;
+                NULL) == PED_EXCEPTION_YES;
 }
 
 static int
 _disk_warn_loss (PedDisk* disk)
 {
-        if (ped_exception_throw (
+        return ped_exception_throw (
                 PED_EXCEPTION_WARNING,
                 PED_EXCEPTION_YES_NO,
                 _("The existing disk label on %s will be destroyed "
                   "and all data on this disk will be lost. Do you "
                   "want to continue?"), 
                 disk->dev->path)
-                        != PED_EXCEPTION_YES)
-                return 0;
-
-        return 1;
+                        == PED_EXCEPTION_YES;
 }
 
 /* This function changes "sector" to "new_sector" if the new value lies
-- 
1.4.2.4


More information about the parted-devel mailing list