[Pkg-privacy-commits] [libgsecuredelete] 78/168: Don't use exceptions when assertions should be used

Ulrike Uhlig u-guest at moszumanska.debian.org
Thu Jul 7 20:06:41 UTC 2016


This is an automated email from the git hooks/post-receive script.

u-guest pushed a commit to branch master
in repository libgsecuredelete.

commit c091901b8f642f0b365eaddb62427bd0bbbd11e4
Author: Colomban Wendling <ban at herbesfolles.org>
Date:   Sat Apr 30 04:22:19 2011 +0200

    Don't use exceptions when assertions should be used
---
 gsecuredelete/gsd-async-operation.vala  |  7 +------
 gsecuredelete/gsd-delete-operation.vala | 11 +++--------
 gsecuredelete/gsd-fill-operation.vala   |  5 +----
 gsecuredelete/gsd-swap-operation.vala   |  4 +---
 4 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/gsecuredelete/gsd-async-operation.vala b/gsecuredelete/gsd-async-operation.vala
index 1bf2b64..4c4b321 100644
--- a/gsecuredelete/gsd-async-operation.vala
+++ b/gsecuredelete/gsd-async-operation.vala
@@ -31,10 +31,6 @@ namespace Gsd
    */
   public errordomain AsyncOperationError {
     /**
-     * An error occurred during the build of the command's arguments.
-     */
-    ARGS_ERROR,
-    /**
      * The subprocess crashed or terminated with an error.
      */
     CHILD_FAILED,
@@ -403,8 +399,7 @@ namespace Gsd
      * @return true if all worked properly, and false if something failed.
      *         An error is thrown if something fails. It can be the subprocess
      *         spawning (SpawnError) or the child that failed
-     *         (AsyncOperationError.CHILD_FAILED) or the generation of
-     *         arguments that failed (AsyncOperationError.ARGS_ERROR).
+     *         (AsyncOperationError.CHILD_FAILED).
      */
     public bool run_sync (string?    working_directory = null,
                           SpawnFlags spawn_flags = 0,
diff --git a/gsecuredelete/gsd-delete-operation.vala b/gsecuredelete/gsd-delete-operation.vala
index 21c8c68..c0352d4 100644
--- a/gsecuredelete/gsd-delete-operation.vala
+++ b/gsecuredelete/gsd-delete-operation.vala
@@ -138,9 +138,11 @@ namespace Gsd
     /* builds the command's argument vector */
     protected override List<string> build_args ()
       throws AsyncOperationError
+      /* FIXME: use an optimization here like (this._paths != null) not to walk
+       * the entire list? Faster but a bit ugly... */
+      requires (this._paths.length () > 0)
     {
       List<string> args = null;
-      bool         have_files = false;
       
       args = base.build_args ();
       args.append ("-r");
@@ -148,13 +150,6 @@ namespace Gsd
       foreach (unowned string path in this._paths) {
         args.append (path);
         this.n_files += this.count_files (path);
-        have_files = true;
-      }
-      
-      /* we can't use the number of files since it is 0 if there is only
-       * directories */
-      if (! have_files) {
-        throw new AsyncOperationError.ARGS_ERROR ("Nothing to remove");
       }
       
       return args;
diff --git a/gsecuredelete/gsd-fill-operation.vala b/gsecuredelete/gsd-fill-operation.vala
index 2526eaa..21be0cf 100644
--- a/gsecuredelete/gsd-fill-operation.vala
+++ b/gsecuredelete/gsd-fill-operation.vala
@@ -93,13 +93,10 @@ namespace Gsd
     /* builds the argument vector */
     protected override List<string> build_args ()
       throws AsyncOperationError
+      requires (this.directory != null)
     {
       List<string> args = null;
       
-      if (this.directory == null) {
-        throw new AsyncOperationError.ARGS_ERROR ("Missing directory to fill");
-      }
-      
       args = base.build_args ();
       this.add_wipe_mode_argument (ref args);
       args.append (this.directory);
diff --git a/gsecuredelete/gsd-swap-operation.vala b/gsecuredelete/gsd-swap-operation.vala
index ae67672..331ad76 100644
--- a/gsecuredelete/gsd-swap-operation.vala
+++ b/gsecuredelete/gsd-swap-operation.vala
@@ -86,12 +86,10 @@ namespace Gsd
     /* builds the argument vector */
     protected override List<string> build_args ()
       throws AsyncOperationError
+      requires (this.device != null)
     {
       List<string> args = null;
       
-      if (this.device == null) {
-        throw new AsyncOperationError.ARGS_ERROR ("Missing device to wipe");
-      }
       /* not really clean to throw AsyncOperationError.SUBCLASS_ERROR, but
        * there's no clean way to do that.. */
       if (this.check_device && this.swap_is_in_use (this.device)) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/libgsecuredelete.git



More information about the Pkg-privacy-commits mailing list