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
This commit is contained in:
parent
1d72e1f254
commit
af3a057919
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue