[med-svn] [SCM] aghermann branch, master, updated. 3b87b4f8039ed683022537a0599b7dea069974d2

Andrei Zavada johnhommer at gmail.com
Sun Sep 30 22:40:51 UTC 2012


The following commit has been merged in the master branch:
commit 8b0c401e5d0235fe6de7ef0a4e9d0a0683519f83
Author: Andrei Zavada <johnhommer at gmail.com>
Date:   Sat Sep 29 02:22:02 2012 +0300

    recover from possible off-by-one page count in CSCourse ctor

diff --git a/src/expdesign/recording.cc b/src/expdesign/recording.cc
index bd6934b..a2412fd 100644
--- a/src/expdesign/recording.cc
+++ b/src/expdesign/recording.cc
@@ -10,7 +10,6 @@
  *         License:  GPL
  */
 
-#include <cassert>
 #include <list>
 #include <valarray>
 
@@ -74,7 +73,7 @@ explain_status( int code)
 
 
 agh::CSCourse::
-CSCourse( CSubject& J, const string& d, const sigfile::SChannel& h,
+CSCourse (CSubject& J, const string& d, const sigfile::SChannel& h,
 	  const SSCourseParamSet& params)
       : SSCourseParamSet (params),
 	_status (0),
@@ -108,8 +107,11 @@ CSCourse( CSubject& J, const string& d, const sigfile::SChannel& h,
 			sigfile::metric_method(params._profile_type), F.subject(), F.session(), F.episode(),
 			F.pages(), pz-pa, ctime( &F.start_time()));
 
-		// this is not really a reportable/recoverable circumstance, so just abort
-		assert (pz - pa == (int)F.pages());
+		if ( pz - pa != (int)F.pages() ) {
+			fprintf( stderr, "CSCourse::CSCourse(): correct end page to match page count in EDF: %d->%zu\n",
+				 pz, pa + F.pages());
+			pz = pa + F.pages();
+		}
 		_pages_in_bed += (pz-pa);
 
 		if ( pa < 0 ) {
@@ -141,7 +143,7 @@ CSCourse( CSubject& J, const string& d, const sigfile::SChannel& h,
 
 
 agh::CSCourse::
-CSCourse( CRecording& M,
+CSCourse (CRecording& M,
 	  const SSCourseParamSet& params)
       : SSCourseParamSet (params),
 	_status (0),
@@ -159,8 +161,11 @@ CSCourse( CRecording& M,
 		sigfile::metric_method(params._profile_type), M.F().subject(), M.F().session(), M.F().episode(),
 		M.F().pages(), pz-pa, ctime( &M.F().start_time()));
 
-	// this is not really a reportable/recoverable circumstance, so just abort
-	assert (pz - pa == (int)M.F().pages());
+	if ( pz - pa != (int)M.F().pages() ) {
+		fprintf( stderr, "CSCourse::CSCourse(): correct end page to match page count in EDF: %d->%zu\n",
+			 pz, pa + M.F().pages());
+		pz = pa + M.F().pages();
+	}
 	_pages_in_bed += (pz-pa);
 
 	if ( pa < 0 ) {

-- 
Sleep experiment manager



More information about the debian-med-commit mailing list