Commit 5508da14 authored by John Douglas Veitch's avatar John Douglas Veitch
Browse files

Fix compilation warnings in lalapps/pulsar/HeterodyneSearch

 - sprintf -> snprintf
 - fall-through in switch blocks
parent 654bd598
......@@ -181,7 +181,7 @@ int main( int argc, char **argv ){
// add "NAME" attribute
PulsarAddParam( pulparams[numpulsars], "NAME", psrname, PULSARTYPE_string_t );
sprintf(outputFilename, "%s/SplInter_%s_%s",inputParams.outputdir,psrname,
snprintf(outputFilename, sizeof(outputFilename), "%s/SplInter_%s_%s",inputParams.outputdir,psrname,
splParams.detector.frDetector.prefix);
outputfilenames = XLALAppendString2Vector(outputfilenames, outputFilename);
......@@ -230,14 +230,14 @@ int main( int argc, char **argv ){
}
/* load all types of ephemeris files, as uses little RAM/computational effort, and different parfiles may use a combination */
sprintf(earthfile200, "%s/earth00-19-DE200.dat.gz",inputParams.ephemdir);
sprintf(sunfile200, "%s/sun00-19-DE200.dat.gz",inputParams.ephemdir);
sprintf(earthfile405, "%s/earth00-19-DE405.dat.gz",inputParams.ephemdir);
sprintf(sunfile405, "%s/sun00-19-DE405.dat.gz",inputParams.ephemdir);
sprintf(earthfile414, "%s/earth00-19-DE414.dat.gz",inputParams.ephemdir);
sprintf(sunfile414, "%s/sun00-19-DE414.dat.gz",inputParams.ephemdir);
sprintf(earthfile421, "%s/earth00-19-DE421.dat.gz",inputParams.ephemdir);
sprintf(sunfile421, "%s/sun00-19-DE421.dat.gz",inputParams.ephemdir);
snprintf(earthfile200, sizeof(earthfile200), "%s/earth00-19-DE200.dat.gz",inputParams.ephemdir);
snprintf(sunfile200, sizeof(sunfile200), "%s/sun00-19-DE200.dat.gz",inputParams.ephemdir);
snprintf(earthfile405, sizeof(earthfile405), "%s/earth00-19-DE405.dat.gz",inputParams.ephemdir);
snprintf(sunfile405, sizeof(sunfile405), "%s/sun00-19-DE405.dat.gz",inputParams.ephemdir);
snprintf(earthfile414, sizeof(earthfile414), "%s/earth00-19-DE414.dat.gz",inputParams.ephemdir);
snprintf(sunfile414, sizeof(sunfile414), "%s/sun00-19-DE414.dat.gz",inputParams.ephemdir);
snprintf(earthfile421, sizeof(earthfile421), "%s/earth00-19-DE421.dat.gz",inputParams.ephemdir);
snprintf(sunfile421, sizeof(sunfile421), "%s/sun00-19-DE421.dat.gz",inputParams.ephemdir);
edat200 = XLALMalloc(sizeof(*edat200));
edat405 = XLALMalloc(sizeof(*edat405));
......@@ -245,8 +245,8 @@ int main( int argc, char **argv ){
edat421 = XLALMalloc(sizeof(*edat421));
/* Load time correction files. */
sprintf(timefileTDB,"%s/tdb_2000-2019.dat.gz",inputParams.ephemdir);
sprintf(timefileTE405, "%s/te405_2000-2019.dat.gz",inputParams.ephemdir);
snprintf(timefileTDB, sizeof(timefileTDB), "%s/tdb_2000-2019.dat.gz",inputParams.ephemdir);
snprintf(timefileTE405, sizeof(timefileTE405), "%s/te405_2000-2019.dat.gz",inputParams.ephemdir);
/* read in ephemeris files */
edat200 = XLALInitBarycenter(earthfile200, sunfile200);
......@@ -390,8 +390,8 @@ int main( int argc, char **argv ){
if ( sftlalcache == NULL ){
CHAR cacheFile[FILENAME_MAXLEN], cacheFileCheck[FILENAME_MAXLEN];
if(inputParams.cacheDir){
sprintf(cacheFile,"list:%s/Segment_%d-%d.sftcache",inputParams.filePattern,(INT4)ROUND(startt),(INT4)ROUND(endt));
sprintf(cacheFileCheck,"%s/Segment_%d-%d.sftcache",inputParams.filePattern,(INT4)ROUND(startt),(INT4)ROUND(endt));
snprintf(cacheFile, sizeof(cacheFile), "list:%s/Segment_%d-%d.sftcache",inputParams.filePattern,(INT4)ROUND(startt),(INT4)ROUND(endt));
snprintf(cacheFileCheck, sizeof(cacheFileCheck), "%s/Segment_%d-%d.sftcache",inputParams.filePattern,(INT4)ROUND(startt),(INT4)ROUND(endt));
}
else{
sprintf(cacheFile,"%s",inputParams.filePattern);
......@@ -1378,8 +1378,10 @@ void get_input_args(InputParams *inputParams, int argc, char *argv[]){
break;
case '?':
fprintf(stderr, "unknown error while parsing options\n" );
break;
default:
fprintf(stderr, "unknown error while parsing options\n" );
break;
}
}
}
......
......@@ -167,7 +167,7 @@ int main(int argc, char **argv){
continue;
}
else{
sprintf(parname,"%s/%s", inputs.pulsarDir, pulsars[h]->d_name);
snprintf(parname,sizeof(parname),"%s/%s", inputs.pulsarDir, pulsars[h]->d_name);
fprintf(stderr, "%s\n", parname);
FILE *inject;
......@@ -400,6 +400,7 @@ void ReadInput(InputParams *inputParams, int argc, char *argv[]){
else
fprintf(stderr, "Error parsing option %s with argument %s\n",
long_options[option_index].name, LALoptarg );
break;
case 'h': /* help message */
fprintf(stderr, USAGE, program);
exit(0);
......@@ -437,8 +438,10 @@ void ReadInput(InputParams *inputParams, int argc, char *argv[]){
break;
case '?':
fprintf(stderr, "unknown error while parsing options\n" );
break;
default:
fprintf(stderr, "unknown error while parsing options\n" );
break;
}
}
......
......@@ -877,6 +877,7 @@ the pulsar parameter file */
else
fprintf(stderr, "Error parsing option %s with argument %s\n",
long_options[option_index].name, LALoptarg );
break;
case 'h': /* help message */
fprintf(stderr, USAGE, program);
exit(0);
......@@ -1045,8 +1046,10 @@ the pulsar parameter file */
break;
case '?':
fprintf(stderr, "unknown error while parsing options\n" );
break;
default:
fprintf(stderr, "unknown error while parsing options\n" );
break;
}
}
......
......@@ -227,7 +227,7 @@ INT4 main(INT4 argc, CHAR *argv[]){
output.psr = inputs.pulsar;
output.dob = inputs.dob; /* set degree of belief for UL */
output.outPost = inputs.outputPost;
sprintf(outputFile, "%s/evidence_%s", output.outputDir, output.psr);
snprintf(outputFile, sizeof(outputFile), "%s/evidence_%s", output.outputDir, output.psr);
/*==========================================================================*/
if( inputs.mcmc.doMCMC == 0 ){
......@@ -294,7 +294,7 @@ defined!\n");
for( i = 0 ; i < numDets ; i++ ){
/*============================ GET DATA ==================================*/
/* get detector B_ks data file in form finehet_JPSR_DET */
sprintf(dataFile, "%s/data%s/finehet_%s_%s", inputs.inputDir, dets[i],
snprintf(dataFile, sizeof(dataFile), "%s/data%s/finehet_%s_%s", inputs.inputDir, dets[i],
inputs.pulsar, dets[i]);
/* open data file */
......@@ -758,9 +758,11 @@ W:y:g:G:K:N:X:O:J:M:{:(r:fFR><)[:" ;
else
fprintf(stderr, "Error passing option %s with argument %s\n",
long_options[option_index].name, LALoptarg);
break;
case 'h': /* help message */
printf("Usage: %s [options]\n\n%s%s\n", program, USAGE1, USAGE2);
exit(0);
break;
case 'R': /* verbose */
inputParams->verbose = 1;
break;
......@@ -938,8 +940,10 @@ W:y:g:G:K:N:X:O:J:M:{:(r:fFR><)[:" ;
break;
case '?':
fprintf(stderr, "Unknown error while parsing options\n");
break;
default:
fprintf(stderr, "Unknown error while parsing options\n");
break;
}
}
......@@ -2459,9 +2463,9 @@ paramData ) ) == NULL ){
/* open output file */
if( input.mcmc.outputBI == 0 )
sprintf(outFile, "%s/MCMCchain_%s_%s", input.outputDir, input.pulsar, det);
snprintf(outFile, sizeof(outFile), "%s/MCMCchain_%s_%s", input.outputDir, input.pulsar, det);
else{ /* append number of burn in steps to the file name */
sprintf(outFile, "%s/MCMCchain_%s_%s_burn_in_%d", input.outputDir,
snprintf(outFile, sizeof(outFile), "%s/MCMCchain_%s_%s_burn_in_%d", input.outputDir,
input.pulsar, det, input.mcmc.burnIn );
}
......
......@@ -144,6 +144,7 @@ int main( int argc, char *argv[] ){
break;
else
fprintf(stderr, "Error parsing option %s with argument %s\n", long_options[option_index].name, LALoptarg );
break;
case 'h': /* help message */
fprintf(stderr, USAGE, program);
exit(0);
......@@ -161,12 +162,15 @@ int main( int argc, char *argv[] ){
break;
case 'g': /* the gps time */
gpstime = atof(LALoptarg);
break;
case '?':
fprintf(stderr, "Unknown error while parsing options\n" );
exit(0);
break;
default:
fprintf(stderr, "Unknown error while parsing options\n" );
exit(0);
break;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment