Fix some defects detected by coverity scan

This commit is contained in:
Carles Fernandez 2017-06-06 17:49:40 +02:00
parent 14b242eafa
commit 5231c9e94b
1 changed files with 29 additions and 18 deletions

View File

@ -567,13 +567,20 @@ void setcodepri(int sys, int freq, const char *pri)
trace(3, "setcodepri : sys=%d freq=%d pri=%s\n", sys, freq, pri);
if (freq <= 0 || MAXFREQ<freq) return;
if (sys&SYS_GPS) strcpy(codepris[0][freq-1], pri);
if (sys&SYS_GLO) strcpy(codepris[1][freq-1], pri);
if (sys&SYS_GAL) strcpy(codepris[2][freq-1], pri);
if (sys&SYS_QZS) strcpy(codepris[3][freq-1], pri);
if (sys&SYS_SBS) strcpy(codepris[4][freq-1], pri);
if (sys&SYS_BDS) strcpy(codepris[5][freq-1], pri);
if (sys&SYS_IRN) strcpy(codepris[6][freq-1], pri);
if(strlen(pri) < 17)
{
if (sys&SYS_GPS) strcpy(codepris[0][freq-1], pri);
if (sys&SYS_GLO) strcpy(codepris[1][freq-1], pri);
if (sys&SYS_GAL) strcpy(codepris[2][freq-1], pri);
if (sys&SYS_QZS) strcpy(codepris[3][freq-1], pri);
if (sys&SYS_SBS) strcpy(codepris[4][freq-1], pri);
if (sys&SYS_BDS) strcpy(codepris[5][freq-1], pri);
if (sys&SYS_IRN) strcpy(codepris[6][freq-1], pri);
}
else
{
trace(1, "pri array is too long");
}
}
@ -2133,7 +2140,7 @@ int readngspcv(const char *file, pcvs_t *pcvs)
{
FILE *fp;
static const pcv_t pcv0 = {0, {}, {}, {0,0}, {0,0}, {{},{}}, {{},{}} };
pcv_t pcv;
pcv_t pcv = {0, {}, {}, {0,0}, {0,0}, {{},{}}, {{},{}} };
double neu[3];
int n = 0;
char buff[256];
@ -2322,7 +2329,8 @@ pcv_t *searchpcv(int sat, const char *type, gtime_t time,
trace(3, "searchpcv: sat=%2d type=%s\n", sat, type);
if (sat) { /* search satellite antenna */
if (sat)
{ /* search satellite antenna */
for (i = 0; i<pcvs->n; i++)
{
pcv = pcvs->pcv+i;
@ -2331,10 +2339,11 @@ pcv_t *searchpcv(int sat, const char *type, gtime_t time,
if (pcv->te.time != 0 && timediff(pcv->te, time)<0.0) continue;
return pcv;
}
}
}
else
{
strcpy(buff, type);
if(strlen(type) < MAXANT +1 ) strcpy(buff, type);
else trace(1, "type array is too long");
for (p = strtok(buff, " "); p && n<2; p = strtok(NULL, " ")) types[n++] = p;
if (n <= 0) return NULL;
@ -3013,7 +3022,8 @@ void traceopen(const char *file)
reppath(file, path, time, "", "");
if (!*path || !(fp_trace = fopen(path, "w"))) fp_trace = stderr;
strcpy(file_trace, file);
if (strlen(file) < 1025) strcpy(file_trace, file);
else trace(1, "file array is too long");
tick_trace = tickget();
time_trace = time;
initlock(&lock_trace);
@ -3228,7 +3238,8 @@ void createdir(const char *path)
if (!(p = strrchr(buff, FILEPATHSEP))) return;
*p = '\0';
mkdir(buff, 0777);
if(mkdir(buff, 0777) == 0) {}
else trace(1, "Error creating folder");
}
@ -3966,10 +3977,10 @@ int rtk_uncompress(const char *file, char *uncfile)
sprintf(cmd, "tar -C \"%s\" -xf \"%s\"", dir, tmpfile);
if (execcmd(cmd))
{
if (stat) remove(tmpfile);
if (stat) if(remove(tmpfile) != 0) trace(1, "Error removing file");
return -1;
}
if (stat) remove(tmpfile);
if (stat) if(remove(tmpfile) != 0) trace(1, "Error removing file");
stat = 1;
}
/* extract hatanaka-compressed file by cnx2rnx */
@ -3983,10 +3994,10 @@ int rtk_uncompress(const char *file, char *uncfile)
if (execcmd(cmd))
{
remove(uncfile);
if (stat) remove(tmpfile);
if (stat) if(remove(tmpfile) != 0) trace(1, "Error removing file");
return -1;
}
if (stat) remove(tmpfile);
if (stat) if(remove(tmpfile) != 0) trace(1, "Error removing file");
stat = 1;
}
trace(3, "rtk_uncompress: stat=%d\n", stat);
@ -4040,7 +4051,7 @@ int expath(const char *path, char *paths[], int nmax)
{
if (strcmp(paths[i], paths[j])>0)
{
strcpy(tmp, paths[i]);
if(strlen(paths[i]) < 1025) strcpy(tmp, paths[i]);
strcpy(paths[i], paths[j]);
strcpy(paths[j], tmp);
}