aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-sysmo/calib_file.c
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-16 18:36:44 +0200
commitfbf97e35ebf985eafcf79cc5db2598a7535108d4 (patch)
treeab3443ab4a87acb85b13467adb93d142474f27e6 /src/osmo-bts-sysmo/calib_file.c
parent91d204e2db8f53a6ae4827ecc4b0ccb0137375d0 (diff)
calib: The call to fscanf can fail and we should check the return value
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
Diffstat (limited to 'src/osmo-bts-sysmo/calib_file.c')
-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 84de31fb..8098da2f 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;
}