Commit Graph

284458 Commits

Author SHA1 Message Date
rillig
bf28682f65 lint: extend test for strict _Bool handling
There is no danger in allowing (flags & FLAG) as a controlling
expression, provided that it is immediately compared to zero, such as in
an if statement or as the operand of a logical operator.
2021-01-11 00:28:28 +00:00
rillig
810790fcb7 make(1): make a few more bool expressions more precise
The previous version of lint(1) from a few hours ago didn't catch all
occurrences.  And even the current one doesn't catch everything.
Function arguments and return types still need some work.  The "return
quietly" from shouldDieQuietly still implicitly converts from int to
_Bool.

No functional change.
2021-01-10 23:59:53 +00:00
riastradh
cba96d16f7 Various entropy integration improvements.
- New /etc/security check for entropy in daily security report.

- New /etc/rc.d/entropy script runs (after random_seed and rndctl) to
  check for entropy at boot -- in rc.conf, you can:

  . set `entropy=check' to halt multiuser boot and enter single-user
    mode if not enough entropy

  . set `entropy=wait' to make multiuser boot wait until enough entropy

  Default is to always boot without waiting -- and rely on other
  channels like security report to alert the operator if there's a
  problem.

- New man page entropy(7) discussing the higher-level concepts and
  system integration with cross-references.

- New paragraph in afterboot(8) about entropy citing entropy(7) for
  more details.

This change addresses many of the issues discussed in security/55659.
This is a first draft; happy to take improvements to the man pages and
scripted messages to improve clarity.

