Skip to content

Commit

Permalink
Fix uninitialized values
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbuf committed Apr 3, 2019
1 parent 50c7a4b commit 9f4462d
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions indicators/ce.c
Expand Up @@ -202,10 +202,7 @@ struct ti_stream {
(RINGBUFFER).buffer[end_idx][1] = (MAX); \
(RINGBUFFER).buffer[end_idx][0] = (MIN); \
TI_REAL val; \
if ((RINGBUFFER).max <= (MAX)) { \
(RINGBUFFER).max = (MAX); \
(RINGBUFFER).max_idx = end_idx; \
} else if ((RINGBUFFER).max_idx == end_idx) { \
if ((RINGBUFFER).max_idx == end_idx) { \
(RINGBUFFER).max = (RINGBUFFER).buffer[0][1]; \
(RINGBUFFER).max_idx = 0; \
int j; \
Expand All @@ -215,11 +212,11 @@ struct ti_stream {
(RINGBUFFER).max_idx = j; \
} \
} \
} else if ((RINGBUFFER).max <= (MAX)) { \
(RINGBUFFER).max = (MAX); \
(RINGBUFFER).max_idx = end_idx; \
} \
if ((RINGBUFFER).min >= (MIN)) { \
(RINGBUFFER).min = (MIN); \
(RINGBUFFER).min_idx = end_idx; \
} else if ((RINGBUFFER).min_idx == end_idx) { \
if ((RINGBUFFER).min_idx == end_idx) { \
(RINGBUFFER).min = (RINGBUFFER).buffer[0][0]; \
(RINGBUFFER).min_idx = 0; \
int j; \
Expand All @@ -229,6 +226,9 @@ struct ti_stream {
(RINGBUFFER).min_idx = j; \
} \
} \
} else if ((RINGBUFFER).min >= (MIN)) { \
(RINGBUFFER).min = (MIN); \
(RINGBUFFER).min_idx = end_idx; \
} \
} while (0) \

Expand All @@ -242,6 +242,10 @@ struct ti_stream {
(RINGBUFFER).end_idx = -1; \
(RINGBUFFER).min_idx = 0; \
(RINGBUFFER).max_idx = 0; \
for (int i = 0; i < (PERIOD); ++i) { \
(RINGBUFFER).buffer[i][0] = 0; \
(RINGBUFFER).buffer[i][1] = 0; \
} \
} while (0) \

int ti_ce_stream_new(TI_REAL const *options, ti_stream **stream) {
Expand Down

0 comments on commit 9f4462d

Please sign in to comment.