# HG changeset patch
# User Jan Mulder <jlmulder@xs4all.nl>
# Date 1553164919 -3600
# Node ID c853f5d23bb7e47fa57d2041431d1281e68eedb9
# Parent  2885628ab3ba453ff61cf518df0766021bc032f4
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>

diff -r 2885628ab3ba -r c853f5d23bb7 Discovery/Src/data_exchange_main.c
--- 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));