Skip to contentSkip to conversation

Code clean-up: Remove unnecessary empty lines

PATCH In review Rafal Michalski 2 participants 5 messages Sep 22, 2011 – Sep 27, 2011 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 Code clean-up: Remove unnecessary empty lines

This patch removes unnecessary empty lines.

---
 plugins/phonebook-tracker.c |    1 -
 plugins/vcard.c             |    1 -
 2 files changed, 0 insertions(+), 2 deletions(-)
plugins/phonebook-tracker.c +0 -1
index 47ce878..da2e2bb 100644
@@ -1003,7 +1003,6 @@ static void add_affiliation(char **field, const char *value)
 static void contact_init(struct phonebook_contact *contact,
 							const char **reply)
 {
-
 	contact->fullname = g_strdup(reply[COL_FULL_NAME]);
 	contact->family = g_strdup(reply[COL_FAMILY_NAME]);
 	contact->given = g_strdup(reply[COL_GIVEN_NAME]);
plugins/vcard.c +0 -1
index 0522c96..e5e1de1 100644
@@ -825,7 +825,6 @@ void phonebook_add_contact(GString *vcards, struct phonebook_contact *contact,
 	vcard_printf_end(vcards);
 }
 
-
 static void field_free(gpointer data)
 {
 	struct phonebook_field *field = data;
Signature · 1 line
1.6.3.3
#1 lore raw

PATCH 2/4 Code clean-up: Remove unnecessary character in comment

This patch removes unnecessary comment's character.

---
 plugins/vcard.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
plugins/vcard.c +1 -1
index e5e1de1..ca3a052 100644
@@ -681,7 +681,7 @@ static void vcard_printf_address(GString *vcards, uint8_t format,
 		g_strlcat(fields, field_esc, len);
 
 		if (l->next)
-			/* not addding ';' after last addr field */
+			/* not adding ';' after last addr field */
 			g_strlcat(fields, ";", len);
 	}
 
Signature · 1 line
1.6.3.3
#2 lore raw

PATCH 3/4 Code clean-up: Remove magic number indicating size of buffer

This patch removes "magic number" indicating buffer's size in "vcard_printf_number" function and replace it by value defined under LEN_MAX. Now it would be consistent with the rest of code, since all functions from vcard_prinf_* family use LEN_MAX to indicate size of buffer which may store some vCard's field content.

---
 plugins/vcard.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
plugins/vcard.c +1 -1
index ca3a052..901a2ac 100644
@@ -406,7 +406,7 @@ static void vcard_printf_number(GString *vcards, uint8_t format,
 					enum phonebook_number_type category)
 {
 	const char *intl = "", *category_string = "";
-	char buf[128], field[LEN_MAX];
+	char buf[LEN_MAX], field[LEN_MAX];
 
 	/* TEL is a mandatory field, include even if empty */
 	if (!number || !strlen(number) || !type) {
Signature · 1 line
1.6.3.3
#3 lore raw

PATCH 4/4 Code clean-up: Simplify vCard's phone number printing

Previously, it was trynig to create string (by snprintf function and stored in "buf" buffer) containing "%s" formatting piece for "vcard_printf" function.
In this case "\%" is not valid escape sequence (it is "%%" for percent character) - backslash is ignored, so sequence "\%s" is treated as "%s" and replaced by string for "number" field when snprintf function is executed. Hence "vcard_printf" function has nothing to do with "number" field, since "buf" does not contain any "%s" formatting sequence.

This patch make simplification for printing phone number field by avoiding storing formatting pieces (for instance "%%s"). Now string for phone number field is stored directly in "field" buffer (common with Quoted Printable encoding) and simply passed to "vcard_printf" function.

---
 plugins/vcard.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
plugins/vcard.c +3 -5
index 901a2ac..5b581fb 100644
@@ -450,17 +450,15 @@ static void vcard_printf_number(GString *vcards, uint8_t format,
 	if ((type == TYPE_INTERNATIONAL) && (number[0] != '+'))
 		intl = "+";
 
+	snprintf(field, sizeof(field), "%s%s", intl, number);
+
 	if (select_qp_encoding(format, number, NULL)) {
 		snprintf(buf, sizeof(buf), "TEL;%s", category_string);
-		snprintf(field, sizeof(field), "%s%s", intl, number);
 		vcard_qp_print_encoded(vcards, buf, field, NULL);
 		return;
 	}
 
-	snprintf(buf, sizeof(buf), "TEL;%s:%s\%s", category_string,
-								intl, number);
-
-	vcard_printf(vcards, buf, number);
+	vcard_printf(vcards, "TEL;%s:%s", category_string, field);
 }
 
 static void vcard_printf_tag(GString *vcards, uint8_t format,
Signature · 1 line
1.6.3.3
#4 lore raw
In reply to Rafal Michalski

Hi Rafal,

Quoted 5 lines · Rafal Michalski

This patch removes unnecessary empty lines.

---
 plugins/phonebook-tracker.c |    1 -
 plugins/vcard.c             |    1 -
 2 files changed, 0 insertions(+), 2 deletions(-)

All four patches applied. Thanks.

Johan