[Libguestfs] [PATCH 1/2] Fix bogus partition number passed to guestfs___check_for_filesystem_on

Richard W.M. Jones rjones at redhat.com
Fri Feb 8 09:55:14 UTC 2013


On Fri, Feb 08, 2013 at 09:51:59AM +0000, Matthew Booth wrote:
> On Fri, 2013-02-08 at 09:44 +0000, Richard W.M. Jones wrote:
> > This patch moves a lot of variable declarations inline.  I've
> > been steadily moving them to the top of function definitions ...
> 
> Then I've been steadily moving them back again :) You need a policy on
> this. In general, though, it is best practise to minimise the scope of a
> variable. This includes declaring it close to use.

I'd love it if C was like OCaml and let you declare or redeclare
variables anywhere in a function, and even better if it had full type
inference so you don't have to keep declaring the types.  But it
doesn't, and that sucks.

So the policy is (declared now!) variables at the top.

It will also make this patch easier to read.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org




More information about the Libguestfs mailing list