aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-07-14 08:28:58 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-07-14 08:28:58 +0200
commitaf3a057919f6a13aa1fda8bb5eb0bbf1e859633b (patch)
tree4f319334e4e593e80d6d257c58c93309fe6fa4ed
parent1d72e1f25420ef71950fc608223bfe47277f7645 (diff)
calib: The call to fscanf can fail and we should check the return valuezecke/work/coverity-fixes
Coverity wants us to check that fscanf has scanned the amount of variables we want to have. Initialize the scan result to 0/0.0f and warn if the scan has failed. Fixes: Coverity CID 1040774, CID 1040773
-rw-r--r--src/osmo-bts-sysmo/calib_file.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/osmo-bts-sysmo/calib_file.c b/src/osmo-bts-sysmo/calib_file.c
index 84de31f..8098da2 100644
--- a/src/osmo-bts-sysmo/calib_file.c
+++ b/src/osmo-bts-sysmo/calib_file.c
@@ -120,15 +120,25 @@ static const unsigned int arrsize_by_band[] = {
static float read_float(FILE *in)
{
- float f;
- fscanf(in, "%f\n", &f);
+ int rc;
+ float f = 0.0f;
+
+ rc = fscanf(in, "%f\n", &f);
+ if (rc != 1)
+ LOGP(DL1C, LOGL_ERROR,
+ "Reading a float from calib data failed.\n");
return f;
}
static int read_int(FILE *in)
{
- int i;
- fscanf(in, "%d\n", &i);
+ int rc;
+ int i = 0;
+
+ rc = fscanf(in, "%d\n", &i);
+ if (rc != 1)
+ LOGP(DL1C, LOGL_ERROR,
+ "Reading an int from calib data failed.\n");
return i;
}