Skip to content

Commit 9bda353

Browse files
author
Luís Venâncio
committed
vendor/libraries/wmm2025/GeomagnetismLibrary: Fixed compilation warnings.
1 parent 5bd61f1 commit 9bda353

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

vendor/libraries/wmm2025/GeomagnetismLibrary.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,9 +1292,13 @@ int MAG_readMagneticModel(char *filename, MAGtype_MagneticModel * MagneticModel)
12921292
MagneticModel->Secular_Var_Coeff_G[0] = 0.0;
12931293

12941294
char header_fmt[sizeof(c_str)];
1295-
snprintf(header_fmt, sizeof(header_fmt), "%%lf %%%ds %%%ds", sizeof(MagneticModel->ModelName), date_size);
1295+
snprintf(header_fmt, sizeof(header_fmt), "%%lf %%%lus %%%ds", sizeof(MagneticModel->ModelName), date_size);
12961296

1297-
fgets(c_str, sizeof(c_str), MAG_COF_File);
1297+
if (fgets(c_str, sizeof(c_str), MAG_COF_File) == NULL){
1298+
free(edit_date);
1299+
fclose(MAG_COF_File);
1300+
return FALSE;
1301+
}
12981302
sscanf(c_str, header_fmt, &epoch, MagneticModel->ModelName, edit_date);
12991303

13001304
MagneticModel->min_year = MAG_dtstr_to_dyear(edit_date);
@@ -1360,7 +1364,7 @@ int MAG_readMagneticModel_Large(char *filename, char *filenameSV, MAGtype_Magnet
13601364
FILE *MAG_COFSV_File;
13611365
char c_str[81], c_str2[81]; /* these strings are used to read a line from coefficient file */
13621366
int i, m, n, index, a, b;
1363-
double epoch, gnm, hnm, dgnm, dhnm;
1367+
double epoch = 0.0, gnm, hnm, dgnm, dhnm;
13641368
MAG_COF_File = fopen(filename, "r");
13651369
MAG_COFSV_File = fopen(filenameSV, "r");
13661370
if(MAG_COF_File == NULL || MAG_COFSV_File == NULL)
@@ -2131,13 +2135,13 @@ OUTPUT : UTMParameters : Pointer to data structure MAGtype_UTMParameters with th
21312135

21322136
double Eps, Epssq;
21332137
double Acoeff[8];
2134-
double Lam0, K0, falseE, falseN;
2138+
double Lam0 = 0.0, K0, falseE, falseN;
21352139
double K0R4, K0R4oa;
21362140
double Lambda, Phi;
21372141
int XYonly;
21382142
double X, Y, pscale, CoM;
2139-
int Zone;
2140-
char Hemisphere;
2143+
int Zone = 0;
2144+
char Hemisphere = '\0';
21412145

21422146

21432147

@@ -2854,7 +2858,7 @@ int MAG_PcupHigh(double *Pcup, double *dPcup, double x, int nMax)
28542858
*/
28552859
{
28562860
double pm2, pm1, pmm, plm, rescalem, z, scalef;
2857-
double *f1, *f2, *PreSqr;
2861+
double *f1 = NULL, *f2 = NULL, *PreSqr = NULL;
28582862
int k, kstart, m, n, NumTerms;
28592863

28602864
NumTerms = ((nMax + 1) * (nMax + 2) / 2);

0 commit comments

Comments
 (0)