diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2019-01-02 10:26:19 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2019-01-30 12:10:03 +0100 |
commit | 8b9053822b28023eb10e3d5e83a3c9a829da7a63 (patch) | |
tree | be92ce34c60a36774e7cc1857f61cd8a02b444c5 | |
parent | 36b5e1ee2029f2aa6cd189918d61153d913415a5 (diff) |
ublox: fix loop looking for a specific 4g band value
We cannot have the ubandsel value comparision inside the for(;;) stop
conditions, because that would mean the loop would stop whenever the
comparison fails. We want to look for a value, so we need to loop the
whole array and stop once we find it only.
-rw-r--r-- | plugins/ublox/mm-modem-helpers-ublox.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/plugins/ublox/mm-modem-helpers-ublox.c b/plugins/ublox/mm-modem-helpers-ublox.c index 28fa120d..0da30993 100644 --- a/plugins/ublox/mm-modem-helpers-ublox.c +++ b/plugins/ublox/mm-modem-helpers-ublox.c @@ -1208,13 +1208,18 @@ append_bands (GArray *bands, band = MM_MODEM_BAND_UNKNOWN; if (mode & MM_MODEM_MODE_4G) { - for (j = 0; ubandsel_value == num_bands_4g[j].num && j < G_N_ELEMENTS (num_bands_4g); j++) { - for (k = 0; k < 5; k++) { - band = num_bands_4g[j].band[k]; - for (x = 0; (band_configuration[i].bands_4g[x] == band) && (x < G_N_ELEMENTS (band_configuration[i].bands_4g)); x++) { - g_array_append_val (bands, band); - break; + for (j = 0; j < G_N_ELEMENTS (num_bands_4g); j++) { + if (ubandsel_value == num_bands_4g[j].num) { + for (k = 0; k < 5; k++) { + band = num_bands_4g[j].band[k]; + for (x = 0; x < G_N_ELEMENTS (band_configuration[i].bands_4g); x++) { + if (band_configuration[i].bands_4g[x] == band) { + g_array_append_val (bands, band); + break; + } + } } + break; } } } |