From 3c27dae5e85ce3e5bf617d2f1bbc33f2addcd236 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Fri, 12 Jun 2009 19:33:55 -0500 Subject: Fixup style issues with previous MCC/MNC patch - Breakup MCC/MNC LENGTH constant - Don't hardcode numbers - Fix >80 column length - Fix test case to expect strings instead of shorts --- drivers/atmodem/network-registration.c | 35 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'drivers/atmodem') diff --git a/drivers/atmodem/network-registration.c b/drivers/atmodem/network-registration.c index 30dd0f7e..f30c41af 100644 --- a/drivers/atmodem/network-registration.c +++ b/drivers/atmodem/network-registration.c @@ -45,20 +45,19 @@ static const char *csq_prefix[] = { "+CSQ:", NULL }; struct netreg_data { gboolean supports_tech; - char mnc[OFONO_MAX_MNC_MCC_LENGTH + 1]; - char mcc[OFONO_MAX_MNC_MCC_LENGTH + 1]; + char mcc[OFONO_MAX_MCC_LENGTH + 1]; + char mnc[OFONO_MAX_MNC_LENGTH + 1]; }; static void extract_mcc_mnc(const char *str, char *mcc, char *mnc) { /* Three digit country code */ - strncpy(mcc, str, OFONO_MAX_MNC_MCC_LENGTH); - mcc[OFONO_MAX_MNC_MCC_LENGTH] = '\0'; + strncpy(mcc, str, OFONO_MAX_MCC_LENGTH); + mcc[OFONO_MAX_MCC_LENGTH] = '\0'; /* Usually a 2 but sometimes 3 digit network code */ - strncpy(mnc, str + OFONO_MAX_MNC_MCC_LENGTH, - OFONO_MAX_MNC_MCC_LENGTH); - mnc[OFONO_MAX_MNC_MCC_LENGTH] = '\0'; + strncpy(mnc, str + OFONO_MAX_MCC_LENGTH, OFONO_MAX_MNC_LENGTH); + mnc[OFONO_MAX_MNC_LENGTH] = '\0'; } static void at_creg_cb(gboolean ok, GAtResult *result, gpointer user_data) @@ -146,7 +145,7 @@ static void cops_cb(gboolean ok, GAtResult *result, gpointer user_data) dump_response("cops_cb", ok, result); decode_at_error(&error, g_at_result_final_response(result)); - if (!ok || *at->netreg->mcc == '\0' || *at->netreg->mnc == '\0') { + if (!ok || at->netreg->mcc[0] == '\0' || at->netreg->mnc[0] == '\0') { cb(&error, NULL, cbd->data); goto out; } @@ -173,11 +172,11 @@ static void cops_cb(gboolean ok, GAtResult *result, gpointer user_data) strncpy(op.name, name, OFONO_MAX_OPERATOR_NAME_LENGTH); op.name[OFONO_MAX_OPERATOR_NAME_LENGTH] = '\0'; - strncpy(op.mcc, at->netreg->mcc, OFONO_MAX_MNC_MCC_LENGTH); - op.mcc[OFONO_MAX_MNC_MCC_LENGTH] = '\0'; + strncpy(op.mcc, at->netreg->mcc, OFONO_MAX_MCC_LENGTH); + op.mcc[OFONO_MAX_MCC_LENGTH] = '\0'; - strncpy(op.mnc, at->netreg->mnc, OFONO_MAX_MNC_MCC_LENGTH); - op.mnc[OFONO_MAX_MNC_MCC_LENGTH] = '\0'; + strncpy(op.mnc, at->netreg->mnc, OFONO_MAX_MNC_LENGTH); + op.mnc[OFONO_MAX_MNC_LENGTH] = '\0'; op.status = -1; op.tech = tech; @@ -239,8 +238,8 @@ static void cops_numeric_cb(gboolean ok, GAtResult *result, gpointer user_data) return; error: - *at->netreg->mcc = '\0'; - *at->netreg->mnc = '\0'; + at->netreg->mcc[0] = '\0'; + at->netreg->mnc[0] = '\0'; } static void at_current_operator(struct ofono_modem *modem, @@ -454,12 +453,10 @@ static void at_register_manual(struct ofono_modem *modem, goto error; if (at->netreg->supports_tech && oper->tech != -1) - sprintf(buf, "AT+COPS=1,2,\"%s%s\",%1d", oper->mcc, - oper->mnc, - oper->tech); + sprintf(buf, "AT+COPS=1,2,\"%s%s\",%1d", oper->mcc, oper->mnc, + oper->tech); else - sprintf(buf, "AT+COPS=1,2,\"%s%s\"", oper->mcc, - oper->mnc); + sprintf(buf, "AT+COPS=1,2,\"%s%s\"", oper->mcc, oper->mnc); if (g_at_chat_send(at->parser, buf, none_prefix, register_cb, cbd, g_free) > 0) -- cgit v1.2.3