mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06: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:
@@ -7,6 +7,8 @@
|
||||
#include <libvirt/libvirt.h>
|
||||
#include <libvirt/virterror.h>
|
||||
|
||||
#define G_N_ELEMENTS(Array) (sizeof(Array) / sizeof(*(Array)))
|
||||
|
||||
static void
|
||||
showError(virConnectPtr conn)
|
||||
{
|
||||
@@ -205,7 +207,7 @@ static int credTypes[] = {
|
||||
/* The auth struct that will be passed to virConnectOpenAuth */
|
||||
static virConnectAuth auth = {
|
||||
credTypes,
|
||||
sizeof(credTypes) / sizeof(int),
|
||||
G_N_ELEMENTS(credTypes),
|
||||
authCallback,
|
||||
NULL, /* cbdata will be initialized in main */
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user