Skip to content

Commit 8c5455f

Browse files
committed
fix -Wall -Wextra
- keep the gnu-specific `?:` operator - keep scanf since scanf_s is not in gcc
1 parent ca0a070 commit 8c5455f

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@ jobs:
1313
strategy:
1414
matrix:
1515
os: [ ubuntu-latest, windows-latest, macos-latest ]
16-
cc: [ gcc, clang ]
16+
cc: [ gcc, clang ]
1717
needs: check
1818
runs-on: ${{matrix.os}}
1919
steps:
2020
- uses: actions/checkout@v2
21-
- if: startswith(matrix.os, 'windows-')
22-
run: make CC="${{matrix.cc}}" TARGET="vcd-${{matrix.os}}-${{matrix.cc}}.exe"
21+
- if: ${{ startswith(matrix.os, 'windows-') && matrix.cc == 'gcc'}}
22+
run: make CC="${{matrix.cc}}" && mv vcd.exe vcd-${{matrix.os}}-${{matrix.cc}}.exe
23+
- if: ${{ startswith(matrix.os, 'windows-') && matrix.cc == 'clang'}}
24+
run: make CC="${{matrix.cc}}" && mv vcd vcd-${{matrix.os}}-${{matrix.cc}}.exe
2325
- if: startswith(matrix.os, 'windows-') == false
24-
run: make CC="${{matrix.cc}}" TARGET="vcd-${{matrix.os}}-${{matrix.cc}}"
26+
run: make CC="${{matrix.cc}}" && mv vcd vcd-${{matrix.os}}-${{matrix.cc}}
2527
- uses: actions/upload-artifact@v2
2628
with:
2729
path: vcd-${{matrix.os}}-${{matrix.cc}}*

Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
TARGET?=vcd
2-
SRCS:=$(wildcard *.c)
32
all: $(TARGET)
4-
$(TARGET): $(SRCS); $(CC) $(CFLAGS) $(SRCS) -o $@
53
install: $(TARGET); install -v -D $< $(DESTDIR)/usr/bin/$<
64
clean: ; $(RM) $(TARGET)

vcd.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void parseVcdInstruction(ParseCtx* p) {
8181
if (!strcmp("var", token)) {
8282
Token id;
8383
Channel c = {.scope = p->scope_cur, .samples = malloc(sizeof(Sample))};
84-
scanf(" %*s %d %" TXT(SFL) "[^ ] %" TXT(SFL) "[^$]", &c.size, id, c.name);
84+
scanf(" %*s %u %" TXT(SFL) "[^ ] %" TXT(SFL) "[^$]", &c.size, id, c.name);
8585
p->ch_lim = MAX(p->ch_lim, strlen(c.name));
8686
p->sz_lim = MAX(p->sz_lim, c.size);
8787
p->ch[chanId(id, p->chan_str)] = c;
@@ -191,7 +191,7 @@ void printYml(ParseCtx* p, PrintOpt* opt) {
191191
printf("%-*g ", ITV_TIME * zoom - 1, smpl * p->scale);
192192
}
193193
printf("%s\nchannels:\n", opt->end);
194-
for (Channel* ch = p->ch; ch - p->ch < COUNT(p->ch); ch++) {
194+
for (Channel* ch = p->ch; ch - p->ch < (signed)COUNT(p->ch); ch++) {
195195
// skip empty ch
196196
if (!ch->size) continue;
197197
// print scope (if changed)
@@ -220,13 +220,13 @@ void printYml(ParseCtx* p, PrintOpt* opt) {
220220
}
221221
}
222222

223-
int main(int argc, char** argv) {
223+
int main() {
224224
PrintOpt opt = {getenv("LOW") ?: "▁", getenv("RAISE") ?: "╱",
225225
getenv("HIGH") ?: "▔", getenv("DROWN") ?: "╲",
226226
getenv("STX") ?: "\"", getenv("ETX") ?: "\"",
227227
atoi(getenv("SKIP") ?: "0")};
228228
// PrintOpt opt = {"_", "/", "#", "\\"} {"▁", "╱", "▔", "╲"};
229-
ParseCtx ctx = {};
229+
ParseCtx ctx = {0};
230230
parseVcd(&ctx);
231231
printYml(&ctx, &opt);
232232
return 0;

0 commit comments

Comments
 (0)