build: lint "strtol" #40442

Problem:
No lint for strtol().

Solution:
Add lint, and update existing usages.

Callers that previously got a (garbage) large positive value:
- `indent.c`: use getdigits() (intmax, no int truncation) with def=1 so
  overflow/too-large values stay positive and fall through to the
  existing "too big" check (E475).
- `file_search.c`: use getdigits() with def=255 so overflow/too-large
  values keep the "max expand" (else) branch.

The other conversions (api/command.c, eval/window.c, highlight_group.c,
tui/tui.c) only diverge on pathological overflow inputs where strtol's
result was already garbage and the observable outcome is unchanged.
This commit is contained in:
Justin M. Keyes
2026-06-28 19:01:24 -04:00
committed by GitHub
parent bb6576c92a
commit 87b42e1209
9 changed files with 37 additions and 12 deletions

View File

@@ -43,7 +43,8 @@ describe('clint.lua', function()
'test/functional/fixtures/clint_test.c:138: Use xfree(...) instead of free(...). [runtime/memory_fn] [2]',
'test/functional/fixtures/clint_test.c:141: Use os_getenv(...) instead of getenv(...). [runtime/os_fn] [2]',
'test/functional/fixtures/clint_test.c:142: Use os_setenv(...) instead of setenv(...). [runtime/os_fn] [2]',
'Total errors found: 28',
'test/functional/fixtures/clint_test.c:143: Use getdigits()/getdigits_int() (or vim_str2nr() for non-decimal bases) instead of strtol, which overflows silently. See src/nvim/charset.c. [runtime/deprecated] [4]',
'Total errors found: 29',
}
t.eq(expected, output_lines)
end)