Skip to content

Commit

Permalink
Fix tidy errors
Browse files Browse the repository at this point in the history
Silence some warnings about `fprintf` vs. `fprintf_s` (which is not
available).
  • Loading branch information
tgross35 committed Jun 24, 2024
1 parent f78090e commit d0c2ab1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ Checks: "clang-diagnostic-*,clang-analyzer-*,cppcoreguidelines-*,modernize-*,-mo
WarningsAsErrors: true
HeaderFilterRegex: ""
FormatStyle: google
ExtraArgsBefore: ["--std=c11"]
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ _lint-min: _clone-repo-tree-sitter configure-compile-database
git ls-files '**.c' | \
grep -v 'parser\.c' | \
grep -v 'bindings/python' | \
xargs -IFNAME sh -c 'echo "\nchecking file FNAME" && clang-tidy --std=c11 FNAME'
xargs -IFNAME sh -c 'echo "\nchecking file FNAME" && clang-tidy FNAME'

# Run the linter for JS, C, Cargo, and Python. Requires clang-tidy, clippy, and ruff.
lint: _lint-min
Expand Down
14 changes: 9 additions & 5 deletions src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,25 @@
#define unused_attr
#endif

#ifndef fprintf_s
#define fprintf_s fprintf // NOLINT
#endif

#ifdef DEBUG_PRINT
#define dbg_print(...) \
do { \
fprintf_s(stderr, " \033[96;1mparse: \033[0m"); \
fprintf_s(stderr, __VA_ARGS__); \
fprintf_s(stderr, " \033[96;1mparse: \033[0m"); \
fprintf_s(stderr, __VA_ARGS__); \
} while (0)
#else
#define dbg_print(...)
#endif

#define panic(...) \
do { \
fprintf_s(stderr, "panic at %s:%d: ", __FILE_NAME__, __LINE__); \
fprintf_s(stderr, __VA_ARGS__); \
fprintf_s(stderr, "\n"); \
fprintf_s(stderr, "panic at %s:%d: ", __FILE_NAME__, __LINE__); \
fprintf_s(stderr, __VA_ARGS__); \
fprintf_s(stderr, "\n"); \
exit(1); \
} while (0);

Expand Down

0 comments on commit d0c2ab1

Please sign in to comment.