On Fri, 9 May 2014 21:03:23 +0200 Stefan Hajnoczi <[email protected]> wrote:
> From: Mike Day <[email protected]> > > The help message for qemu-img lists the supported block formats, of > which there are 27 as of version 2.0.50. The formats are printed in > the order of their driver's position in a linked list, which appears > random. This patch prints the formats in sorted order, making it > easier to read and to find a specific format in the list. > > [Added suggestions from Fam Zheng <[email protected]> to declare variables > at the top of the scope in help() and to omit explicit cast for void* > opaque. > --Stefan] > > Signed-off-by: Mike Day <[email protected]> > Signed-off-by: Stefan Hajnoczi <[email protected]> > --- > qemu-img.c | 28 +++++++++++++++++++++++++--- > 1 file changed, 25 insertions(+), 3 deletions(-) > > diff --git a/qemu-img.c b/qemu-img.c > index 96f4463..317bc6c 100644 > --- a/qemu-img.c > +++ b/qemu-img.c > +static void add_format_to_seq(void *opaque, const char *fmt_name) > +{ > + GSequence *seq = opaque; > + > + if (!g_sequence_lookup(seq, (gpointer)fmt_name, > + compare_data, NULL)) { > + g_sequence_insert_sorted(seq, (gpointer)fmt_name, > + compare_data, NULL); > + } > } Now that this has hit master, I noticed that this breaks the build on my build server: /home/cohuck/git/qemu/qemu-img.c: In function ‘add_format_to_seq’: /home/cohuck/git/qemu/qemu-img.c:73: warning: implicit declaration of function ‘g_sequence_lookup’ /home/cohuck/git/qemu/qemu-img.c:73: warning: nested extern declaration of ‘g_sequence_lookup’ qemu-img.o: In function `add_format_to_seq': /home/cohuck/git/qemu/qemu-img.c:73: undefined reference to `g_sequence_lookup' collect2: ld returned 1 exit status g_sequence_lookup has been added with glib 2.28, and this box has 2.22.5. configure looks for glib >= 2.12 (2.20 for mingw).
