Commit Graph

353 Commits

Author SHA1 Message Date
christos 913c2b066a sort 2013-05-10 15:31:22 +00:00
christos ba8c9169d1 make NOSTRICT behave the same a LINTED; use the new format. 2013-04-19 18:51:14 +00:00
christos 32c6bb3802 Allow linted comments to take an argument that defines which error to suppress. 2013-04-19 17:43:05 +00:00
christos c71dc22c13 obey constcond to !constcond 2013-03-02 21:25:12 +00:00
christos 47281a37ea rename enum_t to avoid rpc/types.h lossage. 2013-02-17 01:26:19 +00:00
christos e0f6e43eb5 add __PRETTY_FUNCTION__ 2012-04-20 18:35:28 +00:00
christos 52ec92ba25 more cross lint friendlyness
XXX: needs more constants converted double/float
2012-03-27 19:24:01 +00:00
christos ca07e01a36 -0 is not unary overflow. 2012-03-21 14:17:22 +00:00
christos 7ae009b5a7 fix the grammar conflict differently. 2011-12-25 20:11:22 +00:00
christos 8af1345344 correct debugging flags. 2011-12-25 01:05:44 +00:00
christos 1e73d755b4 PR/45666: Nicolas Joly: lint(1) wrong 'syntax error' message 2011-12-25 01:05:03 +00:00
njoly def73a1f81 c99: do not warn about trailing comma in enum declaration. 2011-12-19 16:52:27 +00:00
christos c6a6b07331 Handle c99 declarations in the middle of blocks. 2011-10-04 16:19:59 +00:00
christos 0e4108c639 eat the last d in double constants. 2011-10-02 19:45:10 +00:00
christos bfb07aa1f2 Always use our own align macro and explain a bit more why this is bogus. 2011-06-24 01:10:31 +00:00
joerg 1e608ad53f Fix format string usage 2011-05-24 12:49:11 +00:00
christos b9eac88297 weprovidedarracount()sothatwedon'tneedtosqueezethespacesout. 2011-02-07 23:56:18 +00:00
christos ce3fa327b8 provide __arraycount() if not there. 2011-02-07 00:26:27 +00:00
pooka f5d3a9ff38 don't use __arraycount in tools 2011-02-06 23:03:02 +00:00
christos 27eb1769a9 use unsigned char instead of uint8_t, easier for portability 2011-02-06 18:28:22 +00:00
christos 6b997b11db better dependency handling 2011-02-05 19:13:48 +00:00
christos 4c07b5ae7d fix missing comparison 2011-02-05 19:10:40 +00:00
christos 8e14f999b7 copyright date 2011-02-05 17:29:48 +00:00
christos 76706b0082 as promised make the last ops table auto-generated. 2011-02-05 17:14:14 +00:00
christos 6dfaa18130 oops forgot to commit the script. 2011-02-05 16:10:17 +00:00
christos c93e02df25 fix tools build. Why doesn't .PARSEDIR work? 2011-02-05 03:09:46 +00:00
christos 759a394557 generate ops table dynamically. Will move the other table from tree.c there
too.
2011-02-04 23:32:44 +00:00
christos 15f35154fe fix typo 2011-02-04 23:31:23 +00:00
christos 003dddff9d PR/44235: Valeriy E. Ushakov: Don't pick up a block from the free list if
it is not big enough, allocate a new one. XXX: this is inefficient, but at
least it does not end up corrupting memory.
2011-01-17 03:04:10 +00:00
christos c732e7b752 PR/44235: Martin Husemann: Fix core dump due to memory corruption.
Found by Henning Petersen
2010-12-18 20:57:41 +00:00
wiz 3d3c5d42cb Observe the following spelling:
- wide character (noun)
- wide-character (adjective)

Inspired by jmc@OpenBSD.
2010-12-16 17:42:25 +00:00
christos f6fb458da3 PR/44148: Henning Petersen: catstrg() does not set the resulting string length. 2010-11-24 17:51:11 +00:00
mrg 52a4f7ac75 remove the remaining non-ELF code. 2010-07-11 12:07:31 +00:00
mrg 4c92852a80 remove almost all the ability to build netbsd with an a.out target.
we're ELF now, and there are many missing checks against OBJECT_FMT.
if we ever consider switching, the we can figure out what new ones
we need but for now it's just clutter.

this doesn't remove any of the support for exec_aout or any actually
required-for-boot a.out support, only the ability to build a netbsd
release in a.out format.  ie, most of this code has been dead for
over a decade.

