diff Discovery/Src/data_exchange_main.c @ 197:c853f5d23bb7 div-fixes-cleaup-2

cleanup: fix (harmless) use before assign While looking around for possible wrong CNS values in the logbook header, I see this "interesting" thing. Simply assign the current CNS data to the global state, before using it to issue a warning. In practice, this does not fix any real bug, as the code is run very often, so the global state data is always (very) recent. It simply does not look right. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Thu, 21 Mar 2019 11:41:59 +0100
parents 8b8074080d7b
children 878dc9e0dbc5
line wrap: on
line diff
--- a/Discovery/Src/data_exchange_main.c	Wed Mar 20 16:24:10 2019 +0100
+++ b/Discovery/Src/data_exchange_main.c	Thu Mar 21 11:41:59 2019 +0100
@@ -920,6 +920,11 @@
 			pStateReal->lifeData.boolResetStopwatch = 1;
 		}
 
+		pStateReal->lifeData.cns = dataIn.data[dataIn.boolToxicData].cns;
+		pStateReal->lifeData.otu = dataIn.data[dataIn.boolToxicData].otu;
+		pStateReal->lifeData.no_fly_time_minutes = dataIn.data[dataIn.boolToxicData].no_fly_time_minutes;
+		pStateReal->lifeData.desaturation_time_minutes = dataIn.data[dataIn.boolToxicData].desaturation_time_minutes;
+
 		//End of diveMode?
 		if(pStateReal->mode == MODE_DIVE && dataIn.mode != MODE_DIVE)
 		{
@@ -990,11 +995,6 @@
 		pStateReal->compass_uTick_new = dataIn.data[dataIn.boolCompassData].compass_uTick;
 		pStateReal->compass_uTick_local_new = HAL_GetTick();
 
-	    pStateReal->lifeData.cns = dataIn.data[dataIn.boolToxicData].cns;
-		pStateReal->lifeData.otu = dataIn.data[dataIn.boolToxicData].otu;
-	    pStateReal->lifeData.no_fly_time_minutes = dataIn.data[dataIn.boolToxicData].no_fly_time_minutes;
-		pStateReal->lifeData.desaturation_time_minutes = dataIn.data[dataIn.boolToxicData].desaturation_time_minutes;
-
 		memcpy(pStateReal->lifeData.tissue_nitrogen_bar, dataIn.data[dataIn.boolTisssueData].tissue_nitrogen_bar,sizeof(pStateReal->lifeData.tissue_nitrogen_bar));
 		memcpy(pStateReal->lifeData.tissue_helium_bar, dataIn.data[dataIn.boolTisssueData].tissue_helium_bar,sizeof(pStateReal->lifeData.tissue_helium_bar));