From: Jukka Rissanen Date: Wed, 9 May 2012 10:48:26 +0000 (+0300) Subject: dhcp: Use g_list_length() to calculate the list length X-Git-Tag: 1.1~86 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=625e2ed950e25adce7b89fb120c0578c220d973a;p=platform%2Fupstream%2Fconnman.git dhcp: Use g_list_length() to calculate the list length --- diff --git a/src/dhcp.c b/src/dhcp.c index 22eca60..f4de736 100644 --- a/src/dhcp.c +++ b/src/dhcp.c @@ -244,8 +244,7 @@ static void lease_available_cb(GDHCPClient *dhcp_client, gpointer user_data) ip_change = FALSE; option = g_dhcp_client_get_option(dhcp_client, G_DHCP_DNS_SERVER); - for (ns_entries = 0, list = option; list; list = list->next) - ns_entries += 1; + ns_entries = g_list_length(option); nameservers = g_try_new0(char *, ns_entries + 1); if (nameservers != NULL) { for (i = 0, list = option; list; list = list->next, i++) @@ -262,8 +261,7 @@ static void lease_available_cb(GDHCPClient *dhcp_client, gpointer user_data) hostname = g_strdup(option->data); option = g_dhcp_client_get_option(dhcp_client, G_DHCP_NTP_SERVER); - for (ns_entries = 0, list = option; list; list = list->next) - ns_entries += 1; + ns_entries = g_list_length(option); timeservers = g_try_new0(char *, ns_entries + 1); if (timeservers != NULL) { for (i = 0, list = option; list; list = list->next, i++)