I considered changing motd to include an entropy warning with a
reference to the entropy(7) man page, but it's a little trickier:
- Not sure it's appropriate for all users to see at login rather than
  users who have power to affect the entropy estimate (maybe it is,
  just haven't decided).
- We only have a mechanism for changing once at boot; the message would
  remain until next boot even if an operator adds enough entropy.
- The mechanism isn't really conducive to making a message appear
  conditionally from boot to boot.
2021-01-10 23:24:25 +00:00
rillig
e9d1e169d3 lint: add enum flags to the test about strict boolean mode 2021-01-10 21:45:50 +00:00
rillig
465f117622 lint: allow custom flags to be specified in all unit tests
Previously, only the tests called msg_*.c could use this feature.  Since
it is useful for other tests as well, enable it everywhere.
2021-01-10 21:26:12 +00:00
rillig
31940a95cd make(1): consistently use boolean expressions in conditions
Most of the make code already followed the style of explicitly writing
(ptr != NULL) instead of the shorter (ptr) in conditions.

The remaining 50 instances have been found by an experimental,
unpublished check in lint(1) that treats bool expressions as
incompatible to any other scalar type, just as in Java, C#, Pascal and
several other languages.

The only unsafe operation on Boolean that is left over is (flags &
FLAG), for an enum implementing a bit set.  If Boolean is an ordinary
integer type (the default), some high bits may get lost.  But if Boolean
is the same as _Bool (by compiling with -DUSE_C99_BOOLEAN), C99 6.3.1.2
defines that a conversion from any scalar to the type _Bool acts as a
comparison to 0, which cannot lose any bits.
2021-01-10 21:20:46 +00:00
skrll
8be367b3f6 PR/55715: pmax testbed panics with "assertion "asid == curcpu()->ci_pmap_asid_cur" failed"
disable the sigbus_adraln test on qemu for now
2021-01-10 20:46:14 +00:00
riastradh
26da9de7e6 rc.subr(8): Fix markup -- use .It to set off a new item. 2021-01-10 19:26:31 +00:00
jmcneill
0561b403b9 Disable nouveau for now. It can cause long pauses at boot and sometimes
fails to initialize the display at all.
2021-01-10 19:20:16 +00:00
rillig
74ead7f1f1 lint: split check_global_variable into several functions
This reduces the indentation and allows the messages in the comments to
contain the complete text instead of only an abbreviated prefix.

No functional change.
2021-01-10 18:22:52 +00:00
rillig
556f6964e2 lint: fix assertion failure for syntax error in enum declaration 2021-01-10 18:13:42 +00:00
rillig
0ec7a3ab6a lint: add test for triggering assertion failures in lint1 2021-01-10 18:06:38 +00:00
rillig
76d2ead3e0 lint: add test for treating _Bool as non-scalar type
This strict mode is not yet implemented.  The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h.  These variants did find some bugs, but not
reliably so.  Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL.  This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code.  Still, there should not be any assertion
failures while running lint1.
2021-01-10 17:43:46 +00:00
ryoon
09c03af8ed Add whitespace after comma 2021-01-10 15:50:16 +00:00
rillig
f49e4318ba lint: remove redundant parentheses around return value 2021-01-10 14:12:48 +00:00
rillig
b57d857fe2 lint: change return type of eqptrtype to bool 2021-01-10 14:09:57 +00:00
rillig
9325ef4f0b lint: rename functions with short names 2021-01-10 14:07:34 +00:00
rillig
60d8513049 lint: use message 232 for unused label in function
This message had been defined but not used before.
2021-01-10 13:54:13 +00:00
martin
6903ba0384 Explicitly cast offset calculation, size_t may be smaller than off_t. 2021-01-10 13:44:57 +00:00
ryoon
7d49fb627c Fix a typo in debug message 2021-01-10 13:17:44 +00:00
rillig
c7eced1ab4 lint: explain missing error for _Bool constant expressions 2021-01-10 13:17:24 +00:00
rillig
a90a871c79 lint: fix conversion of non-constant scalar to _Bool 2021-01-10 12:46:38 +00:00
tkusumi
f8ac354381 fstyp: Sync HAMMER1/2 with DragonFly BSD
taken-from: DragonFly BSD
2021-01-10 12:38:40 +00:00
rillig
f8cc76a76d lint: fix conversion of constant expressions to _Bool 2021-01-10 12:34:56 +00:00
rillig
9d90fb23fe lint: add test for converting non-constant expressions to _Bool 2021-01-10 12:29:46 +00:00
rillig
a0c63d1765 lint: automate adding a test for lint1 2021-01-10 12:05:07 +00:00
rillig
e107438c00 lint: demonstrate wrong handling of conversion to _Bool 2021-01-10 11:24:42 +00:00
rillig
dadf0f419e lint: rename cvtcon to convert_constant
No functional change.
2021-01-10 11:17:53 +00:00
tsutsui
61cb7e57e0 Print rd(4) capacity and geometry info as sd(4) and wd(4) do.
Before:
rd0 at hpibbus1 slave 0 punit 0: 7937H
rd0: 698 cylinders, 13 heads, 1116102 blocks, 512 bytes/block

After:
rd0 at hpibbus1 slave 0 punit 0: 7937H
rd0: 544 MB, 698 cyl, 13 head, 123 sec, 512 bytes/block x 1116102 blocks
2021-01-10 00:58:56 +00:00
rillig
bfe7d5e162 lint: remove redundant braces in is_confusing_precedence
This nicely aligns the different branches, in which "l" and "r" are
swapped.

No functional change.
2021-01-10 00:12:50 +00:00
rillig
fe68124a52 lint: rename type classification macros
The previous names tspec_is_int and tspec_is_uint were confusing because
there are actually tspec_t constants called INT and UINT, these
classification macros return true for other integer types as well,
though.

While here, remove the prefix "tspec_" from these macros.  It wasn't as
helpful as intended, in many cases it was obviously redundant, when it
was called as tspec_is_integer(tn->tn_type->t_tspec).

No functional change.
2021-01-10 00:05:45 +00:00
wiz
93cc9aa740 Add magic incantation to configure an image for mount_udf(8). 2021-01-09 23:54:26 +00:00
rillig
13e81db968 lint: push down complexity from typeok to typeok_shr
Contrary to the comment in typeok, the types of the expressions before
promotions and conversions are not needed for SHL, SHLASS and SHRASS.
Move that code over to typeok_shr, the only place where it is actually
used.  This removes another 3 variables from typeok.
2021-01-09 23:18:19 +00:00
rillig
fe47a95707 lint: move pointer subtypes from typeok to the sub-functions
The code in typeok is already complicated enough.  Only few of the
checks actually examine the subtype of the pointer, the others don't
need to look at it.  Therefore don't initialize the variables lstp
(left-hand side subtype) and rstp unless they are actually needed.

This reduces the number of variables in typeok and the number of
parameters to the sub-functions.
2021-01-09 23:02:51 +00:00
rillig
6bb8504ff5 lint: add test for 116 "illegal pointer subtraction" 2021-01-09 22:55:36 +00:00
rillig
6c55876374 lint: make the table containing the operator properties more readable
The C preprocessor does not require its arguments to be expressions, an
empty string is valid as well.  This allows to replace the 0 in the
operator properties table with a space, making the 1 stick out.

Since the table is quite long, divide it into sections and add section
headers.

No change in the generated code.
2021-01-09 22:19:11 +00:00
rillig
8668691139 lint: rename ops.c to oper.c
The file ops.c had previously been autogenerated.  This meant that in a
NetBSD build, it was generated in OBJDIR, and a build that had just
updated src/usr.bin would fail.  For a build that last ran on
2020-12-01, and again today, it looks like this:

	#      link  lint1/lint1
	cc ... -o lint1 cgram.lo ... ops.lo ... tyname.lo
	/usr/bin/ld: ops.lo: in function `initmtab':
	ops.c:(.text+0x63): undefined reference to `STRUCT_ASSIGN'

This is caused by ops.c existing in OBJDIR, so the new version in
NETBSDSRCDIR is not looked at.  To prevent this, use oper.c instead as
the filename, which has not been used before.

https://mail-index.netbsd.org/source-changes-d/2021/01/09/msg013096.html
2021-01-09 21:37:44 +00:00
rillig
cc85ccc4e8 UPDATING: lint1/ops.c may require OBJDIR to be cleaned
https://mail-index.netbsd.org/source-changes-d/2021/01/09/msg013098.html
2021-01-09 20:51:08 +00:00
rillig
c52bdc3223 lint: change return type of typeok to bool
No functional change.
2021-01-09 19:13:17 +00:00
rillig
1d7ebe5271 lint: split typeok into several smaller functions
This reduces the number of local variables from 16 to around 5, in most
of the smaller functions.

No functional change.
2021-01-09 19:07:07 +00:00
christos
ca969aae02 preserve errno because we are doing system calls between error printing
and error setting.
2021-01-09 18:26:03 +00:00
christos
d71ebb0175 restore perror -> warn (reported by Havard Eidnes) 2021-01-09 18:22:42 +00:00
rillig
956d051a07 lint: extract typeok_amper from typeok
No functional change.
2021-01-09 18:21:08 +00:00
rillig
7f72829d0c lint: extract typeok_incdec from typeok
No functional change.
2021-01-09 18:15:14 +00:00
rillig
1d90d5eca8 lint: reorder table of operator properties
The 4 "requires" properties are now listed together, in descending
strictness.
2021-01-09 17:36:10 +00:00
rillig
1043e742ed lint: fix crash for error 108 (invalid type of unary operator) 2021-01-09 17:21:33 +00:00
rillig
fe02f4b2ac lint: add test for message 108, which currently crashes 2021-01-09 17:02:19 +00:00
christos
842f023a03 new pppd 2021-01-09 16:44:35 +00:00
christos
ff6bad0242 remove more 2021-01-09 16:41:09 +00:00
christos
56f8a139b1 remove useless files 2021-01-09 16:40:01 +00:00