mobile/gsm322.c: fix: properly print stored BA list entities

As we do iterate over all entities in the BA list, it makes more
sense to print each one separately instead of printing the last
one. Moreover, as soon as the iteration is finished, *ba points
to some zero-initialized part of memory:

  gsm322.c:5170 Write stored BA list (mcc=000 mnc=000  Marshall Islands, 000)

After this patch:

  gsm322.c:5162 Write stored BA list (mcc=250 mnc=99  Russian Federation, Beeline)
  gsm322.c:5162 Write stored BA list (mcc=250 mnc=01  Russian Federation, MegaFon)
  gsm322.c:5162 Write stored BA list (mcc=250 mnc=02  Russian Federation, MTS)
  gsm322.c:5162 Write stored BA list (mcc=544 mnc=31  Serbia, Telenor)

Change-Id: I5160492e6125401c6a1765f54d129b1f1cd503fc
This commit is contained in:
Vadim Yanitskiy 2019-02-02 11:48:07 +03:00
parent 9ec58916d9
commit f4ba6382f5
1 changed files with 6 additions and 6 deletions

View File

@ -5156,6 +5156,11 @@ int gsm322_exit(struct osmocom_ms *ms)
buf[2] = ba->mnc >> 8;
buf[3] = ba->mnc & 0xff;
LOGP(DCS, LOGL_INFO, "Write stored BA list (mcc=%s "
"mnc=%s %s, %s)\n", gsm_print_mcc(ba->mcc),
gsm_print_mnc(ba->mnc), gsm_get_mcc(ba->mcc),
gsm_get_mnc(ba->mcc, ba->mnc));
rc += fwrite(buf, 4, 1, fp);
rc += fwrite(ba->freq, sizeof(ba->freq), 1, fp);
}
@ -5163,12 +5168,7 @@ int gsm322_exit(struct osmocom_ms *ms)
}
}
if (rc == 2)
LOGP(DCS, LOGL_INFO, "Write stored BA list (mcc=%s "
"mnc=%s %s, %s)\n", gsm_print_mcc(ba->mcc),
gsm_print_mnc(ba->mnc), gsm_get_mcc(ba->mcc),
gsm_get_mnc(ba->mcc, ba->mnc));
else
if (rc != 2)
LOGP(DCS, LOGL_ERROR, "Failed to write BA list\n");
/* free lists */