i've tested builds on vax, amd64, i386, mac68k, macppc, sparc, atari,
amiga, shark, cats, dreamcast, landisk, mmeye and x68k.  this covers
the 5 MACHINE_ARCH's affected, and all the other arch code touched.
it also includes some actual run-time testing of sparc, i386 and
shark, and i performed binary comparison upon amiga and x68k as well.


some minor details relevant:
- move shlib.[ch] from ld.aout_so into ldconfig proper, and cut them
  down to only the parts ldconfig needs
- remove various unused source files
- switch amiga bootblocks to using elf2bb.h instead of aout2bb.h
2010-07-06 05:59:50 +00:00
christos 9a10b49e97 revert for now. 2010-03-21 14:29:04 +00:00
christos d867aaf024 make lint recognize constant shift values and not warn if the number of bits
shifted results in a narrower type.
2010-03-21 00:02:13 +00:00
wiz 8e35c759e7 Fix typo in comment. 2010-02-09 23:05:16 +00:00
christos 039ab08b25 fix hex double parsing. 2010-01-11 16:28:06 +00:00
christos 2853bbf4b7 use %option instead of #define YY_NO_... 2009-10-29 14:49:02 +00:00
christos 7770393bf8 add type attributes in a few more places. 2009-10-03 17:09:18 +00:00
christos 3da8ec1b81 accept struct { ... } __packed name; 2009-10-03 01:35:20 +00:00
christos 17b31cc3a2 handle bit fields in packed structures. 2009-10-02 21:49:30 +00:00
christos 876a5b04b7 compute sizes by the new tsize() function. 2009-10-02 21:04:03 +00:00
christos 19f30f4ea2 fix typedef struct __packed 2009-10-02 20:45:06 +00:00
christos 2144a69bda remove debugging 2009-10-02 19:02:16 +00:00
christos 872e317461 recognize struct __packed x { }; in addition to struct x { } __packed; 2009-10-02 19:01:13 +00:00
christos f07e30ff20 change initialization from non const of regular variables to c99 instead of
gnu since c99 now has it.
2009-10-02 18:17:16 +00:00
christos bb531790dc understand __attribute__((__packed__)) and __packed. 2009-10-02 15:03:45 +00:00
wiz 8356afb2c1 Fix typos in comment. 2009-08-05 19:08:28 +00:00
christos 1a90c89fed Add __alignof__. 2009-05-02 16:10:49 +00:00
christos 6892362adf add variable declarations in for loops for c99 2009-05-01 22:03:36 +00:00
ginsbach 5fabed93f9 Print left and right type and not left type twice. (Hi Christos!) 2009-04-27 15:08:10 +00:00
christos 7f812cd511 Lukemify (WARNS=4) 2009-04-15 01:20:57 +00:00
lukem ae780f8105 Compile lint with WARNS=3.
Currently there are too many -Wsign-compare issues for WARNS=4.
2009-04-14 09:09:59 +00:00
christos 3f7bbc73e3 since we know the types, print what they are in error messages. 2009-04-13 21:17:37 +00:00
christos 7c8a9296cc Don't produce type mismatch warnings if one side of ?: is "[qual] void *"
and the other side is "[qual] pointer".
2009-03-02 20:53:10 +00:00
uebayasi febab96b71 Comment out CFLAGS+=-g. 2009-02-14 14:05:58 +00:00
lukem 998789a8d9 this code isn't -Wsign-compare friendly -- drop the WARNS to 3. 2009-02-13 01:27:43 +00:00
joerg 7d8b9145a5 Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.
2008-12-10 16:12:39 +00:00
dholland 3c6470e287 WARNS=4 2008-11-16 07:06:37 +00:00
dholland 96ee89a3c5 Fix wrong memset; PR bin/39733 from Henning Petersen. 2008-10-13 14:00:37 +00:00
dholland c92bbe4462 Don't accidentally treat "long double" as "long". PR bin/39639. 2008-09-27 20:04:24 +00:00
matt c58ed3675c Add the complex types to the floating point promotion rules. 2008-09-27 02:30:46 +00:00
matt 9364aa71ae Teach lint about long double _Complex (C99) 2008-09-26 22:52:24 +00:00
joerg 8a89a3dc54 Check value range of ULONG and UQUAD values. On 32 bit platforms like
i386 "unsigned long x = 0x800000000UL;" passed lint and gcc complains
(rightfully). Validate quad as well to allow using a potentially larger
type to store the value.
2008-09-10 14:05:00 +00:00
christos 3457928c2a Add Picky flag; this produces more warnings:
1. long a; int i; a = i * i;
   suggests casting i to long, so that we gain precision in the multiplication.
2. warns about magnitude comparisons in enums.
3. warns about possible sign extension issues when integer types become widened.
2008-07-31 15:21:34 +00:00
dsl d4d6980a4b Add a check for 'continue' inside a 'do ... while (0)' loop.
'continue' has the same effect as 'break' - as that probably isn't
what the writer had in mind!
2008-07-25 18:33:53 +00:00
christos 26acf9f9d6 don't check for NaN if fpe. 2008-05-03 16:28:56 +00:00
christos 00c6e78061 Since we cannot guarantee that all machines do ieee math, or that they have
the proper math setup deal with SIGFPE directly.
2008-05-02 15:10:05 +00:00
christos ee5dd5c8d7 fix const and volatile printing in types. 2008-05-01 21:52:19 +00:00
martin 11a6dbe728 Convert TNF licenses to new 2 clause variant 2008-04-30 13:10:46 +00:00
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
christos cb68ac0e9c print the types involved in an error. 2008-04-27 01:45:04 +00:00
christos acfccdf2a5 reorder a couple of error messages. 2008-04-27 00:13:58 +00:00
christos 3123c3e08f Fix complex double to be '\0' instead of 'u', from Nicolas Joly. 2008-04-26 23:34:55 +00:00
christos fec2a3517e fix "long double" type recognition which broke with the complex changes. 2008-04-26 16:14:23 +00:00
christos 69ade9fd6e preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.
2008-04-25 22:18:34 +00:00
christos 5f562aba67 handle case C1 ... C2: 2008-04-25 17:18:24 +00:00
christos a23f0e5f81 PR/38142: YAMAMOTO Takashi: lint -S complains on variable length arrays 2008-03-04 02:41:46 +00:00
he 3da5bad40a Add a cheesy workaround marked XXX for the situation where the
strtod() implementation available in the environment does not
handle hex floats.

Discussed with and suggested by christos
2007-02-06 00:08:31 +00:00
christos e903e46b14 deal with hex doubles. 2007-02-02 20:02:18 +00:00
ad c89ec7afee pushinit(): fix a use-after-free bug. 2007-01-20 21:16:23 +00:00
christos 4ad17e5702 No need to leave a lot of space between the error number and the message. 2006-12-19 19:02:49 +00:00
christos f44d03be78 - add debugging to track nowarns
- make /*LINTED*/ take effect on unused functions
2006-11-08 18:31:15 +00:00
christos 39a6c2fdf2 allow 0 sized structs in c9x 2006-10-23 00:15:58 +00:00
christos 5ffa3fb1be add zero sized array handling. It is a little too chatty now. 2006-10-23 00:10:29 +00:00
he e02c317333 Simplify the previous change. There's actually no need to treat constants
specially in ptconv(), the constants will be checked in convert() anyway.
2006-10-18 21:34:39 +00:00
he 4228dd3afb Partly redo when to emit warnings for argument type conversions.
Remove the apparently always true "styp(nt) != SHORT" part of the
innermost test.  Allow atomatic conversion of literals as long as
they fit into the target type.

This should fix some of the lint issues in proplib on some of our
platforms.

Approved by christos.
2006-10-18 00:01:19 +00:00
he 081971a032 Use __inline instead of inline, to allow linting of ourselves... 2006-10-17 23:53:30 +00:00
he 62e8b0f3fa Make a minimal attempt at distinguishing between the hosts and the
targets integer data type value ranges.   For now we just use the
hosts uint64_t for parsing & storing integers constants, and test
against the targets limits and assign appropriately, instead of
sometimes (inappropriately) going via the hosts u_long type.  As
long as none of our architectures have target long or quad data
types strictly larger than 64 bits, we should be fine with this
fix.

Furthermore, as they stand at the moment, we can't use the current
TARG_INT_MAX and TARG_LONG_MAX constants in C preprocessor expressions,
so remove the conditional on them being equal.  Yes, this will
produce dead code for some targets.

This allows an ilp32 host to lint for an lp64 target which uses
e.g. the targets ULONG_MAX constant without triggering an "integer
constant out of range" warning.

OK'ed by christos.
2006-10-16 13:33:57 +00:00
christos 2bd08fcc54 in the same way that we need an extra level for arrays, do the same for struct. 2006-10-15 18:18:54 +00:00
christos 3e006796cf previous fix broke array initializers. 2006-10-15 15:08:20 +00:00
dogcow 37bb4f935a do the #ifndef lint dance for __RCSID; also, include the appropriate
headers if cross-building the program in tools/.
2006-10-15 01:16:31 +00:00
christos e578e35910 Fix c99 initialization issues. Now the regression tests work. 2006-10-14 21:08:50 +00:00
peter e263dfd62f WFORMAT is no more... 2006-10-08 17:52:28 +00:00
christos eb251235c6 flex arrays are a c9x feature. 2006-07-13 17:49:29 +00:00
christos 692e9c49f5 PR/33984: YAMAMOTO Takashi: lint complains about typedef
The grammar for c99 initializers only looked for name tokens, so if there
was a typedef'ed name it failed. Fixed by looking at all identifier tokens.
2006-07-12 20:03:48 +00:00
christos 4b41923ad3 Coverity CID 198: Remove dead code if INT_MAX == LONG_MAX 2006-03-22 02:14:03 +00:00
christos ec166aba55 Coverity CID 199: make sure that rtp is not NULL before dereferencing. 2006-03-22 02:08:55 +00:00
perry 0f0296d88a Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete. 2005-12-24 20:45:08 +00:00
perry cb4a630e29 in several comments:
implizit -> implicit
  explizit -> explicit
2005-09-24 15:30:35 +00:00
christos ddee551034 Handle C99 array range initializers:
type a[] = { [lo ... hi] = c }:
2005-07-17 19:35:48 +00:00
christos 8b3f9b1455 Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.
2005-04-07 16:28:40 +00:00
christos 5f325e6da0 Shift assignment operators were handled incorrectly. On 64 bit machines,
unsigned long x, y;
	x <<= y;
always produces a warning because y is casted to int. Handle them instead
the same way as regular shifts.
2005-01-02 17:59:47 +00:00
christos 2f2c6dc261 say from what type to what time we are converting. 2005-01-02 10:40:49 +00:00
yamt 2e1baea952 recognize _Bool. 2004-09-12 08:58:52 +00:00
yamt 496bd8a26d recognize C99 array initializer designators. PR/18896. 2004-08-03 12:11:54 +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 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
lukem 130ab7336b Rework how MAKEVERBOSE operates:
*	Don't bother prefixing commands with a line of  ${_MKCMD}\
	and instead rely upon "make -s".  This is less intrusive on
	all the Makefiles than the former.  Idea from David Laight.

    *	Rename the variables use to print messages.  The scheme now is:
	    _MKMSG_FOO		Run  _MKMSG 'foo'
	    _MKTARGET_FOO	Run  _MKMSG_FOO ${.TARGET}
	From discussion with Alistair Crooks.
2003-10-21 10:01:19 +00:00
lukem a694177df5 support MAKEVERBOSE and use ${HOST_SH} 2003-10-19 04:25:00 +00:00
lukem a93ea220fc Rework how dependency generation is performed:
* DPSRCS contains extra dependencies, but is _NOT_ added to CLEANFILES.
  This is a change of behaviour.  If a Makefile wants the clean semantics
  it must specifically append to CLEANFILES.
  Resolves PR toolchain/5204.

* To recap: .d (depend) files are generated for all files in SRCS and DPSRCS
  that have a suffix of: .c .m .s .S .C .cc .cpp .cxx

* If YHEADER is set, automatically add the .y->.h to DPSRCS & CLEANFILES

* Ensure that ${OBJS} ${POBJS} ${LOBJS} ${SOBJS} *.d  depend upon ${DPSRCS}

* Deprecate the (short lived) DEPENDSRCS


