[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH] customize, dib, resize, sysprep: Use 'may' pattern in various places.



---
 customize/customize_main.ml  |  5 ++---
 dib/dib.ml                   |  5 ++---
 resize/resize.ml             | 13 ++-----------
 sysprep/sysprep_operation.ml |  5 +----
 4 files changed, 7 insertions(+), 21 deletions(-)

diff --git a/customize/customize_main.ml b/customize/customize_main.ml
index e161e82..13d40bc 100644
--- a/customize/customize_main.ml
+++ b/customize/customize_main.ml
@@ -166,9 +166,8 @@ read the man page virt-customize(1).
   (* Connect to libguestfs. *)
   let g =
     let g = open_guestfs () in
-
-    (match memsize with None -> () | Some memsize -> g#set_memsize memsize);
-    (match smp with None -> () | Some smp -> g#set_smp smp);
+    may g#set_memsize memsize;
+    may g#set_smp smp;
     g#set_network network;
     (* Make sure to turn SELinux off to avoid awkward interactions
      * between the appliance kernel and applications/libraries interacting
diff --git a/dib/dib.ml b/dib/dib.ml
index 1ae8876..fdb5857 100644
--- a/dib/dib.ml
+++ b/dib/dib.ml
@@ -627,9 +627,8 @@ let main () =
 
   let g, tmpdisk, tmpdiskfmt, drive_partition =
     let g = open_guestfs () in
-
-    (match memsize with None -> () | Some memsize -> g#set_memsize memsize);
-    (match smp with None -> () | Some smp -> g#set_smp smp);
+    may g#set_memsize memsize;
+    may g#set_smp smp;
     g#set_network network;
 
     (* Make sure to turn SELinux off to avoid awkward interactions
diff --git a/resize/resize.ml b/resize/resize.ml
index b2802c7..ff10fca 100644
--- a/resize/resize.ml
+++ b/resize/resize.ml
@@ -1210,17 +1210,8 @@ read the man page virt-resize(1).
       if p.p_bootable then
         g#part_set_bootable "/dev/sdb" p.p_target_partnum true;
 
-      (match p.p_label with
-      | Some label ->
-        g#part_set_name "/dev/sdb" p.p_target_partnum label;
-      | None -> ()
-      );
-
-      (match p.p_guid with
-      | Some guid ->
-        g#part_set_gpt_guid "/dev/sdb" p.p_target_partnum guid;
-      | None -> ()
-      );
+      may (g#part_set_name "/dev/sdb" p.p_target_partnum) p.p_label;
+      may (g#part_set_gpt_guid "/dev/sdb" p.p_target_partnum) p.p_guid;
 
       match parttype, p.p_id with
       | GPT, GPT_Type gpt_type ->
diff --git a/sysprep/sysprep_operation.ml b/sysprep/sysprep_operation.ml
index af2004e..057c8c5 100644
--- a/sysprep/sysprep_operation.ml
+++ b/sysprep/sysprep_operation.ml
@@ -186,10 +186,7 @@ let dump_pod () =
       if op.enabled_by_default then printf "*\n";
       printf "\n";
       printf "%s.\n\n" op.heading;
-      (match op.pod_description with
-      | None -> ()
-      | Some description -> printf "%s\n\n" description
-      );
+      may (printf "%s\n\n") op.pod_description;
       (match op.pod_notes with
       | None -> ()
       | Some notes ->
-- 
2.5.0


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]