Fix warnings raised by GCC 8.1.1

This commit is contained in:
Carles Fernandez 2018-05-16 18:32:27 +02:00
parent 0d70b08288
commit 1195234df1
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
4 changed files with 86 additions and 27 deletions

View File

@ -463,14 +463,14 @@ bool rtklib_solver::get_PVT(const std::map<int, Gnss_Synchro>& gnss_observables_
unsigned int used_sats = 0;
for (unsigned int i = 0; i < MAXSAT; i++)
{
if (int vsat = rtk_.ssat[i].vsat[0] == 1) used_sats++;
if (rtk_.ssat[i].vsat[0] == 1) used_sats++;
}
double azel[used_sats * 2];
unsigned int index_aux = 0;
for (unsigned int i = 0; i < MAXSAT; i++)
{
if (int vsat = rtk_.ssat[i].vsat[0] == 1)
if (rtk_.ssat[i].vsat[0] == 1)
{
azel[2 * index_aux] = rtk_.ssat[i].azel[0];
azel[2 * index_aux + 1] = rtk_.ssat[i].azel[1];

View File

@ -130,11 +130,11 @@ double prange(const obsd_t *obs, const nav_t *nav, const double *azel,
double P1_P2 = 0.0;
double P1_C1 = 0.0;
double P2_C2 = 0.0;
//Intersignal corrections (m). See GPS IS-200 CNAV message
double ISCl1 = 0.0;
// Intersignal corrections (m). See GPS IS-200 CNAV message
//double ISCl1 = 0.0;
double ISCl2 = 0.0;
double ISCl5i = 0.0;
double ISCl5q = 0.0;
//double ISCl5q = 0.0;
double gamma_ = 0.0;
int i = 0;
int j = 1;
@ -209,10 +209,10 @@ double prange(const obsd_t *obs, const nav_t *nav, const double *azel,
if (sys == SYS_GPS)
{
ISCl1 = getiscl1(obs->sat, nav);
// ISCl1 = getiscl1(obs->sat, nav);
ISCl2 = getiscl2(obs->sat, nav);
ISCl5i = getiscl5i(obs->sat, nav);
ISCl5q = getiscl5q(obs->sat, nav);
// ISCl5q = getiscl5q(obs->sat, nav);
}
//CHECK IF IT IS STILL NEEDED

View File

@ -54,6 +54,8 @@
//#include <cstdio>
#include <dirent.h>
#include <iostream>
#include <string>
#include <sstream>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/types.h>
@ -253,11 +255,12 @@ const unsigned int tbl_CRC24Q[] = {
0x42FA2F, 0xC4B6D4, 0xC82F22, 0x4E63D9, 0xD11CCE, 0x575035, 0x5BC9C3, 0xDD8538};
extern "C" {
void dgemm_(char *, char *, int *, int *, int *, double *, double *, int *, double *, int *, double *, double *, int *);
extern void dgetrf_(int *, int *, double *, int *, int *, int *);
extern void dgetri_(int *, double *, int *, int *, double *, int *, int *);
extern void dgetrs_(char *, int *, int *, double *, int *, int *, double *, int *, int *);
extern "C"
{
void dgemm_(char *, char *, int *, int *, int *, double *, double *, int *, double *, int *, double *, double *, int *);
extern void dgetrf_(int *, int *, double *, int *, int *, int *);
extern void dgetri_(int *, double *, int *, int *, double *, int *, int *);
extern void dgetrs_(char *, int *, int *, double *, int *, int *, double *, int *, int *);
}
@ -2562,7 +2565,8 @@ void readpos(const char *file, const char *rcv, double *pos)
if (buff[0] == '%' || buff[0] == '#') continue;
if (sscanf(buff, "%lf %lf %lf %s", &poss[np][0], &poss[np][1], &poss[np][2],
str) < 4) continue;
strncpy(stas[np], str, 15);
// strncpy(stas[np], str, 15); This line triggers a warning. Replaced by:
memcpy(stas[np], str, 15 * sizeof(stas[np][0]));
stas[np++][15] = '\0';
}
fclose(fp);
@ -4264,7 +4268,17 @@ int rtk_uncompress(const char *file, char *uncfile)
dir = fname;
fname = p + 1;
}
sprintf(cmd, "tar -C \"%s\" -xf \"%s\"", dir, tmpfile);
// sprintf(cmd, "tar -C \"%s\" -xf \"%s\"", dir, tmpfile);
// NOTE: This sprintf triggers a format overflow warning. Replaced by:
std::ostringstream temp;
std::string s_aux1(dir);
std::string s_aux2(tmpfile);
temp << "tar -C " << s_aux1 << " -xf " << s_aux2;
std::string s_aux = temp.str();
int n = s_aux.length();
if (n < 2048)
for (int i = 0; i < n; i++) cmd[i] = s_aux[i];
if (execcmd(cmd))
{
if (stat)

View File

@ -64,6 +64,7 @@
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <string>
/* global options ------------------------------------------------------------*/
@ -115,7 +116,12 @@ serial_t *openserial(const char *path, int mode, char *msg)
}
parity = (char)toupper((int)parity);
sprintf(dev, "/dev/%s", port);
// sprintf(dev, "/dev/%s", port); This line triggers a warning. Replaced by:
std::string s_aux = "/dev/" + std::string(port);
s_aux.resize(128, '\0');
int n = s_aux.length();
if (n < 128)
for (int i = 0; i < n; i++) dev[i] = s_aux[i];
if ((mode & STR_MODE_R) && (mode & STR_MODE_W))
rw = O_RDWR;
@ -1224,7 +1230,11 @@ int rspntrip_s(ntrip_t *ntrip, char *msg)
else if ((p = strstr((char *)ntrip->buff, NTRIP_RSP_ERROR)))
{ /* error */
nb = ntrip->nb < MAXSTATMSG ? ntrip->nb : MAXSTATMSG;
strncpy(msg, (char *)ntrip->buff, nb);
// strncpy(msg, (char *)ntrip->buff, nb); This line triggers a warning. Replaced by;
std::string s_aux((char *)ntrip->buff);
s_aux.resize(nb, '\0');
for (int i = 0; i < nb; i++) msg[i] = s_aux[i];
msg[nb] = 0;
tracet(1, "rspntrip_s: %s nb=%d\n", msg, ntrip->nb);
ntrip->nb = 0;
@ -1380,7 +1390,11 @@ ntrip_t *openntrip(const char *path, int type, char *msg)
/* ntrip access via proxy server */
if (*proxyaddr)
{
sprintf(ntrip->url, "http://%s", tpath);
// sprintf(ntrip->url, "http://%s", tpath); This line triggers a warning. Replaced by:
std::string s_aux = "http://" + std::string(tpath);
int n = s_aux.length();
if (n < 256)
for (int k = 0; k < n; k++) ntrip->url[k] = s_aux[k];
strcpy(tpath, proxyaddr);
}
/* open tcp client stream */
@ -1545,8 +1559,17 @@ void *ftpthread(void *arg)
p++;
else
p = remote;
sprintf(local, "%s%c%s", localdir, FILEPATHSEP, p);
sprintf(errfile, "%s.err", local);
// sprintf(local, "%s%c%s", localdir, FILEPATHSEP, p); This line triggers a warning. Replaced by:
std::string s_aux = std::string(localdir) + std::to_string(FILEPATHSEP) + std::string(p);
int n = s_aux.length();
if (n < 1024)
for (int i = 0; i < n; i++) local[i] = s_aux[i];
// sprintf(errfile, "%s.err", local); This line triggers a warning. Replaced by:
std::string s_aux2 = std::string(local) + ".err";
n = s_aux2.length();
if (n < 1024)
for (int i = 0; i < n; i++) errfile[i] = s_aux2[i];
/* if local file exist, skip download */
strcpy(tmpfile, local);
@ -1574,16 +1597,35 @@ void *ftpthread(void *arg)
/* download command (ref [2]) */
if (ftp->proto == 0)
{ /* ftp */
sprintf(opt, "--ftp-user=%s --ftp-password=%s --glob=off --passive-ftp %s-t 1 -T %d -O \"%s\"",
ftp->user, ftp->passwd, proxyopt, FTP_TIMEOUT, local);
sprintf(cmd, "%s%s %s \"ftp://%s/%s\" 2> \"%s\"\n", env, FTP_CMD, opt, ftp->addr,
remote, errfile);
// sprintf(opt, "--ftp-user=%s --ftp-password=%s --glob=off --passive-ftp %s-t 1 -T %d -O \"%s\"",
// ftp->user, ftp->passwd, proxyopt, FTP_TIMEOUT, local); This line triggers a warning. Replaced by:
std::string s_aux = "--ftp-user=" + std::string(ftp->user) + " --ftp-password=" + std::string(ftp->passwd) +
" --glob=off --passive-ftp " + std::string(proxyopt) + "s-t 1 -T " + std::to_string(FTP_TIMEOUT) +
" -O \"" + std::string(local) + "\"";
int k = s_aux.length();
if (k < 2048)
for (int i = 0; i < k; i++) opt[i] = s_aux[i];
// sprintf(cmd, "%s%s %s \"ftp://%s/%s\" 2> \"%s\"\n", env, FTP_CMD, opt, ftp->addr,
// remote, errfile); This line triggers a warning. Replaced by:
std::string s_aux2 = std::string(env) + std::string(FTP_CMD) + " " + std::string(opt) + " " +
"\"ftp://" + std::string(ftp->addr) + "/" + std::string(remote) + "\" 2> \"" + std::string(errfile) + "\"\n";
k = s_aux2.length();
for (int i = 0; (i < k) && (i < 1024); i++) cmd[i] = s_aux2[i];
}
else
{ /* http */
sprintf(opt, "%s-t 1 -T %d -O \"%s\"", proxyopt, FTP_TIMEOUT, local);
sprintf(cmd, "%s%s %s \"http://%s/%s\" 2> \"%s\"\n", env, FTP_CMD, opt, ftp->addr,
remote, errfile);
// sprintf(opt, "%s-t 1 -T %d -O \"%s\"", proxyopt, FTP_TIMEOUT, local); This line triggers a warning. Replaced by:
std::string s_aux = std::string(proxyopt) + " -t 1 -T " + std::to_string(FTP_TIMEOUT) + " -O \"" + std::string(local) + "\"";
int l = s_aux.length();
for (int i = 0; (i < l) && (i < 1024); i++) opt[i] = s_aux[i];
// sprintf(cmd, "%s%s %s \"http://%s/%s\" 2> \"%s\"\n", env, FTP_CMD, opt, ftp->addr,
// remote, errfile); This line triggers a warning. Replaced by:
std::string s_aux2 = std::string(env) + std::string(FTP_CMD) + " " + std::string(opt) + " " +
"\"http://" + std::string(ftp->addr) + "/" + std::string(remote) + "\" 2> \"" + std::string(errfile) + "\"\n";
l = s_aux2.length();
for (int i = 0; (i < l) && (i < 1024); i++) cmd[i] = s_aux2[i];
}
/* execute download command */
if ((ret = execcmd(cmd)))
@ -2049,7 +2091,10 @@ int strstat(stream_t *stream, char *msg)
strlock(stream);
if (msg)
{
strncpy(msg, stream->msg, MAXSTRMSG - 1);
// strncpy(msg, stream->msg, MAXSTRMSG - 1); This line triggers a warning. Replaced by:
std::string aux_s(stream->msg);
aux_s.resize(MAXSTRMSG - 1, '0');
for (int i = 0; i < MAXSTRMSG - 1; i++) msg[i] = aux_s[i];
msg[MAXSTRMSG - 1] = '\0';
}
if (!stream->port)