Skip to content

Suppress Cppcheck and spelling errors #257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ qtest: $(OBJS)

fmtscan: tools/fmtscan.c
$(VECHO) " CC+LD\t$@\n"
$(Q)$(CC) -o $@ $(CFLAGS) $<
$(Q)$(CC) -o $@ $(CFLAGS) $< -lrt -lpthread

check: qtest
./$< -v 3 -f traces/trace-eg.cmd
Expand Down
19 changes: 19 additions & 0 deletions scripts/aspell-pws
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ sigaltstack
utime
mknod
ustat
stat
getopt
statfs
fstatfs
sysfs
Expand Down Expand Up @@ -430,3 +432,20 @@ pws
el
fd
hv
col
dA
dC
dD
lu
pC
pE
pGp
pM
pS
pg
phD
pm
pr
ps
newline
abbrev
5 changes: 3 additions & 2 deletions scripts/pre-commit.hook
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ declare -F set_colors >/dev/null 2>&1 || { echo "[!] '$common_script' does not d
# Build unmatched suppressions for each *.c file.
cppcheck_build_unmatched() {
local file suppression=""
for file in *.c; do
for file in *.c tools/*.c; do
suppression+=" --suppress=unmatchedSuppression:$file"
done
echo "$suppression"
Expand Down Expand Up @@ -46,11 +46,12 @@ cppcheck_suppressions() {
"staticFunction:linenoise.c"
"nullPointerOutOfMemory:web.c"
"staticFunction:web.c"
"constParameterCallback:tools/fmtscan.c"
)

# Array for additional cppcheck options (non-suppressions)
local -a other_flags=(
"--inline-suppr harness.c"
"--inline-suppr harness.c --inline-suppr tools/fmtscan.c"
)

local out=""
Expand Down
10 changes: 4 additions & 6 deletions tools/fmtscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ static inline bool find_word(const char *restrict word,

static inline int read_dictionary(const char *dictfile)
{
char *ptr, *dict;
struct stat buf;
char buffer[4096];
const char *buffer_end = buffer + (sizeof(buffer)) - 1;
Expand All @@ -372,6 +371,7 @@ static inline int read_dictionary(const char *dictfile)
return -1;
}

const char *ptr, *dict;
ptr = dict =
mmap(NULL, buf.st_size, PROT_READ, MAP_SHARED | MAP_POPULATE, fd, 0);
if (dict == MAP_FAILED) {
Expand All @@ -393,7 +393,7 @@ static inline int read_dictionary(const char *dictfile)
add_word(buffer, word_nodes, word_node_heap, &word_node_heap_next,
WORD_NODES_HEAP_SIZE);
}
munmap(dict, buf.st_size);
munmap((void *) dict, buf.st_size);
close(fd);

return 0;
Expand Down Expand Up @@ -656,19 +656,17 @@ static get_char_t parse_number(parser_t *restrict p,

/* Determine the integer format based on its prefix. */
if (LIKELY(ch == '0')) {
get_char_t nextch1, nextch2;

token_append(t, ch);

nextch1 = get_char(p);
get_char_t nextch1 = get_char(p);

if (nextch1 >= '0' && nextch1 <= '8') {
/* Treat as an octal value */
ch = nextch1;
isoct = true;
} else if (nextch1 == 'x' || nextch1 == 'X') {
/* Check for hexadecimal notation */
nextch2 = get_char(p);
get_char_t nextch2 = get_char(p);

if (LIKELY(nextch2 != PARSER_EOF)) {
/* If not EOF, revert state and finish token */
Expand Down