changeset 51:8f8ea3a32e82

Resolved warnings pointing to possible invalid memory access
author Ideenmodellierer
date Tue, 31 Jul 2018 22:28:21 +0200
parents 6310a27fd6d3
children d24395f7c939
files Common/Inc/data_exchange.h Common/Src/calc_crush.c Discovery/Src/buehlmann.c Discovery/Src/data_exchange_main.c Discovery/Src/gfx_fonts.c Discovery/Src/simulation.c Discovery/Src/t7.c Discovery/Src/tComm.c Discovery/Src/tMenu.c Discovery/Src/tMenuDeco.c Discovery/Src/vpm.c
diffstat 11 files changed, 31 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/Common/Inc/data_exchange.h	Mon Jul 30 11:37:39 2018 +0200
+++ b/Common/Inc/data_exchange.h	Tue Jul 31 22:28:21 2018 +0200
@@ -140,7 +140,7 @@
 		// wireless data
 		SDataWireless wireless_data[4];
 		// PIC data
-		uint8_t button_setting[3];
+		uint8_t button_setting[4]; /* see dependency to SLiveData->buttonPICdata */
 		uint8_t SPARE1;
 		//debug
 		uint32_t pressure_uTick;
--- a/Common/Src/calc_crush.c	Mon Jul 30 11:37:39 2018 +0200
+++ b/Common/Src/calc_crush.c	Tue Jul 31 22:28:21 2018 +0200
@@ -724,8 +724,8 @@
 void vpm_init(SVpm* pVpm, short conservatism, short repetitive_dive, long seconds_since_last_dive)
 {
 
-	float critical_radius_n2_microns,
-		critical_radius_he_microns;
+	float critical_radius_n2_microns = 0.82;		 /* be conservative in case of an unexpected parameter value */
+	float critical_radius_he_microns = 0.72;
 	float initial_critical_radius_n2[16];
 	float initial_critical_radius_he[16];
 	int i = 0;
@@ -758,6 +758,10 @@
 			critical_radius_n2_microns=0.82;
 			critical_radius_he_microns=0.72;
 			break;
+		default:
+			critical_radius_n2_microns=0.82;
+			critical_radius_he_microns=0.72;
+			break;
 	}
 
 	 for (i = 0; i < 16; ++i) {
--- a/Discovery/Src/buehlmann.c	Mon Jul 30 11:37:39 2018 +0200
+++ b/Discovery/Src/buehlmann.c	Tue Jul 31 22:28:21 2018 +0200
@@ -1,5 +1,5 @@
-/*	getrennte Gase für die verschiedenen Modi
-		um Gaswechsel Einträge zu vereinfachen
+/*	getrennte Gase f�r die verschiedenen Modi
+		um Gaswechsel Eintr�ge zu vereinfachen
 		das heisst:
 		oc == bailout in cc mode
 */
@@ -545,7 +545,7 @@
 int ascend_with_all_gaschanges(float pressure_decrease)
 {
 	float pressureTop, pressureTop_tmp, pressureBottom, pressureChange, ascendrate_in_seconds_for_one_bar, pressure_difference;
-	int time_for_ascend;
+	int time_for_ascend = 0;
 	int seconds;
 	int i;
 
--- a/Discovery/Src/data_exchange_main.c	Mon Jul 30 11:37:39 2018 +0200
+++ b/Discovery/Src/data_exchange_main.c	Tue Jul 31 22:28:21 2018 +0200
@@ -738,7 +738,7 @@
 
 	
 	// wireless - �ltere daten aufr�umen
-	for(int i=0;i<=(2*NUM_GASES+1);i++)
+	for(int i=0;i<(2*NUM_GASES+1);i++)
 	{
 		if(pStateReal->lifeData.bottle_bar[i])
 		{
@@ -815,7 +815,9 @@
 	
 	/*	uint8_t IAmStolenPleaseKillMe;
 	 */
-	if(settingsGetPointer()->IAmStolenPleaseKillMe > 3)
+	pSettings = settingsGetPointer();
+
+	if(pSettings->IAmStolenPleaseKillMe > 3)
 	{
 		pSettings->salinity = 0;
 		dataIn.data[dataIn.boolPressureData].surface_mbar = 999;
@@ -823,7 +825,7 @@
 		dataIn.mode = MODE_DIVE;
 	}
 
-	pSettings = settingsGetPointer();
+
 	ambient = dataIn.data[dataIn.boolPressureData].pressure_mbar / 1000.0f;
 	surface = dataIn.data[dataIn.boolPressureData].surface_mbar / 1000.0f;
 
--- a/Discovery/Src/gfx_fonts.c	Mon Jul 30 11:37:39 2018 +0200
+++ b/Discovery/Src/gfx_fonts.c	Tue Jul 31 22:28:21 2018 +0200
@@ -22,7 +22,9 @@
 # 	define INCLUDE_FONTS_BINARY
 #endif
 
+#ifndef INCLUDE_FONTS_BINARY
 #define INCLUDE_FONTS_BINARY 1
+#endif
 
 #ifdef INCLUDE_FONTS_BINARY
 
--- a/Discovery/Src/simulation.c	Mon Jul 30 11:37:39 2018 +0200
+++ b/Discovery/Src/simulation.c	Tue Jul 31 22:28:21 2018 +0200
@@ -679,7 +679,10 @@
 
     SDiveState * pDiveState = &stateSim;
 
-    uint8_t depthDecoNext, depthLast, depthSecond, depthInc;
+    uint8_t depthDecoNext = 0;
+    uint8_t depthLast = 0;
+    uint8_t depthSecond = 0;
+	uint8_t depthInc = 0;
 
     for(int i = 1; i < 6; i++)
         outputConsumptionTempFloat[i] = 0;
--- a/Discovery/Src/t7.c	Mon Jul 30 11:37:39 2018 +0200
+++ b/Discovery/Src/t7.c	Tue Jul 31 22:28:21 2018 +0200
@@ -1417,7 +1417,7 @@
     char text[256];
     uint16_t textpointer = 0;
     int16_t start;
-    uint8_t lineCountCustomtext;
+    uint8_t lineCountCustomtext = 0;
     int16_t shiftWindowY0;
     RTC_DateTypeDef Sdate;
     RTC_TimeTypeDef Stime;
--- a/Discovery/Src/tComm.c	Mon Jul 30 11:37:39 2018 +0200
+++ b/Discovery/Src/tComm.c	Tue Jul 31 22:28:21 2018 +0200
@@ -1351,7 +1351,7 @@
     uint8_t serialBuffer[10];
     uint32_t length1, length2, lengthCompare, offsetCompare, ByteCompareStatus;
     uint32_t lengthTotal, offsetTotal, pruefsumme, pruefsummeCalc;
-    uint32_t checksum, checksumCalc;
+    uint32_t checksum, checksumCalc = 0;
     uint8_t id;
     const uint8_t id_Region1_firmware = 0xFF;
     const uint8_t id_RTE = 0xFE;
--- a/Discovery/Src/tMenu.c	Mon Jul 30 11:37:39 2018 +0200
+++ b/Discovery/Src/tMenu.c	Tue Jul 31 22:28:21 2018 +0200
@@ -421,7 +421,9 @@
 
 void findValidPosition(uint8_t *pageOuput, uint8_t *lineOutput)
 {
-    uint8_t page, line, first;
+    uint8_t page = 0;
+    uint8_t line = 0;
+    uint8_t first = 0;
 
     *pageOuput = 0;
     *lineOutput = 0;
@@ -606,7 +608,7 @@
 
 void tM_refresh_live_content(void)
 {
-    uint8_t page;
+    uint8_t page = 0;
     char text[MAX_PAGE_TEXTSIZE];
     char subtext[MAX_PAGE_TEXTSIZE];
     uint16_t tabPosition;
--- a/Discovery/Src/tMenuDeco.c	Mon Jul 30 11:37:39 2018 +0200
+++ b/Discovery/Src/tMenuDeco.c	Tue Jul 31 22:28:21 2018 +0200
@@ -67,6 +67,9 @@
         case DIVEMODE_Apnea:
             divemode = TXT_Apnoe;
             break;
+        default :
+        	divemode = TXT_OpenCircuit;
+        	break;
         }
         textPointer += snprintf(&text[textPointer], 60,\
             "%c"
--- a/Discovery/Src/vpm.c	Mon Jul 30 11:37:39 2018 +0200
+++ b/Discovery/Src/vpm.c	Tue Jul 31 22:28:21 2018 +0200
@@ -2059,7 +2059,7 @@
 //	float weighted_allowable_gradient;
     float initial_helium_pressure[16];
  /* by hw */
-    float initial_CNS;
+    float initial_CNS = gCNS_VPM;
 
     //static float time_counter;
     short i;