1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-06-18 11:09:56 +00:00

Fix warning -Wstringop-truncation raised by GCC 11

This commit is contained in:
Carles Fernandez 2021-01-28 14:09:33 +01:00
parent c5916d05c3
commit bd87e4e9b7
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
2 changed files with 20 additions and 3 deletions

View File

@ -31,6 +31,7 @@
#include "rtklib_rtkcmn.h"
#include <glog/logging.h>
#include <cassert>
#include <cstring>
#include <dirent.h>
#include <iostream>
@ -377,7 +378,7 @@ int satsys(int sat, int *prn)
int satid2no(const char *id)
{
int sys;
int prn;
int prn = 0;
char code;
if (sscanf(id, "%d", &prn) == 1)
@ -1417,6 +1418,7 @@ void matfprint(const double A[], int n, int m, int p, int q, FILE *fp)
}
}
void matsprint(const double A[], int n, int m, int p, int q, std::string &buffer)
{
int i;
@ -2689,6 +2691,20 @@ void addpcv(const pcv_t *pcv, pcvs_t *pcvs)
}
/* strncpy without truncation ------------------------------------------------*/
char *strncpy_no_trunc(char *out, size_t outsz, const char *in, size_t insz)
{
assert(outsz > 0);
while (--outsz > 0 && insz > 0 && *in)
{
*out++ = *in++;
insz--;
}
*out = 0;
return out;
}
/* read ngs antenna parameter file -------------------------------------------*/
int readngspcv(const char *file, pcvs_t *pcvs)
{
@ -2718,7 +2734,7 @@ int readngspcv(const char *file, pcvs_t *pcvs)
if (++n == 1)
{
pcv = pcv0;
strncpy(pcv.type, buff, 61);
strncpy_no_trunc(pcv.type, 61, buff, 256);
pcv.type[61] = '\0';
}
else if (n == 2)

View File

@ -59,6 +59,7 @@
#define GNSS_SDR_RTKLIB_RTKCMN_H
#include "rtklib.h"
#include <cstddef>
#include <string>
@ -96,7 +97,7 @@
} \
while (0)
char *strncpy_no_trunc(char *out, size_t outsz, const char *in, size_t insz);
void fatalerr(const char *format, ...);
int satno(int sys, int prn);
int satsys(int sat, int *prn);