Skip to content

Commit 7ed26c9

Browse files
authored
Merge pull request #2088 from willend/main
Debugging fixes, removal of warnings
2 parents ee6fca8 + 3c65c6c commit 7ed26c9

4 files changed

Lines changed: 33 additions & 10 deletions

File tree

common/lib/share/mccode-r.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2378,9 +2378,8 @@ FILE *siminfo_init(FILE *f)
23782378
siminfo_out("end simulation\n");
23792379

23802380
}
2381-
return (siminfo_file);
2382-
23832381
); /* MPI_MASTER */
2382+
return (siminfo_file);
23842383

23852384
} /* siminfo_init */
23862385

common/lib/share/read_table-lib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ void *Table_File_List_store(t_Table *tab){
428428
s = (float*)data;
429429
dataf = (double*)malloc(sizeof(double)*nelements);
430430
if (!dataf) {
431-
fprintf(stderr, "Could not allocate data block of size %i\n", nelements);
431+
fprintf(stderr, "Could not allocate data block of size %ld\n", nelements);
432432
exit(-1);
433433
}
434434
for (i=0; i<nelements; i++)
@@ -723,7 +723,7 @@ void *Table_File_List_store(t_Table *tab){
723723
}
724724
New_Table = (double*)malloc(Length_Table*Table->columns*sizeof(double));
725725
if (!New_Table) {
726-
fprintf(stderr,"Could not allocate New_Table of size %i x %i\n", Length_Table, Table->columns);
726+
fprintf(stderr,"Could not allocate New_Table of size %ld x %ld\n", Length_Table, Table->columns);
727727
exit(-1);
728728
}
729729
for (i=0; i < Length_Table; i++)

mcstas-comps/samples/PowderN.comp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,25 @@ struct line_info_struct
304304
&& strcasecmp(ext, "res")) return infile;
305305

306306
OUTFILE = malloc(1024);
307-
if (!OUTFILE) return infile;
307+
if (!OUTFILE) {
308+
free(OUTFILE);
309+
return infile;
310+
}
308311
inpath = malloc(1024);
309-
if (!inpath) return infile;
312+
if (!inpath) {
313+
free(OUTFILE);
314+
free(inpath);
315+
return infile;
316+
}
310317

311318
// get input file path from read-table:Open_File
312319
FILE *f_infile = Open_File(infile, "r", inpath);
313-
if (!f_infile) return infile;
320+
if (!f_infile) {
321+
free(OUTFILE);
322+
free(inpath);
323+
free(f_infile);
324+
return infile;
325+
}
314326
fclose(f_infile);
315327

316328
strncpy(OUTFILE, tmpnam(NULL), 1024); // create an output temporary file name

mcstas-comps/samples/Single_crystal.comp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,25 @@ struct hkl_data
413413
&& strcasecmp(ext, "res")) return infile;
414414

415415
OUTFILE = malloc(1024);
416-
if (!OUTFILE) return infile;
416+
if (!OUTFILE) {
417+
free(OUTFILE);
418+
return infile;
419+
}
417420
inpath = malloc(1024);
418-
if (!inpath) return infile;
421+
if (!inpath) {
422+
free(OUTFILE);
423+
free(inpath);
424+
return infile;
425+
}
419426

420427
// get input file path from read-table:Open_File
421428
FILE *f_infile = Open_File(infile, "r", inpath);
422-
if (!f_infile) return infile;
429+
if (!f_infile) {
430+
free(OUTFILE);
431+
free(inpath);
432+
free(f_infile);
433+
return infile;
434+
}
423435
fclose(f_infile);
424436

425437
strncpy(OUTFILE, tmpnam(NULL), 1024); // create an output temporary file name

0 commit comments

Comments
 (0)