[libvirt] [PATCH 7/8] examples: Use G_N_ELEMENTS instead of ARRAY_CARDINALITY

Daniel P. Berrangé berrange at redhat.com
Tue Oct 15 17:21:53 UTC 2019


On Tue, Oct 15, 2019 at 04:10:55PM +0200, Andrea Bolognani wrote:
> On Tue, 2019-10-15 at 14:21 +0200, Ján Tomko wrote:
> > We try to keep the example programs independent of libraries
> > other than libvirt.
> > 
> > Rename the locally defined ARRAY_CARDINALITY macro to G_N_ELEMENTS
> > which GLib provides, even though we don't actually include GLib.
> 
> [...]
> 
> > -#define ARRAY_CARDINALITY(Array) (sizeof(Array) / sizeof(*(Array)))
> > +#define G_N_ELEMENTS(Array) (sizeof(Array) / sizeof(*(Array)))
> 
> In this case, and in this case only, I think we should leave the name
> alone.
> 
> When we use GLib and simply provide our own implementation when using
> a version that's too old, the GLib name is obviously accurate, but in
> this specific case I think it's misleading and we should stick with
> the current one.

We do have the option to have our example programs use GLib instead
of plain C. If people are using libvirt from plain C, I'm inclined
to suggest they'd be wise to use GLib for the same reasons that it
is beneficial for libvirt to use GLib.

If they're not using GLib, they likely have enough C knowledge to
figure out what they must do from our examples anyway.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the libvir-list mailing list