[Pkg-privacy-commits] [libgsecuredelete] 67/168: Rewrite a bit argument building

Ulrike Uhlig u-guest at moszumanska.debian.org
Thu Jul 7 20:06:40 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 fa6612662e6eb07acaa1ed2c7f539fa739d7ded4
Author: Colomban Wendling <ban at herbesfolles.org>
Date:   Wed Apr 27 15:26:55 2011 +0200

    Rewrite a bit argument building
    
    Don't add manually the argument for each parent class but rather simply
    call the parent's build_args() first, letting it do the job.
    This also allowed to make various arguments-related methods private,
    cleaning up API.
---
 gsecuredelete/delete-operation.vala       |  6 ++----
 gsecuredelete/fill-operation.vala         |  7 ++-----
 gsecuredelete/mem-operation.vala          | 12 ------------
 gsecuredelete/securedelete-operation.vala | 20 ++++++++++++++++----
 gsecuredelete/swap-operation.vala         |  5 +----
 gsecuredelete/zeroable-operation.vala     | 14 ++++++++++++--
 6 files changed, 33 insertions(+), 31 deletions(-)

diff --git a/gsecuredelete/delete-operation.vala b/gsecuredelete/delete-operation.vala
index d450379..d3db047 100644
--- a/gsecuredelete/delete-operation.vala
+++ b/gsecuredelete/delete-operation.vala
@@ -144,10 +144,8 @@ namespace Gsd
       List<string> args = null;
       bool         have_files = false;
       
-      args.append ("-rv");
-      this.add_fast_argument (ref args);
-      this.add_mode_argument (ref args);
-      this.add_zeroise_argument (ref args);
+      args = base.build_args ();
+      args.append ("-r");
       this.n_files = 0;
       foreach (unowned string path in this._paths) {
         args.append (path);
diff --git a/gsecuredelete/fill-operation.vala b/gsecuredelete/fill-operation.vala
index 4933aed..cf22a46 100644
--- a/gsecuredelete/fill-operation.vala
+++ b/gsecuredelete/fill-operation.vala
@@ -77,7 +77,7 @@ namespace Gsd
     }
     
     /* adds the argument needed by the current wipe mode to an argument list */
-    protected void add_wipe_mode_argument (ref List<string> args)
+    private void add_wipe_mode_argument (ref List<string> args)
     {
       unowned string? arg_mode = this.get_argument_for_wipe_mode (this.wipe_mode);
       if (arg_mode != null) {
@@ -95,11 +95,8 @@ namespace Gsd
         throw new AsyncOperationError.ARGS_ERROR ("Missing directory to fill");
       }
       
-      args.append ("-v");
-      this.add_fast_argument (ref args);
-      this.add_mode_argument (ref args);
+      args = base.build_args ();
       this.add_wipe_mode_argument (ref args);
-      this.add_zeroise_argument (ref args);
       args.append (this.directory);
       
       return args;
diff --git a/gsecuredelete/mem-operation.vala b/gsecuredelete/mem-operation.vala
index 4d4708a..035eeaa 100644
--- a/gsecuredelete/mem-operation.vala
+++ b/gsecuredelete/mem-operation.vala
@@ -34,17 +34,5 @@ namespace Gsd
     construct {
       this.path = Config.SMEM_PATH;
     }
-    
-    /* builds the argument vector */
-    protected override List<string> build_args ()
-    {
-      List<string> args = null;
-      
-      args.append ("-v");
-      this.add_fast_argument (ref args);
-      this.add_mode_argument (ref args);
-      
-      return args;
-    }
   }
 }
diff --git a/gsecuredelete/securedelete-operation.vala b/gsecuredelete/securedelete-operation.vala
index 68f9608..aac98e9 100644
--- a/gsecuredelete/securedelete-operation.vala
+++ b/gsecuredelete/securedelete-operation.vala
@@ -61,7 +61,7 @@ namespace Gsd
     /* returns the argument to pass to SecureDelete tools depending on the
      * speed mode. %null can be returned, meaning no argument should be
      * added */
-    protected unowned string? get_argument_for_fast (bool fast)
+    private unowned string? get_argument_for_fast (bool fast)
     {
       if (fast) {
         return "-f";
@@ -70,7 +70,7 @@ namespace Gsd
     }
     
     /* adds the argument needed by the current set speed to an argument list */
-    protected void add_fast_argument (ref List<string> args)
+    private void add_fast_argument (ref List<string> args)
     {
       unowned string? arg_fast = this.get_argument_for_fast (this.fast);
       if (arg_fast != null) {
@@ -81,7 +81,7 @@ namespace Gsd
     /* returns the argument to pass to SecureDelete tools depending on the
      * security mode. %null can be returned, meaning no argument should be
      * added */
-    protected unowned string? get_argument_for_mode (Mode mode)
+    private unowned string? get_argument_for_mode (Mode mode)
     {
       switch (mode) {
         case Mode.INSECURE:
@@ -93,7 +93,7 @@ namespace Gsd
     }
     
     /* adds the argument needed by the current set mode to an argument list */
-    protected void add_mode_argument (ref List<string> args)
+    private void add_mode_argument (ref List<string> args)
     {
       unowned string? arg_mode = this.get_argument_for_mode (this.mode);
       if (arg_mode != null) {
@@ -101,6 +101,18 @@ namespace Gsd
       }
     }
     
+    protected override List<string> build_args ()
+      throws AsyncOperationError
+    {
+      List<string> args = null;
+      
+      args.append ("-v");
+      this.add_fast_argument (ref args);
+      this.add_mode_argument (ref args);
+      
+      return args;
+    }
+    
     /* returns the supposed number of pass to show the progress status */
     protected override uint get_max_progress ()
     {
diff --git a/gsecuredelete/swap-operation.vala b/gsecuredelete/swap-operation.vala
index 6fa3d25..63501a0 100644
--- a/gsecuredelete/swap-operation.vala
+++ b/gsecuredelete/swap-operation.vala
@@ -99,10 +99,7 @@ namespace Gsd
                                                       this.device);
       }
       
-      args.append ("-v");
-      this.add_fast_argument (ref args);
-      this.add_mode_argument (ref args);
-      this.add_zeroise_argument (ref args);
+      args = base.build_args ();
       args.append (this.device);
       
       return args;
diff --git a/gsecuredelete/zeroable-operation.vala b/gsecuredelete/zeroable-operation.vala
index f909e99..9174e1d 100644
--- a/gsecuredelete/zeroable-operation.vala
+++ b/gsecuredelete/zeroable-operation.vala
@@ -45,7 +45,7 @@ namespace Gsd
     /* returns the argument to pass to SecureDelete tools depending whether the
      * last wiping pass should be done with zeros. %null wan be returned,
      * meaning no argument should be added */
-    protected unowned string? get_argument_for_zeroise (bool zeroise)
+    private unowned string? get_argument_for_zeroise (bool zeroise)
     {
       if (zeroise) {
         return "-z";
@@ -55,12 +55,22 @@ namespace Gsd
     
     /* adds the argument needed by the currently set zeorise setting to an
      * argument list */
-    protected void add_zeroise_argument (ref List<string> args)
+    private void add_zeroise_argument (ref List<string> args)
     {
       unowned string? arg = this.get_argument_for_zeroise (this.zeroise);
       if (arg != null) {
         args.append (arg);
       }
     }
+    
+    protected override List<string> build_args ()
+      throws AsyncOperationError
+    {
+      var args = base.build_args ();
+      
+      this.add_zeroise_argument (ref args);
+      
+      return args;
+    }
   }
 }

-- 
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