1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-14 04:00:34 +00:00

Fix defects detected by coverity scan

This commit is contained in:
Carles Fernandez 2017-06-06 18:27:54 +02:00
parent 5231c9e94b
commit 0047595373
5 changed files with 23 additions and 10 deletions

View File

@ -92,7 +92,7 @@ double var_uraeph(int ura)
2.4, 3.4, 4.85, 6.85, 9.65, 13.65, 24.0, 48.0, 96.0, 192.0, 384.0, 768.0, 1536.0,
3072.0, 6144.0
};
return ura < 0 || 15 < ura ? std::pow(6144.0, 2.0) : std::pow(ura_value[ura], 2.0);
return ura < 0 || 14 < ura ? std::pow(6144.0, 2.0) : std::pow(ura_value[ura], 2.0);
}

View File

@ -364,7 +364,8 @@ int valsol(const double *azel, const int *vsat, int n,
const prcopt_t *opt, const double *v, int nv, int nx,
char *msg)
{
double azels[MAXOBS*2], dop[4], vv;
double azels[MAXOBS*2] = {0};
double dop[4], vv;
int i, ns;
trace(3, "valsol : n=%d nv=%d\n", n, nv);

View File

@ -461,7 +461,11 @@ int fix_amb_ILS(rtk_t *rtk, int *sat1, int *sat2, int *NW, int n)
sat2[m] = sat2[i];
NW[m++] = NW[i];
}
if (m<3) return 0;
if (m<3)
{
free(B1); free(N1); free(D); free(E); free(Q); free(NC);
return 0;
}
/* covariance of narrow-lane ambiguities */
matmul("TN", m, rtk->nx, rtk->nx, 1.0, D, rtk->P, 0.0, E);
@ -471,9 +475,14 @@ int fix_amb_ILS(rtk_t *rtk, int *sat1, int *sat2, int *NW, int n)
if ((info = lambda(m, 2, B1, Q, N1, s)))
{
trace(2, "lambda error: info=%d\n", info);
free(B1); free(N1); free(D); free(E); free(Q); free(NC);
return 0;
}
if (s[0] <= 0.0)
{
free(B1); free(N1); free(D); free(E); free(Q); free(NC);
return 0;
}
if (s[0] <= 0.0) return 0;
rtk->sol.ratio = (float)(MIN_PPP(s[1]/s[0], 999.9));

View File

@ -3234,12 +3234,12 @@ void createdir(const char *path)
char buff[1024], *p;
//tracet(3, "createdir: path=%s\n", path);
strcpy(buff, path);
if(strlen(path) < 1025) strcpy(buff, path);
else trace(1, "path is too long");
if (!(p = strrchr(buff, FILEPATHSEP))) return;
*p = '\0';
if(mkdir(buff, 0777) == 0) {}
else trace(1, "Error creating folder");
if(mkdir(buff, 0777) != 0) trace(1, "Error creating folder");
}
@ -3257,7 +3257,9 @@ int repstr(char *str, const char *pat, const char *rep)
r += sprintf(r, "%s", rep);
}
if (p <= str) return 0;
strcpy(r, p);
if(strlen(p) < 1025 ) strcpy(r, p);
else trace(1, "pat array is too long");
strcpy(str, buff);
return 1;
}
@ -3945,7 +3947,8 @@ int rtk_uncompress(const char *file, char *uncfile)
trace(3, "rtk_uncompress: file=%s\n", file);
strcpy(tmpfile, file);
if(strlen(file) < 1025) strcpy(tmpfile, file);
else trace(1, "file array is too long");
if (!(p = strrchr(tmpfile, '.'))) return 0;
/* uncompress by gzip */

View File

@ -271,7 +271,7 @@ int decode_nmeagga(char **val, int n, sol_t *sol)
/* decode nmea ---------------------------------------------------------------*/
int decode_nmea(char *buff, sol_t *sol)
{
char *p,*q,*val[MAXFIELD];
char *p, *q, *val[MAXFIELD] = {0};
int n = 0;
trace(4,"decode_nmea: buff=%s\n",buff);