Re: [libvirt] [libvirt-glib] Prefer 'for' over 'while'

2012-01-26 Thread Christophe Fergeau
On Thu, Jan 26, 2012 at 08:18:38AM +0100, Philipp Hahn wrote: Your changed version only has the same behaviour, if the user-passed-in function iter_func() never changes it-next, which you can't guarentee here. You need to keep the next copy. Yes, the for loop was changed to a while loop

Re: [libvirt] [libvirt-glib] Prefer 'for' over 'while'

2012-01-26 Thread Zeeshan Ali (Khattak)
On Thu, Jan 26, 2012 at 11:19 AM, Christophe Fergeau cferg...@redhat.com wrote: On Thu, Jan 26, 2012 at 08:18:38AM +0100, Philipp Hahn wrote: Your changed version only has the same behaviour, if the user-passed-in function iter_func() never changes it-next, which you can't guarentee here. You

Re: [libvirt] [libvirt-glib] Prefer 'for' over 'while'

2012-01-26 Thread Christophe Fergeau
On Thu, Jan 26, 2012 at 05:05:15PM +0200, Zeeshan Ali (Khattak) wrote: On Thu, Jan 26, 2012 at 11:19 AM, Christophe Fergeau cferg...@redhat.com wrote: On Thu, Jan 26, 2012 at 08:18:38AM +0100, Philipp Hahn wrote: Your changed version only has the same behaviour, if the user-passed-in

Re: [libvirt] [libvirt-glib] Prefer 'for' over 'while'

2012-01-26 Thread Zeeshan Ali (Khattak)
On Thu, Jan 26, 2012 at 5:09 PM, Christophe Fergeau cferg...@redhat.com wrote: On Thu, Jan 26, 2012 at 05:05:15PM +0200, Zeeshan Ali (Khattak) wrote: On Thu, Jan 26, 2012 at 11:19 AM, Christophe Fergeau cferg...@redhat.com wrote: On Thu, Jan 26, 2012 at 08:18:38AM +0100, Philipp Hahn wrote:

[libvirt] [libvirt-glib] Prefer 'for' over 'while'

2012-01-25 Thread Zeeshan Ali (Khattak)
From: Zeeshan Ali (Khattak) zeesha...@gnome.org In this particular case 'for' seems like a more natural choice as then we don't need to update the iterator (which we were forgetting to do and causing a hang in Boxes). --- libvirt-gconfig/libvirt-gconfig-helpers.c |5 + 1 files changed, 1

Re: [libvirt] [libvirt-glib] Prefer 'for' over 'while'

2012-01-25 Thread Philipp Hahn
Hello, On Thursday 26 January 2012 06:10:28 Zeeshan Ali (Khattak) wrote: -it = node-children; -while (it != NULL) { +for (it = node-children; it != NULL; it = it-next) { ... -xmlNodePtr next = it-next; ... cont = iter_func(it, opaque); ... -it = next;