Update the various Makefiles to these new semantics; generally either
adding to CLEANFILES (because DPSRCS doesn't do that anymore), or replacing
specific .o dependencies with DPSRCS entries.

Tested with "make -j 8 distribution" and "make distribution".
2003-08-01 17:03:41 +00:00
christos fb6b32b11b Back out debugging Makefile. 2003-05-30 13:38:09 +00:00
christos e3071c679b PR/21706: Krister Walfridsson: CVT nodes not handled in ?: expressions. 2003-05-30 13:37:49 +00:00
christos 0fe2b9e22b handle void ({ }) 2003-05-24 22:17:46 +00:00
christos 1a57478e96 Better implementation of ({}) gcc extension. 2003-05-20 13:59:32 +00:00
kristerw 8e46e7bae0 Prevent use of stale pointer for determining return type of ({ })
expressions.

Details:
lint did fail on constructs like

   struct foo *x;
   x = ({ struct foo *y; /* do stuff */; y;});

since it gave the whole ({ }) the same structure representing the
type as y, but that structure is reclaimed when y goes out of scope.
2003-05-18 23:30:00 +00:00
lukem 826a14607a Now that <bsd.prog.mk> DTRT if HOSTPROG is defined (i.e, it is a no-op),
there's no need to special-case .include-ing it.
2003-05-18 07:57:31 +00:00
wiz de87ca793d constant usually has two n. 2003-05-14 12:45:06 +00:00
dbj f1e0ecadf7 remove dependencies on ${LIBC} ${LIBM} and ${LIBTERMCAP} static libraries
from host tool targets.  Commits fix from PR toolchain/21495
2003-05-14 00:24:06 +00:00
lukem ef83aa34d9 clear errno before strto(u)l() if we're going to test it for ERANGE afterwards 2003-04-18 03:21:00 +00:00
simonb 276fd1665c The Double-Semi-Colon Police. 2003-01-20 05:29:53 +00:00
thorpej 8fb0e9f9e9 Include <string.h> for prototypes. 2002-12-06 03:27:39 +00:00
christos 67dc335c98 PR/18896: Jason Thorpe: C99 structure member initializers broken for arrays.
XXX: The checking done does not work, but the code passes.
2002-11-13 21:50:57 +00:00
perry 5f042d3d69 add a comment on c99ism noting that the logic might be wrong but we
haven't yet decided on what combinations of -s and -S really are
intended to mean yet.
2002-11-02 20:14:10 +00:00
perry 22f5530a1a Make long long a c99ism, not a gnuism. 2002-11-02 20:10:16 +00:00
perry cca1626bfa add c99ism(), by analogy to gnuism(), for c99 construct (un)warnings 2002-11-02 20:09:27 +00:00
perry ab74747a8d 1) // is only for c99 or gcc
2) inline is acceptable in c99 -- create a new c99 keyword class.

XXX The handling of sflag and Sflag is utterly bogus throughout this
pass. I think I have to make some adjustments.
2002-11-02 01:42:22 +00:00
christos c7e6cd9edb mention what is wrong with the ({}) productions. 2002-10-23 13:01:16 +00:00
christos fa292fcfa7 forgot to commit those. 2002-10-23 00:36:36 +00:00
christos 5a3a9e9ea9 add support for ({}) gcc shit. 2002-10-22 22:50:11 +00:00
christos 899427c2e4 handle free-ing of temp symbols properly. Don't segv on bad node types. 2002-10-22 21:09:34 +00:00
christos c5db62c0ef add C9X/GCC compound literal expressions. 2002-10-22 18:15:00 +00:00
christos 8c326659c6 add variable array dimension. 2002-10-22 13:48:50 +00:00
christos ff5be0fa49 handle gcc __FUNCTION__ and C9X __func__ 2002-10-22 13:31:34 +00:00
christos e6e5ec1d1b fix spelling in comment. 2002-10-22 13:30:23 +00:00
christos cb118faff0 a cast to a pointer is an l-value. 2002-10-22 00:25:29 +00:00
christos 718a2bccc8 handle cast in the rhs of a - op. 2002-10-22 00:06:46 +00:00
christos 49f5eb9bb9 Ignore cast size test in initializers; look at example in the comment.
Maybe there is a better way...
2002-10-21 22:48:13 +00:00
christos 18a706cc53 fix typo 2002-10-21 22:44:08 +00:00
christos 66cab14e3e support for c99 style and gnu style structure and union named initializers. 2002-10-21 21:14:51 +00:00
christos baa7f9f49e Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
  error are printed before we abort.
- recurse in type printing to provide the proper type name.
2002-09-13 14:59:24 +00:00
jmc 855a0649f3 Change xgetblk to detect cases where the requested size is more than mblklen.
(generally it's 20k). Adjust mblklen temporarily to the size of the block
required and allocate one. This avoids coredumps when mapping in identifiers
that have huge values. (In my example it was a char[] for a 640k pixmap).
2002-06-28 05:03:55 +00:00
tv 6057928f1a Rename `basename' as `lbasename' so as not to confuse with the libgen.h
prototyped function of the same name.
2002-03-07 20:17:37 +00:00
thorpej b02b24b1d7 Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions.  These types are more
portable, and a little more sane to do autoconf tests for.
2002-02-05 03:04:26 +00:00
lukem 9c3323249d need -lm in the HOSTPROG case too... 2002-02-01 05:44:40 +00:00
ross 4ecd3ab001 now needs -lm for finite(3) 2002-02-01 01:32:20 +00:00
tv 9fbd88883c Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
  sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.
2002-01-31 22:43:33 +00:00
tv 95407c5758 Use !finite() instead of isinf() in two places for better compatibility. 2002-01-31 22:30:20 +00:00
tv 76834aef57 Protect __RCSID and __COPYRIGHT from being invoked if not defined. 2002-01-31 19:36:47 +00:00