From 53ec944deb3d1a85ee85a7871d5ad0c8ced00644 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 3 Oct 2012 22:37:13 +0300 Subject: [PATCH] alert: Fix various coding style issues --- profiles/alert/server.c | 48 +++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/profiles/alert/server.c b/profiles/alert/server.c index 35f500432..0c1717650 100644 --- a/profiles/alert/server.c +++ b/profiles/alert/server.c @@ -49,8 +49,8 @@ #include "textfile.h" #include "attio.h" -#define PHONE_ALERT_STATUS_SVC_UUID 0x180E -#define ALERT_NOTIF_SVC_UUID 0x1811 +#define PHONE_ALERT_STATUS_SVC_UUID 0x180E +#define ALERT_NOTIF_SVC_UUID 0x1811 #define ALERT_STATUS_CHR_UUID 0x2A3F #define RINGER_CP_CHR_UUID 0x2A40 @@ -62,9 +62,9 @@ #define SUPP_NEW_ALERT_CAT_CHR_UUID 0x2A47 #define SUPP_UNREAD_ALERT_CAT_CHR_UUID 0x2A48 -#define ALERT_OBJECT_PATH "/org/bluez" -#define ALERT_INTERFACE "org.bluez.Alert" -#define ALERT_AGENT_INTERFACE "org.bluez.AlertAgent" +#define ALERT_OBJECT_PATH "/org/bluez" +#define ALERT_INTERFACE "org.bluez.Alert" +#define ALERT_AGENT_INTERFACE "org.bluez.AlertAgent" /* Maximum length for "Text String Information" */ #define NEW_ALERT_MAX_INFO_SIZE 18 @@ -255,7 +255,7 @@ static gboolean pasp_category(const char *category) } static gboolean valid_description(const char *category, - const char *description) + const char *description) { if (!pasp_category(category)) { if (strlen(description) >= NEW_ALERT_MAX_INFO_SIZE) @@ -548,6 +548,7 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg, struct alert_data *alert; uint16_t count; unsigned int i; + size_t dlen; if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category, DBUS_TYPE_UINT16, &count, DBUS_TYPE_STRING, @@ -577,27 +578,28 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg, return btd_error_invalid_args(msg); } + dlen = strlen(description); + for (i = 0; i < G_N_ELEMENTS(anp_categories); i++) { - if (g_str_equal(anp_categories[i], category)) { - uint8_t value[NEW_ALERT_CHR_MAX_VALUE_SIZE + 1]; - size_t dlen = strlen(description); - uint8_t *ptr = value; + uint8_t value[NEW_ALERT_CHR_MAX_VALUE_SIZE + 1]; + uint8_t *ptr = value; + + if (!g_str_equal(anp_categories[i], category)) + continue; - memset(value, 0, sizeof(value)); + memset(value, 0, sizeof(value)); - *ptr++ = 2; /* Attribute value size */ - *ptr++ = i; /* Category ID (mandatory) */ - *ptr++ = count; /* Number of New Alert (mandatory) */ - /* Text String Information (optional) */ - strncpy((char *) ptr, description, + *ptr++ = 2; /* Attribute value size */ + *ptr++ = i; /* Category ID (mandatory) */ + *ptr++ = count; /* Number of New Alert (mandatory) */ + /* Text String Information (optional) */ + strncpy((char *) ptr, description, NEW_ALERT_MAX_INFO_SIZE - 1); - if (dlen > 0) - *value += dlen + 1; + if (dlen > 0) + *value += dlen + 1; - g_slist_foreach(alert_adapters, update_new_alert, - value); - } + g_slist_foreach(alert_adapters, update_new_alert, value); } if (pasp_category(category)) @@ -818,7 +820,7 @@ static uint8_t supp_new_alert_cat_read(struct attribute *a, gpointer user_data) { struct btd_adapter *adapter = user_data; - uint8_t value[] = {0x00, 0x00}; + uint8_t value[] = { 0x00, 0x00 }; DBG("a = %p", a); @@ -834,7 +836,7 @@ static uint8_t supp_unread_alert_cat_read(struct attribute *a, gpointer user_data) { struct btd_adapter *adapter = user_data; - uint8_t value[] = {0x00, 0x00}; + uint8_t value[] = { 0x00, 0x00 }; DBG("a = %p", a); -- 2.47.3