mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-14 12:10:34 +00:00
Fix warning -Wstringop-truncation raised by GCC 11
This commit is contained in:
parent
c5916d05c3
commit
bd87e4e9b7
@ -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)
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user