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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

This case being "the isolated event-test.c example" or "the
ARRAY_CARDINALITY macro in event-test.c"?

If it's the latter, I can add an exception to syntax-check instead.

Note that I also added a G_GNUC_UNUSED macro earlier, if the G_ prefix
is the issue. (The ATTRIBUTE_UNUSED spelling is used by multiple libs,
including libxml2)

Also, we open-code the 'verify' macro from gnulib.


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.


Alternatively, would a comment along the lines of:
/* define these macros to avoid pulling in glib */
make it less misleading?

The reason we included these macros here in the first place is that
we wanted to keep the code in sync with the rest of libvirt.

Jano


--
Andrea Bolognani / Red Hat / Virtualization

Attachment: signature.asc
Description: PGP signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux