Commit Graph

21 Commits

Author SHA1 Message Date
rillig df5e1bf6cb lint: remove custom memory allocator
Besides adding complexity, the custom memory allocator didn't invalidate
freed memory, which made it harder to find possible use-after-free bugs.
2023-01-13 19:41:50 +00:00
rillig 0386644f46 lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.

No binary change.
2022-05-20 21:18:54 +00:00
rillig 5788d57ee7 lint: fix memory allocation (since 2021-08-28)
In mem1.c 1.50 and mem2.c 1.13 from 2021-08-28, I accidentally changed
the initialization of mblklen from round_up to round_down, trying to
avoid a division instruction.

On NetBSD x86_64 this resulted in a few more malloc calls, but on Cygwin
with its 64k pagesize, mblklen became 0.  Later, the function xalloc in
lint2 called xalloc(mblklen) and blindly assumed that the returned
memory would be large enough.  This in turn led to out-of-bounds memory
access and crashes.  Lint1 was not affected since it adjust mblklen
during runtime if it gets too small.
2021-08-31 17:22:24 +00:00
rillig 44802c0b56 lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values
which are sometimes ignored.

The remaining calls to fprintf that ignore the return value come from
scan.c.  Lint does not currently detect the auto-generated portions of
that file and the interesting ones since it assumes that scan.c is the
main filename, see expr_zalloc_tnode.

No functional change.
2021-08-28 13:29:26 +00:00
rillig f7d8392a80 lint: only include code in the binaries that is actually used
No functional change.
2021-08-22 15:06:49 +00:00
rillig 6e889c432d lint: make memory management code easier to read
No functional change.
2021-08-03 17:20:02 +00:00
rillig 86a595a37f lint: make xasprintf simpler
No functional change.
2021-08-01 18:13:53 +00:00
rillig cd66f68dee lint: unexport nomem
No functional change.
2021-08-01 18:07:35 +00:00
rillig fdcb9d74e4 lint: remove xmapalloc
Just trust the standard malloc to be smart enough.

No functional change.
2021-08-01 17:59:47 +00:00
rillig 5bf56b009b lint: remove WARNS=3, falling back to the default WARNS=5
It's strange that GCC does not warn about the nonliteral format strings
in lint1/err.c, lint2/msg.c and lint2/read.c, despite -Wformat=2, but
Clang does.
2021-04-18 22:51:24 +00:00
rillig 9068543091 lint: remove redundant parentheses around return value 2020-12-29 11:35:11 +00:00
rillig e0f7967137 lint: remove trailing whitespace 2020-12-28 22:16:42 +00:00
rillig 0ab178ad4b lint: spell check 2020-12-28 21:24:55 +00:00
christos b6b0a28bae use asprintf(). 2020-02-10 04:54:01 +00:00
jmc b2f782612f Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
2004-06-20 22:20:14 +00:00
christos 2a2701085e - keep the fd to /dev/zero open
- take advantage of MAP_ANONYMOUS
2003-10-22 16:10:03 +00:00
christos 58507d43c3 PR/23219: Dan McMahill: Make this compile on system that don't have MAP_ANON.
Centralize the mmap allocations in a new function, xmapalloc() that handles
this.
2003-10-21 23:58:53 +00:00
itojun d5250e4ec9 safer use of realloc 2003-10-16 06:34:19 +00:00
tv 76834aef57 Protect __RCSID and __COPYRIGHT from being invoked if not defined. 2002-01-31 19:36:47 +00:00
tv 44fbde6015 Add hooks for compiling on non-NetBSD hosts. 2002-01-21 19:49:51 +00:00
thorpej 41d48940fa * Move stuff shared between lint1 and lint2 to the new common/ directory.
* Move the arch/ directory out of lint1/ into the top-level.
2002-01-18 20:39:17 +00:00