mirror of
https://github.com/libvirt/libvirt.git
synced 2026-08-13 14:44:42 -05:00
Use G_N_ELEMENTS() more
In a few places we still use the good old: sizeof(var) / sizeof(var[0]) sizeof(var) / sizeof(int) The G_N_ELEMENTS() macro is preferred though. In a few places we don't link with glib, so provide the macro definition. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
This commit is contained in:
@@ -53,6 +53,7 @@
|
||||
|
||||
#define LIBVIRT_ALIGN(x) (((x) + __SIZEOF_POINTER__ - 1) & ~(__SIZEOF_POINTER__ - 1))
|
||||
#define FAMILY_ADDRESS_SIZE(family) ((family) == AF_INET6 ? 16 : 4)
|
||||
#define G_N_ELEMENTS(Array) (sizeof(Array) / sizeof(*(Array)))
|
||||
|
||||
static int
|
||||
leaseAddressSorter(const void *a,
|
||||
@@ -595,7 +596,7 @@ nss_module_register(const char *name __attribute__((unused)),
|
||||
unsigned int *size,
|
||||
nss_module_unregister_fn *unregister)
|
||||
{
|
||||
*size = sizeof(methods) / sizeof(methods[0]);
|
||||
*size = G_N_ELEMENTS(methods);
|
||||
*unregister = NULL;
|
||||
return methods;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user