Skip to contentSkip to conversation

Fix pulling phonebook size

PATCH In review Bartosz Szatkowski 2 participants 4 messages Jul 22, 2011 – Jul 26, 2011 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix pulling phonebook size

---
 plugins/phonebook-ebook.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
plugins/phonebook-ebook.c +1 -1
index 9cb32c3..91d0c0b 100644
@@ -180,7 +180,7 @@ static void ebookpull_cb(EBook *book, const GError *gerr, GList *contacts,
 	 */
 	maxcount = data->params->maxlistcount;
 	if (maxcount == 0) {
-		count += g_list_length(contacts);
+		data->count += g_list_length(contacts);
 		goto done;
 	}
 
Signature · 1 line
1.7.6
#1 lore raw

Hi Bartosz,

Quoted 9 lines · Bartosz Szatkowski
---
 plugins/phonebook-ebook.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
plugins/phonebook-ebook.c +0 -0
index 9cb32c3..91d0c0b 100644

plugins/phonebook-ebook.c static void ebookpull_cb(EBook *book, const GError *gerr, GList *contacts, · line 185

Quoted 7 lines
plugins/phonebook-ebook.c +1 -1
@@ -180,7 +180,7 @@ static void ebookpull_cb(EBook *book, const GError *gerr, GList *contacts,
 	 */
 	maxcount = data->params->maxlistcount;
 	if (maxcount == 0) {
-		count += g_list_length(contacts);
+		data->count += g_list_length(contacts);
 		goto done;
 	}

Since you're doing this I suppose it also makes sense to move the initialization of the count variable (to 0) to the initialization part of the for loop in the same function.

Johan

#2 lore raw

PATCH 1/1 Fix pulling phonebook size

---
 plugins/phonebook-ebook.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
plugins/phonebook-ebook.c +5 -5
index 9cb32c3..683037a 100644
@@ -164,7 +164,7 @@ static void ebookpull_cb(EBook *book, const GError *gerr, GList *contacts,
 {
 	struct query_context *data = user_data;
 	GList *l;
-	unsigned int count = 0, maxcount;
+	unsigned int count, maxcount;
 
 	if (gerr != NULL) {
 		error("E-Book query failed: %s", gerr->message);
@@ -180,13 +180,13 @@ static void ebookpull_cb(EBook *book, const GError *gerr, GList *contacts,
 	 */
 	maxcount = data->params->maxlistcount;
 	if (maxcount == 0) {
-		count += g_list_length(contacts);
+		data->count += g_list_length(contacts);
 		goto done;
 	}
 
 	l = g_list_nth(contacts, data->params->liststartoffset);
 
-	for (; l && count + data->count < maxcount; l = g_list_next(l),
+	for (count = 0; l && count + data->count < maxcount; l = g_list_next(l),
 								count++) {
 		EContact *contact = E_CONTACT(l->data);
 		EVCard *evcard = E_VCARD(contact);
@@ -200,13 +200,13 @@ static void ebookpull_cb(EBook *book, const GError *gerr, GList *contacts,
 		g_free(vcard);
 	}
 
+	DBG("collected %d vcards", count);
+
 	data->count += count;
 
 done:
 	g_list_free_full(contacts, g_object_unref);
 
-	DBG("collected %d vcards", count);
-
 	data->queued_calls--;
 	if (data->queued_calls == 0) {
 		GString *buf = data->buf;
Signature · 1 line
1.7.6
#3 lore raw

Hi Bartosz,

Quoted 3 lines · Bartosz Szatkowski
---
 plugins/phonebook-ebook.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

Applied. Thanks.

Johan