[evolution-exchange] Prefer G_N_ELEMENTS over sizeof calculations.



commit e163dc767149f4a2b64227bca82c0603369aab67
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sat Oct 24 18:22:18 2009 -0400

    Prefer G_N_ELEMENTS over sizeof calculations.

 addressbook/e-book-backend-exchange.c       |   18 ++++++++----------
 addressbook/e-book-backend-gal.c            |   16 +++++++---------
 calendar/e-cal-backend-exchange-tasks.c     |    3 +--
 calendar/e2k-cal-query.c                    |    2 +-
 camel/mail-utils.c                          |    3 +--
 eplugin/exchange-delegates.c                |    7 +++----
 eplugin/exchange-permissions-dialog.c       |    3 +--
 server/lib/e2k-autoconfig.c                 |   10 ++++------
 server/lib/e2k-freebusy.c                   |    7 +++----
 server/lib/e2k-marshal.c                    |    2 ++
 server/lib/e2k-security-descriptor.c        |    6 ++----
 server/lib/ebrowse.c                        |    3 +--
 server/lib/ruletest.c                       |    4 ++--
 server/storage/exchange-hierarchy-foreign.c |    8 ++++----
 server/storage/exchange-hierarchy-somedav.c |    6 +++---
 server/storage/exchange-hierarchy-webdav.c  |   11 +++++------
 tools/exchange-autoconfig-wizard.c          |   10 ++++------
 17 files changed, 52 insertions(+), 67 deletions(-)
---
diff --git a/addressbook/e-book-backend-exchange.c b/addressbook/e-book-backend-exchange.c
index c442b9c..87bbb02 100644
--- a/addressbook/e-book-backend-exchange.c
+++ b/addressbook/e-book-backend-exchange.c
@@ -222,7 +222,6 @@ prop_mappings[] = {
 
 	EXCHANGE_FIELD (CATEGORIES, KEYWORDS, "categories", proppatch_categories, populate_categories)
 };
