#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,
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;
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];
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;
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;
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;
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;