On Fri, Sep 19, 2014 at 03:39:09PM +0800, Hu Tao wrote:
And introduce parameter create_surplus to indicate whether to
create surplus partition or not. Later this parameter will be
used by logical partitions.
Signed-off-by: Hu Tao <hutao(a)cn.fujitsu.com>
---
resize/resize.ml | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/resize/resize.ml b/resize/resize.ml
index 37e4087..2ffd26e 100644
--- a/resize/resize.ml
+++ b/resize/resize.ml
@@ -1025,11 +1025,10 @@ read the man page virt-resize(1).
* the final list just contains partitions that need to be created
* on the target.
*)
- let partitions =
- let rec loop partnum start = function
+ let rec loop partnum start create_surplus = function
A couple of style comments on this one.
First of all, you can't really call this function 'loop', except in
the case where it's immediately used. This function needs to be given
a real name.
Secondly it's better to use a labelled parameter for create_surplus,
so that it's obvious at the calling site what that parameter
(true/false) means.
- let partitions =
- let rec loop partnum start = function
+ let rec calculate_target_partitions partnum start ~create_surplus = function
and later when it is called:
- | OpDelete -> loop partnum start ps (* skip p *)
+ | OpDelete -> create_target_partitions partnum start ~create_surplus ps (* skip p
*)
[...]
- loop 1 start partitions in
+ create_target_partitions 1 start ~create_surplus:true partitions in
Hope that's clear.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages.
http://libguestfs.org