From f796175a28a22221dc812c88dd4843a5e4cfa09f Mon Sep 17 00:00:00 2001 From: Reinhard Prix Date: Thu, 18 Jul 2019 17:19:40 +0000 Subject: [PATCH 1/4] MakeSFTs.c: fix sprintf size bug (warning thanks to gcc-8.3.0) --- lalapps/src/pulsar/MakeSFTs/MakeSFTs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lalapps/src/pulsar/MakeSFTs/MakeSFTs.c b/lalapps/src/pulsar/MakeSFTs/MakeSFTs.c index 3b2db0ad14..f4ebc5a80a 100644 --- a/lalapps/src/pulsar/MakeSFTs/MakeSFTs.c +++ b/lalapps/src/pulsar/MakeSFTs/MakeSFTs.c @@ -302,7 +302,7 @@ void mkSFTFilename(CHAR *sftFilename, CHAR *site, CHAR *numSFTs, CHAR *ifo, CHAR /* 01/09/06 gam; move filename1 to filename2 */ void mvFilenames(CHAR *filename1, CHAR *filename2) { - CHAR mvFilenamesCommand[512]; + CHAR mvFilenamesCommand[512+4]; sprintf(mvFilenamesCommand,"mv %s %s",filename1,filename2); if ( system(mvFilenamesCommand) ) XLALPrintError ("system() returned non-zero status\n"); } From 9d5f835b5281ff2765e933a23c5eb4b493a06884 Mon Sep 17 00:00:00 2001 From: Reinhard Prix Date: Thu, 4 Apr 2019 08:08:49 +0200 Subject: [PATCH 2/4] DetResponseTest.c: fix warning (for Debian buster build) --- lal/test/tools/DetResponseTest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lal/test/tools/DetResponseTest.c b/lal/test/tools/DetResponseTest.c index 14906933df..77d0ad0b2c 100644 --- a/lal/test/tools/DetResponseTest.c +++ b/lal/test/tools/DetResponseTest.c @@ -2628,7 +2628,7 @@ BOOLEAN passed_special_locations_tests_p(LALStatus UNUSED *status) char *laldr_strlcpy(char *dst, const char *src, size_t len) { - char *retval = strncpy(dst, src, len); + char *retval = strncpy(dst, src, len-1); if (verbose_level & 8) { printf("sizeof(dst) = %zu\n", sizeof(dst)); From 19e6169176a66da4b422c7e27847f8b76ea5ada3 Mon Sep 17 00:00:00 2001 From: Reinhard Prix Date: Wed, 19 Feb 2020 17:39:11 +0100 Subject: [PATCH 3/4] XLALAdd[Type]TimeSeries(): add sample-alignment safety check - when adding timeseries, make sure the corresponding time-samples align (within 10eps), otherwise throw an error - the current behavior of silently rounding to the nearest bin is scientifically unsafe --- lal/lib/tools/TimeSeries_source.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lal/lib/tools/TimeSeries_source.c b/lal/lib/tools/TimeSeries_source.c index fdf550a400..49b9922f03 100644 --- a/lal/lib/tools/TimeSeries_source.c +++ b/lal/lib/tools/TimeSeries_source.c @@ -154,14 +154,20 @@ SERIESTYPE *ASERIES ( XLALPrintError("%s(): incompatible sample periods\n", __func__); XLAL_ERROR_NULL(XLAL_EDATA); } + REAL8 i0 = fabs(Delta_epoch / arg1->deltaT); + REAL8 bin_mismatch = fabs(i0 - round(i0)) / (i0 >= 1 ? i0 : 1.0); + if ( bin_mismatch > 10 * LAL_REAL8_EPS ) { + XLALPrintError("%s(): incompatible start-times, bins misaligned by %.5g deltaT\n", __func__, i0 - round(i0) ); + XLAL_ERROR_NULL(XLAL_EDATA); + } /* set start indexes */ if(Delta_epoch >= 0) { - i = floor(Delta_epoch / arg1->deltaT + 0.5); + i = round(Delta_epoch / arg1->deltaT); j = 0; } else { i = 0; - j = floor(-Delta_epoch / arg2->deltaT + 0.5); + j = round(-Delta_epoch / arg2->deltaT); } /* add arg2 to arg1, adjusting the units */ From 4ee8eb6fe951b94d0650e9353fe4e677954b0341 Mon Sep 17 00:00:00 2001 From: Reinhard Prix Date: Wed, 19 Feb 2020 17:51:35 +0100 Subject: [PATCH 4/4] XLALCWMakeFakeData(): ensure transient signals are added sample aligned - ensure transient signal start-time is aligned to closest timeseries sample before adding to ensure arbitrary phase shifts - fixes #76 --- lalpulsar/lib/CWMakeFakeData.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lalpulsar/lib/CWMakeFakeData.c b/lalpulsar/lib/CWMakeFakeData.c index 4653138f03..d3d783342f 100644 --- a/lalpulsar/lib/CWMakeFakeData.c +++ b/lalpulsar/lib/CWMakeFakeData.c @@ -296,9 +296,12 @@ XLALCWMakeFakeData ( SFTVector **SFTvect, signalStartGPS = firstGPS; } else if ( t0 >= lastGPS_REAL8 ) { signalStartGPS = lastGPS; - } - else { - signalStartGPS.gpsSeconds = t0; + } else { // firstGPS < t0 < lastGPS: + // make sure signal start-time is an integer multiple of deltaT from timeseries start + // to allow safe adding of resulting signal timeseries + REAL8 offs0_aligned = round ( (t0 - firstGPS_REAL8) * fSamp ) / fSamp; + signalStartGPS = firstGPS; + XLALGPSAdd( &signalStartGPS, offs0_aligned ); } // use earliest possible end-time: min(t1,lastGPS), but not earlier than firstGPS