-static gint num_prop_mappings = sizeof(prop_mappings) / sizeof (prop_mappings[0]);
 
 struct ContactListMember
 {
@@ -236,7 +235,7 @@ e_book_backend_exchange_prop_to_exchange (const gchar *propname)
 {
 	gint i;
 
-	for (i = 0; i < num_prop_mappings; i ++)
+	for (i = 0; i < G_N_ELEMENTS (prop_mappings); i ++)
 		if (prop_mappings[i].e_book_field && !strcmp (prop_mappings[i].e_book_field, propname))
 			return prop_mappings[i].prop_name;
 
@@ -430,7 +429,7 @@ e_contact_from_props (EBookBackendExchange *be, E2kResult *result)
 
 	e_contact_set (contact, E_CONTACT_UID, result->href);
 
-	for (i = 0; i < num_prop_mappings; i ++) {
+	for (i = 0; i < G_N_ELEMENTS (prop_mappings); i ++) {
 		data = e2k_properties_get_prop (result->props,
 						prop_mappings[i].prop_name);
 		if (!data)
@@ -616,7 +615,6 @@ static const gchar *folder_props[] = {
 	PR_ACCESS,
 	E2K_PR_DAV_LAST_MODIFIED
 };
-static const gint n_folder_props = sizeof (folder_props) / sizeof (folder_props[0]);
 
 static gpointer
 build_cache (EBookBackendExchange *be)
@@ -725,7 +723,7 @@ e_book_backend_exchange_connect (EBookBackendExchange *be)
 
 	/* check permissions on the folder */
 	status = e_folder_exchange_propfind (bepriv->folder, NULL,
-					     folder_props, n_folder_props,
+					     folder_props, G_N_ELEMENTS (folder_props),
 					     &results, &nresults);
 
 	if (status != E2K_HTTP_MULTI_STATUS) {
@@ -1301,7 +1299,7 @@ props_from_contact (EBookBackendExchange *be,
 			}
 		}
 	} else {
-		for (i = 0; i < num_prop_mappings; i ++) {
+		for (i = 0; i < G_N_ELEMENTS (prop_mappings); i ++) {
 			/* handle composite attributes here (like addresses) */
 			if (prop_mappings[i].flags & FLAG_COMPOSITE) {
 				prop_mappings[i].composite_proppatch_func (&prop_mappings[i], contact, old_contact, props);
@@ -2002,7 +2000,7 @@ func_match (struct _ESExp *f, gint argc, struct _ESExpResult **argv, gpointer da
 		gint i;
 
 		rns = g_ptr_array_new ();
-		for (i = 0; i < num_prop_mappings; i ++) {
+		for (i = 0; i < G_N_ELEMENTS (prop_mappings); i ++) {
 			if (prop_mappings[i].flags & FLAG_UNLIKEABLE)
 				continue;
 
@@ -2098,7 +2096,7 @@ e_book_backend_exchange_build_restriction (const gchar *query,
 
 	sexp = e_sexp_new ();
 
-	for (i = 0; i < sizeof (symbols) / sizeof (symbols[0]); i++) {
+	for (i = 0; i < G_N_ELEMENTS (symbols); i++) {
 		e_sexp_add_function (sexp, 0, (gchar *) symbols[i].name,
 				     symbols[i].func,
 				     GUINT_TO_POINTER (symbols[i].flags));
@@ -2728,7 +2726,7 @@ e_book_backend_exchange_get_supported_fields (EBookBackendSync  *backend,
 	d(printf("ebbe_get_supported_fields(%p, %p)\n", backend, book));
 
 	*methods = NULL;
-	for (i = 0; i < num_prop_mappings; i ++) {
+	for (i = 0; i < G_N_ELEMENTS (prop_mappings); i ++) {
 		if (prop_mappings[i].e_book_field) {
 			*methods = g_list_prepend (*methods,
 					g_strdup (e_contact_field_name(prop_mappings[i].field)));
@@ -2983,7 +2981,7 @@ e_book_backend_exchange_class_init (EBookBackendExchangeClass *klass)
 	g_ptr_array_add (field_names_array, (gpointer) E2K_PR_MAPI_EMAIL_2_ADDRTYPE);
 	g_ptr_array_add (field_names_array, (gpointer) E2K_PR_MAPI_EMAIL_3_ADDRTYPE);
 	g_ptr_array_add (field_names_array, (gpointer) E2K_PR_HTTPMAIL_HAS_ATTACHMENT);
-	for (i = 0; i < num_prop_mappings; i ++)
+	for (i = 0; i < G_N_ELEMENTS (prop_mappings); i ++)
 		g_ptr_array_add (field_names_array, (gpointer) prop_mappings[i].prop_name);
 	field_names = (const gchar **)field_names_array->pdata;
 	n_field_names = field_names_array->len;
diff --git a/addressbook/e-book-backend-gal.c b/addressbook/e-book-backend-gal.c
index 084970d..ce448bd 100644
--- a/addressbook/e-book-backend-gal.c
+++ b/addressbook/e-book-backend-gal.c
@@ -216,8 +216,6 @@ struct prop_info {
 #undef GROUP_PROP
 };
 
-static gint num_prop_infos = sizeof(prop_info) / sizeof(prop_info[0]);
-
 static gboolean
 can_browse (EBookBackend *backend)
 {
@@ -1015,7 +1013,7 @@ query_prop_to_ldap (const gchar *query_prop)
 	if (!strcmp (query_prop, "email"))
 		query_prop = "email_1";
 
-	for (i = 0; i < num_prop_infos; i ++)
+	for (i = 0; i < G_N_ELEMENTS (prop_info); i ++)
 		if (!strcmp (query_prop, e_contact_field_name (prop_info[i].field_id)))
 			return prop_info[i].ldap_attr;
 
@@ -1199,7 +1197,7 @@ build_query (EBookBackendGAL *bl, const gchar *query, const gchar *ldap_filter,
 
 	sexp = e_sexp_new();
 
-	for (i=0;i<sizeof(symbols)/sizeof(symbols[0]);i++) {
+	for (i = 0; i < G_N_ELEMENTS (symbols); i++) {
 		e_sexp_add_function(sexp, 0, (gchar *) symbols[i].name,
 				    symbols[i].func, NULL);
 	}
@@ -1446,7 +1444,7 @@ build_contact_from_entry (EBookBackendGAL *bl, LDAPMessage *e, GList **existing_
 			ldap_value_free (values);
 		}
 		else {
-			for (i = 0; i < num_prop_infos; i ++)
+			for (i = 0; i < G_N_ELEMENTS (prop_info); i ++)
 				if (!g_ascii_strcasecmp (attr, prop_info[i].ldap_attr)) {
 					info = &prop_info[i];
 					break;
@@ -2879,16 +2877,16 @@ class_init (EBookBackendGALClass *klass)
 
 	/* Set up static data */
 	supported_fields = NULL;
-	for (i = 0; i < num_prop_infos; i++) {
+	for (i = 0; i < G_N_ELEMENTS (prop_info); i++) {
 		supported_fields = g_list_append (supported_fields,
 						  (gchar *)e_contact_field_name (prop_info[i].field_id));
 	}
 	supported_fields = g_list_append (supported_fields, (gpointer) "file_as");
 
-	search_attrs = g_new (const gchar *, num_prop_infos + 1);
-	for (i = 0; i < num_prop_infos; i++)
+	search_attrs = g_new (const gchar *, G_N_ELEMENTS (prop_info) + 1);
+	for (i = 0; i < G_N_ELEMENTS (prop_info); i++)
 		search_attrs[i] = prop_info[i].ldap_attr;
-	search_attrs[num_prop_infos] = NULL;
+	search_attrs[G_N_ELEMENTS (prop_info)] = NULL;
 }
 
 static void
diff --git a/calendar/e-cal-backend-exchange-tasks.c b/calendar/e-cal-backend-exchange-tasks.c
index 6f5d68c..570930b 100644
--- a/calendar/e-cal-backend-exchange-tasks.c
+++ b/calendar/e-cal-backend-exchange-tasks.c
@@ -558,7 +558,6 @@ static const gchar *task_props[] = {
         E2K_PR_EXCHANGE_KEYWORDS,
         E2K_PR_CALENDAR_URL
 };
-static const gint n_task_props = sizeof (task_props) / sizeof (task_props[0]);
 
 static guint
 get_changed_tasks (ECalBackendExchange *cbex)
@@ -611,7 +610,7 @@ get_changed_tasks (ECalBackendExchange *cbex)
 
         iter = e_folder_exchange_search_start (cbex->folder, NULL,
 					       task_props,
-					       n_task_props,
+					       G_N_ELEMENTS (task_props),
 					       rn, NULL, TRUE);
         e2k_restriction_unref (rn);
 
diff --git a/calendar/e2k-cal-query.c b/calendar/e2k-cal-query.c
index e869e91..8c8a862 100644
--- a/calendar/e2k-cal-query.c
+++ b/calendar/e2k-cal-query.c
@@ -398,7 +398,7 @@ e2k_cal_query_to_restriction (ECalBackendExchange *cbex,
 	g_return_val_if_fail (sexp != NULL, NULL);
 
 	esexp = e_sexp_new ();
-	for (i = 0; i < (sizeof (functions) / sizeof (functions[0])); i++)
+	for (i = 0; i < G_N_ELEMENTS (functions); i++)
 		e_sexp_add_function (esexp, 0, (gchar *) functions[i].name, functions[i].func, NULL);
 
 	e_sexp_input_text (esexp, sexp, strlen (sexp));
diff --git a/camel/mail-utils.c b/camel/mail-utils.c
index 4505378..2040382 100644
--- a/camel/mail-utils.c
+++ b/camel/mail-utils.c
@@ -220,7 +220,6 @@ mail_util_extract_transport_headers (E2kProperties *props)
 static const gchar *note_colors[] = {
 	"#CCCCFF", "#CCFFCC", "#FFCCCC", "#FFFFCC", "#FFFFFF"
 };
-static const gint ncolors = sizeof (note_colors) / sizeof (note_colors[0]);
 #define DEFAULT_NOTE_COLOR 3
 
 /**
@@ -272,7 +271,7 @@ mail_util_stickynote_to_rfc822 (E2kProperties *props)
 	prop = e2k_properties_get_prop (props, E2K_PR_OUTLOOK_STICKYNOTE_COLOR);
 	if (prop) {
 		color = atoi (prop);
-		if (color < 0 || color >= ncolors)
+		if (color < 0 || color >= G_N_ELEMENTS (note_colors))
 			color = DEFAULT_NOTE_COLOR;
 	} else
 		color = DEFAULT_NOTE_COLOR;
diff --git a/eplugin/exchange-delegates.c b/eplugin/exchange-delegates.c
index 89da03e..4168191 100644
--- a/eplugin/exchange-delegates.c
+++ b/eplugin/exchange-delegates.c
@@ -188,7 +188,6 @@ static const gchar *sd_props[] = {
 	E2K_PR_EXCHANGE_SD_BINARY,
 	E2K_PR_EXCHANGE_SD_XML
 };
-static const gint n_sd_props = sizeof (sd_props) / sizeof (sd_props[0]);
 
 /* Read the folder security descriptors and match them up with the
  * list of delegates.
@@ -236,7 +235,7 @@ get_folder_security (ExchangeDelegates *delegates)
 	iter = e2k_context_bpropfind_start (
 		ctx, NULL, delegates->account->home_uri,
 		(const gchar **)hrefs->pdata, hrefs->len,
-		sd_props, n_sd_props);
+		sd_props, G_N_ELEMENTS (sd_props));
 	g_ptr_array_free (hrefs, TRUE);
 
 	while ((result = e2k_result_iter_next (iter))) {
@@ -284,7 +283,6 @@ static const gchar *delegation_props[] = {
 	PR_DELEGATES_SEE_PRIVATE,
 	PR_CREATOR_ENTRYID
 };
-static const gint n_delegation_props = sizeof (delegation_props) / sizeof (delegation_props[0]);
 
 /* Fetch the list of delegates from the freebusy message. */
 static gboolean
@@ -302,7 +300,8 @@ get_user_list (ExchangeDelegates *delegates)
 	iter = e2k_context_bpropfind_start (ctx, NULL,
 					    delegates->account->home_uri,
 					    &exchange_localfreebusy_path, 1,
-					    delegation_props, n_delegation_props);
+					    delegation_props,
+					    G_N_ELEMENTS (delegation_props));
 	result = e2k_result_iter_next (iter);
 	if (!result || !E2K_HTTP_STATUS_IS_SUCCESSFUL (result->status)) {
 		e2k_result_iter_free (iter);
diff --git a/eplugin/exchange-permissions-dialog.c b/eplugin/exchange-permissions-dialog.c
index 20af66e..b3a5fb9 100644
--- a/eplugin/exchange-permissions-dialog.c
+++ b/eplugin/exchange-permissions-dialog.c
@@ -131,7 +131,6 @@ static const gchar *sd_props[] = {
 	E2K_PR_EXCHANGE_SD_BINARY,
 	E2K_PR_EXCHANGE_SD_XML
 };
-static const gint n_sd_props = sizeof (sd_props) / sizeof (sd_props[0]);
 
 /**
  * exchange_permissions_dialog_new:
@@ -197,7 +196,7 @@ exchange_permissions_dialog_new (ExchangeAccount *account,
 
 	/* And fetch the security descriptor */
 	status = e2k_context_propfind (ctx, NULL, folder_uri,
-				       sd_props, n_sd_props,
+				       sd_props, G_N_ELEMENTS (sd_props),
 				       &results, &nresults);
 	if (!E2K_HTTP_STATUS_IS_SUCCESSFUL (status) || nresults < 1) {
 	lose:
diff --git a/server/lib/e2k-autoconfig.c b/server/lib/e2k-autoconfig.c
index f277e2a..a113748 100644
--- a/server/lib/e2k-autoconfig.c
+++ b/server/lib/e2k-autoconfig.c
@@ -618,7 +618,6 @@ static const gchar *home_properties[] = {
 	PR_STORE_ENTRYID,
 	E2K_PR_EXCHANGE_TIMEZONE
 };
-static const gint n_home_properties = sizeof (home_properties) / sizeof (home_properties[0]);
 
 /*
  * e2k_autoconfig_check_exchange:
@@ -753,7 +752,7 @@ e2k_autoconfig_check_exchange (E2kAutoconfig *ac, E2kOperation *op)
 	iter = e2k_context_bpropfind_start (ctx, op,
 					    ac->home_uri, hrefs, 1,
 					    home_properties,
-					    n_home_properties);
+					    G_N_ELEMENTS (home_properties));
 	results = e2k_result_iter_next (iter);
 	if (results) {
 		timezone = e2k_properties_get_prop (results->props,
@@ -1319,7 +1318,6 @@ static struct {
 	/* (GMT+13:00) Nuku'alofa */
 	{ "Tonga", NULL, NULL, "Pacific/Tongatapu" }
 };
-static const gint n_zone_mappings = sizeof (zonemap) / sizeof (zonemap[0]);
 
 static gchar *
 find_olson_timezone (const gchar *windows_timezone)
@@ -1337,13 +1335,13 @@ find_olson_timezone (const gchar *windows_timezone)
 	tzlen = p - windows_timezone + 1;
 
 	/* Find the first entry in zonemap with a matching name */
-	for (i = 0; i < n_zone_mappings; i++) {
+	for (i = 0; i < G_N_ELEMENTS (zonemap); i++) {
 		if (!g_ascii_strncasecmp (windows_timezone,
 					  zonemap[i].windows_name,
 					  tzlen))
 			break;
 	}
-	if (i == n_zone_mappings)
+	if (i == G_N_ELEMENTS (zonemap))
 		return NULL; /* Shouldn't happen... */
 
 	/* If there's only one choice, go with it */
@@ -1373,7 +1371,7 @@ find_olson_timezone (const gchar *windows_timezone)
 		if ((zonemap[i].lang && !strcmp (zonemap[i].lang, lang)) ||
 		    (zonemap[i].country && !strcmp (zonemap[i].country, country)))
 			return g_strdup (zonemap[i].olson_name);
-	} while (++i < n_zone_mappings &&
+	} while (++i < G_N_ELEMENTS (zonemap) &&
 		 !g_ascii_strncasecmp (windows_timezone,
 				       zonemap[i].windows_name,
 				       tzlen));
diff --git a/server/lib/e2k-freebusy.c b/server/lib/e2k-freebusy.c
index 6ed069d..29646de 100644
--- a/server/lib/e2k-freebusy.c
+++ b/server/lib/e2k-freebusy.c
@@ -151,7 +151,6 @@ static const gchar *public_freebusy_props[] = {
 	PR_FREEBUSY_OOF_MONTHS,
 	PR_FREEBUSY_OOF_EVENTS
 };
-static const gint n_public_freebusy_props = sizeof (public_freebusy_props) / sizeof (public_freebusy_props[0]);
 
 /**
  * e2k_freebusy_new:
@@ -184,7 +183,7 @@ e2k_freebusy_new (E2kContext *ctx, const gchar *public_uri, const gchar *dn)
 
 	status = e2k_context_propfind (ctx, NULL, uri,
 				       public_freebusy_props,
-				       n_public_freebusy_props,
+				       G_N_ELEMENTS (public_freebusy_props),
 				       &results, &nresults);
 	if (!E2K_HTTP_STATUS_IS_SUCCESSFUL (status) || nresults == 0) {
 		/* FIXME: create it */
@@ -367,7 +366,6 @@ static const gchar *freebusy_props[] = {
 	E2K_PR_CALENDAR_DTEND,
 	E2K_PR_CALENDAR_BUSY_STATUS
 };
-static const gint n_freebusy_props = sizeof (freebusy_props) / sizeof (freebusy_props[0]);
 
 /**
  * e2k_freebusy_add_from_calendar_uri:
@@ -411,7 +409,8 @@ e2k_freebusy_add_from_calendar_uri (E2kFreebusy *fb, const gchar *uri,
 		NULL);
 
 	iter = e2k_context_search_start (fb->ctx, NULL, uri,
-					 freebusy_props, n_freebusy_props,
+					 freebusy_props,
+					 G_N_ELEMENTS (freebusy_props),
 					 rn, NULL, TRUE);
 	e2k_restriction_unref (rn);
 	g_free (start);
diff --git a/server/lib/e2k-marshal.c b/server/lib/e2k-marshal.c
index f6a230c..44c1405 100644
--- a/server/lib/e2k-marshal.c
+++ b/server/lib/e2k-marshal.c
@@ -2,6 +2,7 @@
 
 #include	<glib-object.h>
 
+
 #ifdef G_ENABLE_DEBUG
 #define g_marshal_value_peek_boolean(v)  g_value_get_boolean (v)
 #define g_marshal_value_peek_char(v)     g_value_get_char (v)
@@ -46,6 +47,7 @@
 #define g_marshal_value_peek_object(v)   (v)->data[0].v_pointer
 #endif /* !G_ENABLE_DEBUG */
 
+
 /* NONE:INT,INT (./e2k-marshal.list:1) */
 void
 e2k_marshal_VOID__INT_INT (GClosure     *closure,
diff --git a/server/lib/e2k-security-descriptor.c b/server/lib/e2k-security-descriptor.c
index abf2342..3eaa817 100644
--- a/server/lib/e2k-security-descriptor.c
+++ b/server/lib/e2k-security-descriptor.c
@@ -115,8 +115,6 @@ static E2kPermissionsMap permissions_map[] = {
 	{ E2K_PERMISSION_FOLDER_VISIBLE,
 	  LE(0x1208a9), LE(0x1200a9), LE(0x000000), LE(0x000000) }
 };
-static const gint permissions_map_size =
-	sizeof (permissions_map) / sizeof (permissions_map[0]);
 
 static const guint32 container_permissions_all = LE(0x1fc9bf);
 static const guint32 object_permissions_all    = LE(0x1f0fbf);
@@ -709,7 +707,7 @@ e2k_security_descriptor_get_permissions (E2kSecurityDescriptor *sd,
 		if (aces[ace].Header.AceType == E2K_ACCESS_DENIED_ACE_TYPE)
 			continue;
 
-		for (map = 0; map < permissions_map_size; map++) {
+		for (map = 0; map < G_N_ELEMENTS (permissions_map); map++) {
 			if (aces[ace].Header.AceFlags & E2K_OBJECT_INHERIT_ACE)
 				checkperm = permissions_map[map].object_allowed;
 			else
@@ -797,7 +795,7 @@ e2k_security_descriptor_set_permissions (E2kSecurityDescriptor *sd,
 	container_allowed = 0;
 	container_denied  = container_permissions_all;
 
-	for (map = 0; map < permissions_map_size; map++) {
+	for (map = 0; map < G_N_ELEMENTS (permissions_map); map++) {
 		if (!(permissions_map[map].mapi_permission & perms))
 			continue;
 
diff --git a/server/lib/ebrowse.c b/server/lib/ebrowse.c
index 7f14028..26d4f2c 100644
--- a/server/lib/ebrowse.c
+++ b/server/lib/ebrowse.c
@@ -54,7 +54,6 @@ static const gchar *folder_tree_props[] = {
 	E2K_PR_DAV_DISPLAY_NAME,
 	E2K_PR_EXCHANGE_FOLDER_CLASS
 };
-static const gint n_folder_tree_props = sizeof (folder_tree_props) / sizeof (folder_tree_props[0]);
 
 static void
 display_folder_tree (E2kContext *ctx, gchar *top)
@@ -70,7 +69,7 @@ display_folder_tree (E2kContext *ctx, gchar *top)
 					E2K_RELOP_EQ, TRUE);
 	iter = e2k_context_search_start (ctx, &op, top,
 					 folder_tree_props,
-					 n_folder_tree_props,
+					 G_N_ELEMENTS (folder_tree_props),
 					 rn, NULL, TRUE);
 	e2k_restriction_unref (rn);
 
diff --git a/server/lib/ruletest.c b/server/lib/ruletest.c
index 7cf0bd4..c5ea6d0 100644
--- a/server/lib/ruletest.c
+++ b/server/lib/ruletest.c
@@ -37,7 +37,6 @@ const gchar *test_program_name = "ruletest";
 static const gchar *rules_props[] = {
 	PR_RULES_DATA,
 };
-static const gint n_rules_props = sizeof (rules_props) / sizeof (rules_props[0]);
 
 void
 test_main (gint argc, gchar **argv)
@@ -59,7 +58,8 @@ test_main (gint argc, gchar **argv)
 
 	ctx = test_get_context (url);
 	status = e2k_context_propfind (ctx, NULL, url,
-				       rules_props, n_rules_props,
+				       rules_props,
+				       G_N_ELEMENTS (rules_props),
 				       &results, &nresults);
 	test_abort_if_http_error (status);
 
diff --git a/server/storage/exchange-hierarchy-foreign.c b/server/storage/exchange-hierarchy-foreign.c
index 69bf785..93d5174 100644
--- a/server/storage/exchange-hierarchy-foreign.c
+++ b/server/storage/exchange-hierarchy-foreign.c
@@ -116,7 +116,6 @@ static const gchar *privacy_props[] = {
 	PR_DELEGATES_ENTRYIDS,
 	PR_DELEGATES_SEE_PRIVATE,
 };
-static const gint n_privacy_props = sizeof (privacy_props) / sizeof (privacy_props[0]);
 
 static void
 check_hide_private (ExchangeHierarchy *hier)
@@ -143,7 +142,8 @@ check_hide_private (ExchangeHierarchy *hier)
 	ctx = exchange_account_get_context (hier->account);
 
 	status = e2k_context_propfind (ctx, NULL, uri,
-				       privacy_props, n_privacy_props,
+				       privacy_props,
+				       G_N_ELEMENTS (privacy_props),
 				       &results, &nresults);
 	g_free (uri);
 
@@ -210,7 +210,6 @@ static const gchar *folder_props[] = {
 	E2K_PR_DAV_DISPLAY_NAME,
 	PR_ACCESS
 };
-static const gint n_folder_props = sizeof (folder_props) / sizeof (folder_props[0]);
 
 static ExchangeAccountFolderResult
 find_folder (ExchangeHierarchy *hier, const gchar *uri, EFolder **folder_out)
@@ -224,7 +223,8 @@ find_folder (ExchangeHierarchy *hier, const gchar *uri, EFolder **folder_out)
 	const gchar *access;
 
 	status = e2k_context_propfind (ctx, NULL, uri,
-				       folder_props, n_folder_props,
+				       folder_props,
+				       G_N_ELEMENTS (folder_props),
 				       &results, &nresults);
 	if (!E2K_HTTP_STATUS_IS_SUCCESSFUL (status))
 		return exchange_hierarchy_webdav_status_to_folder_result (status);
diff --git a/server/storage/exchange-hierarchy-somedav.c b/server/storage/exchange-hierarchy-somedav.c
index 8b93336..4ed598c 100644
--- a/server/storage/exchange-hierarchy-somedav.c
+++ b/server/storage/exchange-hierarchy-somedav.c
@@ -117,7 +117,6 @@ static const gchar *folder_props[] = {
 	E2K_PR_DAV_DISPLAY_NAME,
 	PR_ACCESS
 };
-static const gint n_folder_props = sizeof (folder_props) / sizeof (folder_props[0]);
 
 static ExchangeAccountFolderResult
 scan_subtree (ExchangeHierarchy *hier, EFolder *folder, gint mode)
@@ -154,7 +153,7 @@ scan_subtree (ExchangeHierarchy *hier, EFolder *folder, gint mode)
 						  (const gchar **)hrefs->pdata,
 						  hrefs->len,
 						  folder_props,
-						  n_folder_props);
+						  G_N_ELEMENTS (folder_props));
 
 	while ((result = e2k_result_iter_next (iter))) {
 		folders_returned++;
@@ -233,7 +232,8 @@ exchange_hierarchy_somedav_add_folder (ExchangeHierarchySomeDAV *hsd,
 	ctx = exchange_account_get_context (hier->account);
 
 	status = e2k_context_propfind (ctx, NULL, uri,
-				       folder_props, n_folder_props,
+				       folder_props,
+				       G_N_ELEMENTS (folder_props),
 				       &results, &nresults);
 	if (!E2K_HTTP_STATUS_IS_SUCCESSFUL (status))
 		return exchange_hierarchy_webdav_status_to_folder_result (status);
diff --git a/server/storage/exchange-hierarchy-webdav.c b/server/storage/exchange-hierarchy-webdav.c
index 30315d5..ca48c0d 100644
--- a/server/storage/exchange-hierarchy-webdav.c
+++ b/server/storage/exchange-hierarchy-webdav.c
@@ -498,7 +498,6 @@ static const gchar *rescan_props[] = {
 	E2K_PR_EXCHANGE_FOLDER_SIZE,
 	E2K_PR_HTTPMAIL_UNREAD_COUNT
 };
-static const gint n_rescan_props = sizeof (rescan_props) / sizeof (rescan_props[0]);
 
 static void
 rescan (ExchangeHierarchy *hier)
@@ -531,7 +530,8 @@ rescan (ExchangeHierarchy *hier)
 	iter = e_folder_exchange_bpropfind_start (hier->toplevel, NULL,
 						  (const gchar **)hrefs->pdata,
 						  hrefs->len,
-						  rescan_props, n_rescan_props);
+						  rescan_props,
+						  G_N_ELEMENTS (rescan_props));
 	g_ptr_array_free (hrefs, TRUE);
 
 	while ((result = e2k_result_iter_next (iter))) {
@@ -681,7 +681,6 @@ static const gchar *folder_props[] = {
 	E2K_PR_EXCHANGE_FOLDER_SIZE,
 	E2K_PR_DAV_HAS_SUBS
 };
-static const gint n_folder_props = sizeof (folder_props) / sizeof (folder_props[0]);
 
 static const gchar *pub_folder_props[] = {
 	E2K_PR_EXCHANGE_FOLDER_CLASS,
@@ -689,7 +688,6 @@ static const gchar *pub_folder_props[] = {
 	E2K_PR_EXCHANGE_PERMANENTURL,
 	E2K_PR_DAV_HAS_SUBS
 };
-static const gint n_pub_folder_props = sizeof (pub_folder_props) / sizeof (pub_folder_props[0]);
 
 static ExchangeAccountFolderResult
 scan_subtree (ExchangeHierarchy *hier, EFolder *parent, gint mode)
@@ -738,11 +736,12 @@ scan_subtree (ExchangeHierarchy *hier, EFolder *parent, gint mode)
 	if (hier->type == EXCHANGE_HIERARCHY_PUBLIC)
 		iter = e_folder_exchange_search_start (parent, NULL,
 						       pub_folder_props,
-						       n_pub_folder_props,
+						       G_N_ELEMENTS (pub_folder_props),
 						       folders_rn, NULL, TRUE);
 	else
 		iter = e_folder_exchange_search_start (parent, NULL,
-						       folder_props, n_folder_props,
+						       folder_props,
+						       G_N_ELEMENTS (folder_props),
 						       folders_rn, NULL, TRUE);
 
 	while ((result = e2k_result_iter_next (iter))) {
diff --git a/tools/exchange-autoconfig-wizard.c b/tools/exchange-autoconfig-wizard.c
index 4929d8c..b0aecf6 100644
--- a/tools/exchange-autoconfig-wizard.c
+++ b/tools/exchange-autoconfig-wizard.c
@@ -618,8 +618,6 @@ static struct {
 	{ NULL, -1, finish_page_create, NULL, NULL, NULL }
 };
 
-static const gint num_autoconfig_pages = sizeof (autoconfig_pages) / sizeof (autoconfig_pages[0]);
-
 /* Autoconfig assistant */
 
 static gint
@@ -627,7 +625,7 @@ find_page (ExchangeAutoconfigGUI *gui, GtkWidget *page)
 {
 	gint page_num;
 
-	for (page_num = 0; page_num < num_autoconfig_pages; page_num++) {
+	for (page_num = 0; page_num < G_N_ELEMENTS (autoconfig_pages); page_num++) {
 		if (autoconfig_pages[page_num].assistant_page == page)
 			return page_num;
 	}
@@ -665,7 +663,7 @@ assistant_page_content_changed (GtkWidget *sender, ExchangeAutoconfigGUI *gui)
 	if (page_num == -1)
 		return;
 
-	g_return_if_fail (page_num >= 0 && page_num < num_autoconfig_pages);
+	g_return_if_fail (page_num >= 0 && page_num < G_N_ELEMENTS (autoconfig_pages));
 
 	gui->changing = TRUE;
 
@@ -704,7 +702,7 @@ assistant_forward_func (gint current_page, gpointer user_data)
 	if (!gui->changing && gui->active_page == current_page) {
 		gint page_num;
 
-		for (page_num = 0; page_num < num_autoconfig_pages; page_num++) {
+		for (page_num = 0; page_num < G_N_ELEMENTS (autoconfig_pages); page_num++) {
 			if (autoconfig_pages[page_num].assistant_page_index == current_page) {
 				if (autoconfig_pages[page_num].get_next_page_func)
 					next_page = autoconfig_pages[page_num].get_next_page_func (gui);
@@ -745,7 +743,7 @@ exchange_autoconfig_assistant_run (void)
 	icon = gdk_pixbuf_new_from_file (pngfile, NULL);
 	g_free (pngfile);
 
-	for (i = 0; i < num_autoconfig_pages; i++) {
+	for (i = 0; i < G_N_ELEMENTS (autoconfig_pages); i++) {
 		autoconfig_pages[i].create_func (gui, icon, &autoconfig_pages[i].assistant_page, &autoconfig_pages[i].assistant_page_index);
 	}
 



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