Skip to content

Commit 947bec7

Browse files
authored
Merge pull request #205 from edgar-bonet/uninit
Fix CI failure on maybe-uninitialized compiler warning
2 parents f470bb0 + a01ae83 commit 947bec7

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

.github/workflows/linux_and_macos.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,8 @@ jobs:
147147
# would error out saying "ld: unknown option: --as-needed"
148148
if [[ ${{ runner.os }} = macOS ]]; then
149149
as_needed=
150-
# GCC on macOS needs this flag to suppress false positive uninitialized warnings
151-
maybe_uninit_flag='-Wno-error=maybe-uninitialized'
152150
else
153151
as_needed='-Wl,--as-needed'
154-
maybe_uninit_flag=
155152
fi
156153
157154
# musl-gcc and gcc/macOS do not seem to support linking with sanitizers
@@ -165,7 +162,7 @@ jobs:
165162
166163
${MAKE} --version 2>/dev/null || true
167164
168-
CFLAGS="-std=c99 -pedantic -Werror ${maybe_uninit_flag} ${sanitizer} -O1" LDFLAGS="${as_needed} ${sanitizer}" ${MAKE}
165+
CFLAGS="-std=c99 -pedantic -Werror ${sanitizer} -O1" LDFLAGS="${as_needed} ${sanitizer}" ${MAKE}
169166
170167
- name: 'Install'
171168
env:

ttyplot.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ static void draw_line(int x, int ph, int l1, int l2, cchar_t *c1, cchar_t *c2,
322322

323323
// Handle drawing based on whether values are positive or negative
324324
if (zero_pos > 0) { // We have negative values
325-
int y1_start, y1_end, y2_start, y2_end;
325+
int y1_start, y1_end;
326326

327327
// For value 1
328328
if (v1 >= 0) {
@@ -335,8 +335,17 @@ static void draw_line(int x, int ph, int l1, int l2, cchar_t *c1, cchar_t *c2,
335335
y1_end = ph + 1 - l1;
336336
}
337337

338+
// Draw the lines
339+
if (y1_start < y1_end) {
340+
mvvline_set(y1_start, x, c1, y1_end - y1_start);
341+
} else if (y1_start > y1_end && l1 > 0) {
342+
mvvline_set(y1_end, x, c1, y1_start - y1_end);
343+
}
344+
338345
// For value 2
339346
if (has_v2) {
347+
int y2_start, y2_end;
348+
340349
if (v2 > 0) {
341350
y2_start = ph + 1 - l2;
342351
y2_end = ph + 1 - zero_pos;
@@ -347,15 +356,8 @@ static void draw_line(int x, int ph, int l1, int l2, cchar_t *c1, cchar_t *c2,
347356
y2_start = ph + 1 - zero_pos;
348357
y2_end = ph + 1 - zero_pos;
349358
}
350-
}
351359

352-
// Draw the lines
353-
if (y1_start < y1_end) {
354-
mvvline_set(y1_start, x, c1, y1_end - y1_start);
355-
} else if (y1_start > y1_end && l1 > 0) {
356-
mvvline_set(y1_end, x, c1, y1_start - y1_end);
357-
}
358-
if (has_v2) {
360+
// Draw the lines
359361
if (y2_start < y2_end) {
360362
mvvline_set(y2_start, x, &c2r, y2_end - y2_start);
361363
} else if (y2_start > y2_end) {

0 commit comments

Comments
 (0)