1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-06-16 01:59:58 +00:00

Fix defects detected by Coverity Scan

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

View File

@ -186,18 +186,15 @@ const int MAXPRNGAL = 36; //!< max satellite PRN numbe
const int NSATGAL = (MAXPRNGAL - MINPRNGAL + 1); //!< number of Galileo satellites const int NSATGAL = (MAXPRNGAL - MINPRNGAL + 1); //!< number of Galileo satellites
const int NSYSGAL = 1; const int NSYSGAL = 1;
const int MAXPRNQZS = 199; //!< max satellite PRN number of QZSS
const int MINPRNQZS = 193; //!< min satellite PRN number of QZSS
#ifdef ENAQZS #ifdef ENAQZS
const int MINPRNQZS = 193; //!< min satellite PRN number of QZSS
const int MAXPRNQZS = 199; //!< max satellite PRN number of QZSS
const int MINPRNQZS_S = 183; //!< min satellite PRN number of QZSS SAIF const int MINPRNQZS_S = 183; //!< min satellite PRN number of QZSS SAIF
const int MAXPRNQZS_S = 189; //!< max satellite PRN number of QZSS SAIF const int MAXPRNQZS_S = 189; //!< max satellite PRN number of QZSS SAIF
const int NSATQZS = (MAXPRNQZS - MINPRNQZS + 1); //!< number of QZSS satellites const int NSATQZS = (MAXPRNQZS - MINPRNQZS + 1); //!< number of QZSS satellites
const int NSYSQZS = 1; const int NSYSQZS = 1;
#else #else
const int MINPRNQZS = 0;
const int MAXPRNQZS = 0;
const int MINPRNQZS_S = 0; const int MINPRNQZS_S = 0;
const int MAXPRNQZS_S = 0;
const int NSATQZS = 0; const int NSATQZS = 0;
const int NSYSQZS = 0; const int NSYSQZS = 0;
#endif #endif
@ -215,26 +212,22 @@ const int NSATBDS = 0;
const int NSYSBDS = 0; const int NSYSBDS = 0;
#endif #endif
const int MINPRNIRN = 1; //!< min satellite sat number of IRNSS
const int MAXPRNIRN = 7; //!< max satellite sat number of IRNSS
#ifdef ENAIRN #ifdef ENAIRN
const int MINPRNIRN = 1; //!< min satellite sat number of IRNSS
const int MAXPRNIRN = 7; //!< max satellite sat number of IRNSS
const int NSATIRN = (MAXPRNIRN - MINPRNIRN + 1); //!< number of IRNSS satellites const int NSATIRN = (MAXPRNIRN - MINPRNIRN + 1); //!< number of IRNSS satellites
const int NSYSIRN = 1; const int NSYSIRN = 1;
#else #else
const int MINPRNIRN = 0;
const int MAXPRNIRN = 0;
const int NSATIRN = 0; const int NSATIRN = 0;
const int NSYSIRN = 0; const int NSYSIRN = 0;
#endif #endif
const int MINPRNLEO = 1; //!< min satellite sat number of LEO
const int MAXPRNLEO = 10; //!< max satellite sat number of LEO */
#ifdef ENALEO #ifdef ENALEO
const int MINPRNLEO = 1; //!< min satellite sat number of LEO
const int NSATLEO = 10; //!< max satellite sat number of LEO
const int NSATLEO = (MAXPRNLEO - MINPRNLEO + 1); //!< number of LEO satellites const int NSATLEO = (MAXPRNLEO - MINPRNLEO + 1); //!< number of LEO satellites
const int NSYSLEO = 1; const int NSYSLEO = 1;
#else #else
const int MINPRNLEO = 0;
const int MAXPRNLEO = 0;
const int NSATLEO = 0; const int NSATLEO = 0;
const int NSYSLEO = 0; const int NSYSLEO = 0;
#endif #endif

View File

@ -274,19 +274,19 @@ int satno(int sys, int prn)
} }
return NSATGPS + NSATGLO + NSATGAL + prn - MINPRNQZS + 1; return NSATGPS + NSATGLO + NSATGAL + prn - MINPRNQZS + 1;
case SYS_BDS: case SYS_BDS:
if (prn < MINPRNBDS || MAXPRNBDS < prn) if (MAXPRNBDS < prn)
{ {
return 0; return 0;
} }
return NSATGPS + NSATGLO + NSATGAL + NSATQZS + prn - MINPRNBDS + 1; return NSATGPS + NSATGLO + NSATGAL + NSATQZS + prn - MINPRNBDS + 1;
case SYS_IRN: case SYS_IRN:
if (prn < MINPRNIRN || MAXPRNIRN < prn) if (MAXPRNIRN < prn)
{ {
return 0; return 0;
} }
return NSATGPS + NSATGLO + NSATGAL + NSATQZS + NSATBDS + prn - MINPRNIRN + 1; return NSATGPS + NSATGLO + NSATGAL + NSATQZS + NSATBDS + prn - MINPRNIRN + 1;
case SYS_LEO: case SYS_LEO:
if (prn < MINPRNLEO || MAXPRNLEO < prn) if (MAXPRNLEO < prn)
{ {
return 0; return 0;
} }
@ -378,7 +378,7 @@ int satsys(int sat, int *prn)
int satid2no(const char *id) int satid2no(const char *id)
{ {
int sys; int sys;
int prn = 0; int prn;
char code; char code;
if (sscanf(id, "%d", &prn) == 1) if (sscanf(id, "%d", &prn) == 1)
@ -443,6 +443,11 @@ int satid2no(const char *id)
default: default:
return 0; return 0;
} }
if (prn <= 0 || prn > MAXSAT)
{
return 0;
}
return satno(sys, prn); return satno(sys, prn);
} }