Skip to content

Commit

Permalink
fix -Wall -Wextra
Browse files Browse the repository at this point in the history
- keep the gnu-specific `?:` operator
- keep scanf since scanf_s is not in gcc
  • Loading branch information
rfon6ngy committed Dec 17, 2022
1 parent ca0a070 commit 8c5455f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
cc: [ gcc, clang ]
cc: [ gcc, clang ]
needs: check
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- if: startswith(matrix.os, 'windows-')
run: make CC="${{matrix.cc}}" TARGET="vcd-${{matrix.os}}-${{matrix.cc}}.exe"
- if: ${{ startswith(matrix.os, 'windows-') && matrix.cc == 'gcc'}}
run: make CC="${{matrix.cc}}" && mv vcd.exe vcd-${{matrix.os}}-${{matrix.cc}}.exe
- if: ${{ startswith(matrix.os, 'windows-') && matrix.cc == 'clang'}}
run: make CC="${{matrix.cc}}" && mv vcd vcd-${{matrix.os}}-${{matrix.cc}}.exe
- if: startswith(matrix.os, 'windows-') == false
run: make CC="${{matrix.cc}}" TARGET="vcd-${{matrix.os}}-${{matrix.cc}}"
run: make CC="${{matrix.cc}}" && mv vcd vcd-${{matrix.os}}-${{matrix.cc}}
- uses: actions/upload-artifact@v2
with:
path: vcd-${{matrix.os}}-${{matrix.cc}}*
Expand Down
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
TARGET?=vcd
SRCS:=$(wildcard *.c)
all: $(TARGET)
$(TARGET): $(SRCS); $(CC) $(CFLAGS) $(SRCS) -o $@
install: $(TARGET); install -v -D $< $(DESTDIR)/usr/bin/$<
clean: ; $(RM) $(TARGET)
8 changes: 4 additions & 4 deletions vcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void parseVcdInstruction(ParseCtx* p) {
if (!strcmp("var", token)) {
Token id;
Channel c = {.scope = p->scope_cur, .samples = malloc(sizeof(Sample))};
scanf(" %*s %d %" TXT(SFL) "[^ ] %" TXT(SFL) "[^$]", &c.size, id, c.name);
scanf(" %*s %u %" TXT(SFL) "[^ ] %" TXT(SFL) "[^$]", &c.size, id, c.name);
p->ch_lim = MAX(p->ch_lim, strlen(c.name));
p->sz_lim = MAX(p->sz_lim, c.size);
p->ch[chanId(id, p->chan_str)] = c;
Expand Down Expand Up @@ -191,7 +191,7 @@ void printYml(ParseCtx* p, PrintOpt* opt) {
printf("%-*g ", ITV_TIME * zoom - 1, smpl * p->scale);
}
printf("%s\nchannels:\n", opt->end);
for (Channel* ch = p->ch; ch - p->ch < COUNT(p->ch); ch++) {
for (Channel* ch = p->ch; ch - p->ch < (signed)COUNT(p->ch); ch++) {
// skip empty ch
if (!ch->size) continue;
// print scope (if changed)
Expand Down Expand Up @@ -220,13 +220,13 @@ void printYml(ParseCtx* p, PrintOpt* opt) {
}
}

int main(int argc, char** argv) {
int main() {
PrintOpt opt = {getenv("LOW") ?: "▁", getenv("RAISE") ?: "╱",
getenv("HIGH") ?: "▔", getenv("DROWN") ?: "╲",
getenv("STX") ?: "\"", getenv("ETX") ?: "\"",
atoi(getenv("SKIP") ?: "0")};
// PrintOpt opt = {"_", "/", "#", "\\"} {"▁", "╱", "▔", "╲"};
ParseCtx ctx = {};
ParseCtx ctx = {0};
parseVcd(&ctx);
printYml(&ctx, &opt);
return 0;
Expand Down

0 comments on commit 8c5455f

Please sign in to comment.