mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Init every struct sample with default values
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
This commit is contained in:
		
							parent
							
								
									1f8506ce64
								
							
						
					
					
						commit
						adbc71f9da
					
				
					 4 changed files with 9 additions and 4 deletions
				
			
		|  | @ -114,6 +114,7 @@ struct divecomputer *fake_dc(struct divecomputer *dc, bool alloc) | |||
| 	static struct sample fake_samples[6]; | ||||
| 	static struct divecomputer fakedc; | ||||
| 	struct sample *fake = fake_samples; | ||||
| 	int i; | ||||
| 
 | ||||
| 	fakedc = (*dc); | ||||
| 	if (alloc) | ||||
|  | @ -129,6 +130,10 @@ struct divecomputer *fake_dc(struct divecomputer *dc, bool alloc) | |||
| 
 | ||||
| 	memset(fake, 0, sizeof(fake_samples)); | ||||
| 	fake[5].time.seconds = max_t; | ||||
| 	for (i = 0; i < 6; i++) { | ||||
| 		fake_samples[i].bearing.degrees = -1; | ||||
| 		fake_samples[i].ndl.seconds = -1; | ||||
| 	} | ||||
| 	if (!max_t || !max_d) | ||||
| 		return &fakedc; | ||||
| 
 | ||||
|  |  | |||
|  | @ -1727,7 +1727,7 @@ static void merge_one_sample(struct sample *sample, int time, struct divecompute | |||
| { | ||||
| 	int last = dc->samples - 1; | ||||
| 	if (last >= 0) { | ||||
| 		static struct sample surface; | ||||
| 		static struct sample surface = { .bearing.degrees = -1, .ndl.seconds = -1 }; | ||||
| 		struct sample *prev = dc->sample + last; | ||||
| 		int last_time = prev->time.seconds; | ||||
| 		int last_depth = prev->depth.mm; | ||||
|  | @ -1772,7 +1772,7 @@ static void merge_samples(struct divecomputer *res, struct divecomputer *a, stru | |||
| 
 | ||||
| 	for (;;) { | ||||
| 		int at, bt; | ||||
| 		struct sample sample; | ||||
| 		struct sample sample = { .bearing.degrees = -1, .ndl.seconds = -1 }; | ||||
| 
 | ||||
| 		if (!res) | ||||
| 			return; | ||||
|  |  | |||
|  | @ -350,7 +350,7 @@ static void save_samples(struct membuffer *b, struct dive *dive, struct divecomp | |||
| 	int nr; | ||||
| 	int o2sensor; | ||||
| 	struct sample *s; | ||||
| 	struct sample dummy = {}; | ||||
| 	struct sample dummy = { .bearing.degrees = -1, .ndl.seconds = -1 }; | ||||
| 
 | ||||
| 	/* Is this a CCR dive with the old-style "o2pressure" sensor? */ | ||||
| 	o2sensor = legacy_format_o2pressures(dive, dc); | ||||
|  |  | |||
|  | @ -364,7 +364,7 @@ static void save_samples(struct membuffer *b, struct dive *dive, struct divecomp | |||
| 	int nr; | ||||
| 	int o2sensor; | ||||
| 	struct sample *s; | ||||
| 	struct sample dummy = {}; | ||||
| 	struct sample dummy = { .bearing.degrees = -1, .ndl.seconds = -1 }; | ||||
| 
 | ||||
| 	/* Set up default pressure sensor indexes */ | ||||
| 	o2sensor = legacy_format_o2pressures(dive, dc); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue