Fix warnings

This commit is contained in:
Carles Fernandez 2023-12-01 10:20:52 +01:00
parent 4b60f8a7f2
commit 4f36210536
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
2 changed files with 17 additions and 16 deletions

View File

@ -2983,7 +2983,7 @@ pcv_t *searchpcv(int sat, const char *type, gtime_t time,
const pcvs_t *pcvs)
{
pcv_t *pcv;
char buff[MAXANT] = "";
char buff[MAXANT + 1] = "";
char *types[2];
char *p;
int i;
@ -3730,12 +3730,12 @@ int savenav(const char *file, const nav_t *nav)
}
auto id = satno2id(nav->eph[i].sat);
fprintf(fp,
"%s,%d,%d,%d,%d,%d,%d,%d,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,"
"%s,%d,%d,%d,%d,%lld,%lld,%lld,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,"
"%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,"
"%.14E,%.14E,%.14E,%.14E,%.14E,%d,%d\n",
id.data(), nav->eph[i].iode, nav->eph[i].iodc, nav->eph[i].sva,
nav->eph[i].svh, static_cast<int>(nav->eph[i].toe.time),
static_cast<int>(nav->eph[i].toc.time), static_cast<int>(nav->eph[i].ttr.time),
nav->eph[i].svh, static_cast<int64_t>(nav->eph[i].toe.time),
static_cast<int64_t>(nav->eph[i].toc.time), static_cast<int64_t>(nav->eph[i].ttr.time),
nav->eph[i].A, nav->eph[i].e, nav->eph[i].i0, nav->eph[i].OMG0,
nav->eph[i].omg, nav->eph[i].M0, nav->eph[i].deln, nav->eph[i].OMGd,
nav->eph[i].idot, nav->eph[i].crc, nav->eph[i].crs, nav->eph[i].cuc,
@ -3751,11 +3751,11 @@ int savenav(const char *file, const nav_t *nav)
}
auto id = satno2id(nav->geph[i].sat);
fprintf(fp,
"%s,%d,%d,%d,%d,%d,%d,%d,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,"
"%s,%d,%d,%d,%d,%d,%lld,%lld,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,"
"%.14E,%.14E,%.14E,%.14E,%.14E,%.14E\n",
id.data(), nav->geph[i].iode, nav->geph[i].frq, nav->geph[i].svh,
nav->geph[i].sva, nav->geph[i].age, static_cast<int>(nav->geph[i].toe.time),
static_cast<int>(nav->geph[i].tof.time),
nav->geph[i].sva, nav->geph[i].age, static_cast<int64_t>(nav->geph[i].toe.time),
static_cast<int64_t>(nav->geph[i].tof.time),
nav->geph[i].pos[0], nav->geph[i].pos[1], nav->geph[i].pos[2],
nav->geph[i].vel[0], nav->geph[i].vel[1], nav->geph[i].vel[2],
nav->geph[i].acc[0], nav->geph[i].acc[1], nav->geph[i].acc[2],
@ -5016,7 +5016,7 @@ int rtk_uncompress(const char *file, char *uncfile)
int stat = 0;
char *p;
char cmd[2048] = "";
char tmpfile[1024] = "";
char tmpfile[1025] = "";
char buff[1024];
char *fname;
char *dir = const_cast<char *>("");
@ -5157,7 +5157,7 @@ int expath(const char *path, char *paths[], int nmax)
int i;
int j;
int n = 0;
char tmp[1024] = "";
char tmp[1025] = "";
struct dirent *d;
DIR *dp;
const char *file = path;
@ -5230,6 +5230,7 @@ int expath(const char *path, char *paths[], int nmax)
}
std::strncpy(paths[i], paths[j], 1024);
std::strncpy(paths[j], tmp, 1024);
paths[j][1023] = '\0';
}
}
}

View File

@ -81,7 +81,8 @@ serial_t *openserial(const char *path, int mode, char *msg)
char *p;
char parity = 'N';
char dev[128];
char port[128];
char port[128] = "";
port[127] = '\0';
char fctr[64] = "";
const speed_t bs[] = {
@ -105,7 +106,7 @@ serial_t *openserial(const char *path, int mode, char *msg)
}
else if (strlen(path) < 128)
{
std::strncpy(port, path, 128);
std::strncpy(port, path, 127);
port[127] = '\0';
}
@ -124,7 +125,6 @@ serial_t *openserial(const char *path, int mode, char *msg)
return nullptr;
}
parity = static_cast<char>(toupper(static_cast<int>(parity)));
std::string s_aux = "/dev/"s + std::string(port);
s_aux.resize(128, '\0');
int n = s_aux.length();
@ -705,7 +705,7 @@ void syncfile(file_t *file1, file_t *file2)
void decodetcppath(const char *path, char *addr, char *port, char *user,
char *passwd, char *mntpnt, char *str)
{
char buff[MAXSTRPATH] = "";
char buff[MAXSTRPATH + 1] = "";
char *p;
char *q;
@ -1827,7 +1827,7 @@ int statentrip(ntrip_t *ntrip)
void decodeftppath(const char *path, char *addr, char *file, char *user,
char *passwd, int *topts)
{
char buff[MAXSTRPATH] = "";
char buff[MAXSTRPATH + 1] = "";
char *p;
char *q;
@ -1896,7 +1896,7 @@ void decodeftppath(const char *path, char *addr, char *file, char *user,
p = buff;
}
std::strncpy(addr, p, 1024);
std::strncpy(addr, p, 1023);
addr[1023] = '\0';
}
@ -2254,7 +2254,7 @@ int stropen(stream_t *stream, int type, int mode, const char *path)
stream->mode = mode;
if (strlen(path) < MAXSTRPATH)
{
std::strncpy(stream->path, path, MAXSTRPATH);
std::strncpy(stream->path, path, MAXSTRPATH - 1);
stream->path[MAXSTRPATH - 1] = '\0';
}
stream->inb = stream->inr = stream->outb = stream->outr = 0;