summaryrefslogtreecommitdiffstats
path: root/src/call-forwarding.c
diff options
context:
space:
mode:
authorOleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>2012-02-06 14:33:55 +0200
committerDenis Kenzior <denkenz@gmail.com>2012-02-22 04:24:18 -0600
commit12076487aa37281d6adc9deb18c84de36cac198b (patch)
tree8b59f5752c713658cf43bc819684f2cf6859c79c /src/call-forwarding.c
parent07adce67e01bed16eb58da1928688e1288a86b0c (diff)
downloadofono-12076487aa37281d6adc9deb18c84de36cac198b.tar.bz2
call-forwarding: Refactoring of is_cfu_enabled()
This also removes the need for uninitialized_var() macro.
Diffstat (limited to 'src/call-forwarding.c')
-rw-r--r--src/call-forwarding.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/src/call-forwarding.c b/src/call-forwarding.c
index 731a38a7..8b8d5a80 100644
--- a/src/call-forwarding.c
+++ b/src/call-forwarding.c
@@ -36,14 +36,17 @@
#include "common.h"
#include "simutil.h"
-#define uninitialized_var(x) x = x
-
#define CALL_FORWARDING_FLAG_CACHED 0x1
#define CALL_FORWARDING_FLAG_CPHS_CFF 0x2
/* According to 27.007 Spec */
#define DEFAULT_NO_REPLY_TIMEOUT 20
+#define is_cfu_enabled(_cf) \
+({ \
+ cf_find_unconditional(_cf) ? TRUE : FALSE; \
+})
+
enum call_forwarding_type {
CALL_FORWARDING_TYPE_UNCONDITIONAL = 0,
CALL_FORWARDING_TYPE_BUSY = 1,
@@ -221,8 +224,8 @@ static void sim_cphs_cff_update_cb(int ok, void *data)
ofono_info("Failed to update EFcphs-cff");
}
-static gboolean is_cfu_enabled(struct ofono_call_forwarding *cf,
- struct ofono_call_forwarding_condition **out)
+static struct ofono_call_forwarding_condition *cf_find_unconditional(
+ struct ofono_call_forwarding *cf)
{
GSList *l = cf->cf_conditions[CALL_FORWARDING_TYPE_UNCONDITIONAL];
struct ofono_call_forwarding_condition *cond;
@@ -237,21 +240,16 @@ static gboolean is_cfu_enabled(struct ofono_call_forwarding *cf,
if (cond->cls > BEARER_CLASS_VOICE)
continue;
- if (out)
- *out = cond;
-
- return TRUE;
+ return cond;
}
- return FALSE;
+ return NULL;
}
static void sim_set_cf_indicator(struct ofono_call_forwarding *cf)
{
- gboolean cfu_voice;
- struct ofono_call_forwarding_condition *uninitialized_var(cond);
-
- cfu_voice = is_cfu_enabled(cf, &cond);
+ struct ofono_call_forwarding_condition *cfu_voice =
+ cf_find_unconditional(cf);
if (cf->cfis_record_id) {
unsigned char data[16];
@@ -263,15 +261,15 @@ static void sim_set_cf_indicator(struct ofono_call_forwarding *cf)
data[0] = 0x01;
if (cfu_voice) {
- number_len = strlen(cond->phone_number.number);
+ number_len = strlen(cfu_voice->phone_number.number);
/* CFU indicator Status - Voice */
data[1] = 0x01;
number_len = (number_len + 1) / 2;
data[2] = number_len + 1;
- data[3] = cond->phone_number.type;
+ data[3] = cfu_voice->phone_number.type;
- sim_encode_bcd_number(cond->phone_number.number,
+ sim_encode_bcd_number(cfu_voice->phone_number.number,
data + 4);
} else {
data[1] = 0x00;
@@ -317,7 +315,7 @@ static void set_new_cond_list(struct ofono_call_forwarding *cf,
if ((cf->flags & CALL_FORWARDING_FLAG_CPHS_CFF) ||
cf->cfis_record_id > 0)
- old_cfu = is_cfu_enabled(cf, NULL);
+ old_cfu = is_cfu_enabled(cf);
else
old_cfu = FALSE;
@@ -432,7 +430,7 @@ static void set_new_cond_list(struct ofono_call_forwarding *cf,
if ((cf->flags & CALL_FORWARDING_FLAG_CPHS_CFF) ||
cf->cfis_record_id > 0)
- new_cfu = is_cfu_enabled(cf, NULL);
+ new_cfu = is_cfu_enabled(cf);
else
new_cfu = FALSE;
@@ -523,7 +521,7 @@ static DBusMessage *cf_get_properties_reply(DBusMessage *msg,
if ((cf->flags & CALL_FORWARDING_FLAG_CPHS_CFF) ||
cf->cfis_record_id > 0)
- status = is_cfu_enabled(cf, NULL);
+ status = is_cfu_enabled(cf);
else
status = FALSE;