summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2016-01-25 13:58:57 +0100
committerAleksander Morgado <aleksander@aleksander.es>2016-01-25 14:00:29 +0100
commit20b85ba47ef8e8ad9f830a25c5aa57a98eb7d961 (patch)
treec482124ced0976e2b3deea0f1fdbc91ce3a6428b
parentf722c07c2ead619e00cd24dbbd082f3a25474520 (diff)
downloadModemManager-20b85ba47ef8e8ad9f830a25c5aa57a98eb7d961.tar.gz
telit: minor coding style fixes
(cherry picked from commit 3911ea5a0f6b26e12a3586c75d72bb2c5820e3c1)
-rw-r--r--plugins/telit/mm-broadband-modem-telit.c2
-rw-r--r--plugins/telit/mm-modem-helpers-telit.c37
-rw-r--r--plugins/telit/tests/test-mm-modem-helpers-telit.c18
3 files changed, 30 insertions, 27 deletions
diff --git a/plugins/telit/mm-broadband-modem-telit.c b/plugins/telit/mm-broadband-modem-telit.c
index 2e09ac740..77b180034 100644
--- a/plugins/telit/mm-broadband-modem-telit.c
+++ b/plugins/telit/mm-broadband-modem-telit.c
@@ -104,7 +104,7 @@ modem_load_supported_bands (MMIfaceModem *self,
{
LoadSupportedBandsContext *ctx;
- ctx = g_slice_new0(LoadSupportedBandsContext);
+ ctx = g_slice_new0 (LoadSupportedBandsContext);
ctx->self = g_object_ref (self);
ctx->mm_modem_is_2g = mm_iface_modem_is_2g (ctx->self);
diff --git a/plugins/telit/mm-modem-helpers-telit.c b/plugins/telit/mm-modem-helpers-telit.c
index f28788781..91609f2b7 100644
--- a/plugins/telit/mm-modem-helpers-telit.c
+++ b/plugins/telit/mm-modem-helpers-telit.c
@@ -26,9 +26,6 @@
#include "mm-modem-helpers.h"
#include "mm-modem-helpers-telit.h"
-#define EMPTY_STRING ""
-
-
/*****************************************************************************/
/* +CSIM response parser */
@@ -168,7 +165,7 @@ mm_telit_parse_supported_bands_response (const gchar *response,
end:
if (!ret && bands != NULL)
- g_array_free(bands, TRUE);
+ g_array_free (bands, TRUE);
if(match_info)
g_match_info_free (match_info);
@@ -198,14 +195,14 @@ mm_telit_get_2g_mm_bands (GMatchInfo *match_info,
match_str = g_match_info_fetch_named (match_info, "Bands2G");
- if (match_str == NULL || g_strcmp0(match_str, EMPTY_STRING) == 0) {
+ if (match_str == NULL || match_str[0] == '\0') {
g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Could not find 2G band flags from response");
ret = FALSE;
goto end;
}
- flags = g_array_new (FALSE, FALSE, sizeof(guint));
+ flags = g_array_new (FALSE, FALSE, sizeof (guint));
if (!mm_telit_get_band_flags_from_string (match_str, &flags, error)) {
ret = FALSE;
@@ -213,7 +210,9 @@ mm_telit_get_2g_mm_bands (GMatchInfo *match_info,
}
for (i = 0; i < flags->len; i++) {
- guint flag = g_array_index (flags, guint, i);
+ guint flag;
+
+ flag = g_array_index (flags, guint, i);
if (!mm_telit_update_band_array (flag, map, bands, error)) {
ret = FALSE;
goto end;
@@ -265,17 +264,16 @@ mm_telit_get_3g_mm_bands (GMatchInfo *match_info,
{ BND_FLAG_UNKNOWN, {}},
};
-
match_str = g_match_info_fetch_named (match_info, "Bands3G");
- if (match_str == NULL || g_strcmp0(match_str, EMPTY_STRING) == 0) {
+ if (match_str == NULL || match_str[0] == '\0') {
g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Could not find 3G band flags from response");
ret = FALSE;
goto end;
}
- flags = g_array_new (FALSE, FALSE, sizeof(guint));
+ flags = g_array_new (FALSE, FALSE, sizeof (guint));
if (!mm_telit_get_band_flags_from_string (match_str, &flags, error)) {
ret = FALSE;
@@ -283,7 +281,9 @@ mm_telit_get_3g_mm_bands (GMatchInfo *match_info,
}
for (i = 0; i < flags->len; i++) {
- guint flag = g_array_index (flags, guint, i);
+ guint flag;
+
+ flag = g_array_index (flags, guint, i);
if (!mm_telit_update_band_array (flag, map, bands, error)) {
ret = FALSE;
goto end;
@@ -311,12 +311,11 @@ mm_telit_get_4g_mm_bands(GMatchInfo *match_info,
gchar *match_str = NULL;
guint i;
guint max_value;
-
gchar **tokens;
match_str = g_match_info_fetch_named (match_info, "Bands4G");
- if (match_str == NULL || g_strcmp0(match_str, EMPTY_STRING) == 0) {
+ if (match_str == NULL || match_str[0] == '\0') {
g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Could not find 4G band flags from response");
ret = FALSE;
@@ -332,12 +331,12 @@ mm_telit_get_4g_mm_bands(GMatchInfo *match_info,
goto end;
}
- sscanf(tokens[1], "%d", &max_value);
+ sscanf (tokens[1], "%d", &max_value);
- for(i = 0; max_value > 0; i++) {
+ for (i = 0; max_value > 0; i++) {
if (max_value % 2 != 0) {
band = MM_MODEM_BAND_EUTRAN_I + i;
- g_array_append_val(*bands, band);
+ g_array_append_val (*bands, band);
}
max_value = max_value >> 1;
}
@@ -351,6 +350,7 @@ end:
return ret;
}
+
gboolean
mm_telit_bands_contains (GArray *mm_bands, const MMModemBand mm_band)
{
@@ -403,7 +403,7 @@ mm_telit_get_band_flags_from_string (const gchar *flag_str,
guint flag;
guint i;
- if (g_strcmp0(flag_str, "") == 0) {
+ if (flag_str == NULL || flag_str[0] == '\0') {
g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"String is empty, no band flags to parse");
return FALSE;
@@ -443,6 +443,3 @@ mm_telit_get_band_flags_from_string (const gchar *flag_str,
return TRUE;
}
-
-
-
diff --git a/plugins/telit/tests/test-mm-modem-helpers-telit.c b/plugins/telit/tests/test-mm-modem-helpers-telit.c
index 708477910..857b93f42 100644
--- a/plugins/telit/tests/test-mm-modem-helpers-telit.c
+++ b/plugins/telit/tests/test-mm-modem-helpers-telit.c
@@ -26,7 +26,7 @@
#include "mm-modem-helpers-telit.h"
typedef struct {
- gchar* response;
+ gchar *response;
gint result;
} CSIMResponseTest;
@@ -137,8 +137,11 @@ test_parse_band_flag_str (void) {
g_assert_true (res);
for (j = 0; j < band_flag_test[i].band_flags_len; j++) {
- guint ref = band_flag_test[i].band_flags[j];
- guint cur = g_array_index (band_flags, guint, j);
+ guint ref;
+ guint cur;
+
+ ref = band_flag_test[i].band_flags[j];
+ cur = g_array_index (band_flags, guint, j);
g_assert_true (ref == cur);
}
@@ -221,12 +224,15 @@ test_parse_supported_bands_response (void) {
for (j = 0; j < supported_band_mapping_tests[i].mm_bands_len; j++) {
- MMModemBand ref = supported_band_mapping_tests[i].mm_bands[j];
- MMModemBand cur = g_array_index (bands, MMModemBand, j);
+ MMModemBand ref;
+ MMModemBand cur;
+
+ ref = supported_band_mapping_tests[i].mm_bands[j];
+ cur = g_array_index (bands, MMModemBand, j);
g_assert_cmpint (cur, ==, ref);
}
- g_assert_cmpint(bands->len, ==, supported_band_mapping_tests[i].mm_bands_len);
+ g_assert_cmpint (bands->len, ==, supported_band_mapping_tests[i].mm_bands_len);
g_array_free (bands, FALSE);
bands = NULL;