Commit graph

487 commits

Author SHA1 Message Date
Warner Losh c0c066f86d config: Remove redundant code
since errx is marked dead2, we don't need this.

Noticed by:		jrtc27
Sponsored by:		Netflix
2024-06-06 15:48:38 -06:00
Dapeng Gao 5dda778db6 Use correct function declaration for yyerror
According to the POSIX standard at
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/yacc.html
`yyerror` should return `int`. Add unreachable since errx never returns.

Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D45447
2024-06-03 12:14:10 -06:00
Warner Losh 4d65a7c695 usr.sbin: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:24:01 -07:00
Warner Losh 0b8224d1cc Remove copyright strings ifdef'd out
We've ifdef'd out the copyright strings for some time now. Go ahead and
remove the ifdefs. Plus whatever other detritis was left over from other
recent removals. These copyright strings are present in the comments and
are largely from CSRG's attempt at adding their copyright to every
binary file (which modern interpretations of the license doesn't
require).

Sponsored by:		Netflix
2023-11-26 22:23:58 -07:00
Warner Losh 8a7b612037 usr.sbin: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by:		Netflix
2023-11-26 22:23:56 -07:00
John Baldwin eba230afba Purge more stray embedded $FreeBSD$ strings
These do not use __FBSDID but instead use bare char arrays.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41957
2023-09-25 07:54:56 -07:00
Warner Losh b2c76c41be Remove $FreeBSD$: one-line nroff pattern
Remove /^\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:15 -06:00
Warner Losh fa9896e082 Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:10 -06:00
Warner Losh d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh 42b388439b Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:23 -06:00
Warner Losh b3e7694832 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:16 -06:00
Simon J. Gerraty d9a4274795 Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
Kyle Evans b9c8f4900c config: drop reference to removed System_spec
Fixes the following warning:

yacc: w - the symbol System_spec is undefined
yacc: 3 rules never reduced

Reported by:	otis
Fixes:	6a836ea741 ("config(8): Remove obsolete 'config' directive.")
2023-02-24 13:16:19 -06:00
Mark Johnston 8c8574acb8 config: Include errno.h in mkmakefile.cc
Commit da88842029 ("config: error out on malformed env/hint lines")
added a reference to EINVAL.  In some configurations the bootstrap tools
build fails for lack of errno definitions.

Fixes:	da88842029 ("config: error out on malformed env/hint lines")
Reported by:	syzbot+b1a5d112a737d9a2be9b@syzkaller.appspotmail.com
2023-02-23 21:53:06 -05:00
Kyle Evans c04ad15ca7 config: address a number of Coverity issues
Highlights:
- Various memory leaks
- FILE* leaks
- `tsize` in moveifchanged() is only needed if !changed, and `from_sb`
    is only valid if !changed.
- Simplify trivially true expression
- Sanity check elfdump size output (+ fix variable sizes) (des@)

CID:	1471167, 1006391, 1505333, 1505275, 1505349, 1505306, 1505232
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D38643
2023-02-16 14:37:06 -06:00
Kyle Evans da88842029 config: error out on malformed env/hint lines
We need these to be assignments, error out if they're not.

While we're here, tag errout as __printflike so that the compiler will
sanity check the format string + args.

CID:	1505293
Reviewed by:	emaste, imp
Differential Revision:	https://reviews.freebsd.org/D38642
2023-02-16 14:37:05 -06:00
Kyle Evans b2c5a01722 config: push path() into moveifchanged()
Every caller path()s its arguments anyways, just simplify these and push
path() into moveifchanged().  This fixes a number of memory leaks in the
process since path() allocates memory, which we will now free().

While we're here, make sure we close from_fd/to_fd appropriately.

CID:	1471040, 1471714, 1472045, 1006907, 1006908
Reviewed by:	emaste, imp
Differential Revision:	https://reviews.freebsd.org/D38641
2023-02-16 14:36:42 -06:00
Kyle Evans f518229d55 config: fix some common issues with path() usage
None of the callers check that the allocation in path() failed, so let's
check in path() and abort instead of failing.

Along those lines, none of the callers seem to acknowledge that the
returned string needs to be free()d -- let's do that as well.  There are
a couple not addressed in this commit that will be addressed in a future
commit by pushing the path() call down into moveifchanged() instead and
freeing it properly there.

CID:	1505271, 1505250, 1505279
Reviewed by:	emaste, imp
2023-02-16 14:36:16 -06:00
Kyle Evans 83d7ed8af3 config: drop dependency on libsbuf
Use an std::stringstream instead.  get_word() and get_quoted_word() both
return a buffer that's presumed to not need release, so solve this by
returning a new special configword type that holds a string or eof/eol
state.  This cleans up caller checking for EOF/EOL to make it more
explicit what they're doing, at least in the EOL cases which previously
checked for NULL.

Sponsored by:	Klara, Inc.
Sponsored by:	NetApp, Inc.
Differential Revision:	https://reviews.freebsd.org/D38276
2023-02-08 22:56:10 -06:00
Kyle Evans 29c5f8bf9a config: drop dependency on libnv
Compile mkmakefile.c as C++ instead and use an std::unordered_map to
accomplish the same goal.

Reviewed by:	imp
Sponsored by:	Klara, Inc.
Sponsored by:	NetApp, Inc.
Differential Revision:	https://reviews.freebsd.org/D38275
2023-02-08 00:09:19 -06:00
Kyle Evans 2ffdc21324 config: make changes to allow some parts to build as C++
Highlights:
- Avoid keywords (this, not) as variable names
- Move yyparse into config.h with other declarations
- All declarations in config.h are assumed guilty until proven innocent
- Some const-correctness
- Casting malloc/calloc returns

Note that we're not building any C++ here yet, this will be introduced
in other commits to replace some of the lib dependencies.  Reducing the
number of FreeBSD-specific dependencies we have reduces some friction
for building our bootstrap tools independently in other environments.

Reviewed by:	imp
Sponsored by:	Klara, Inc.
Sponsored by:	NetApp, Inc.
Differential Revision:	https://reviews.freebsd.org/D38274
2023-02-08 00:09:10 -06:00
Mitchell Horne 1e6577831d config(5): drop mention of mips
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D37019
2022-10-17 15:12:12 -03:00
Jens Schweikhardt 3c405c7e83 Indicate which port gdb.1 and kgdb.1 come from. 2022-08-17 19:13:22 +02:00
Felix Johnson 191c624d95 config(5): Update upper limit for maxusers on 64-bit systems
The limit of 384 maxusers for auto configuration was only imposed on
32-bit systems. Document that maxusers scales above 384 based on memory
for 64-bit systems.

PR:		204938
MFC after:	3 days
Reported by:	David Höppner <0xffea@gmail.com>
2021-10-28 14:15:08 -04:00
Warner Losh 6a836ea741 config(8): Remove obsolete 'config' directive.
The "config" line in config files has been obsolete since FreeBSD 4.x
when we moved to having the boot loader pass in the root device. Remove
it.

MFC After:		1 week
Sponsored by:		Netflix
2021-06-17 15:17:18 -06:00
Warner Losh 2763a0928a config: style for '\0' and NULL
Use NULL for pointers instead of '0' (though hey are the same thing in
these cases). Ditto for using the zero character '\0' instead of a naked
0 (ditto).

Reviewed by:		markj@
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D29847
2021-04-19 16:10:12 -06:00
Gordon Bergling c8786bba8e Revert "config(8): Correct the mentioned paper in the SEE ALSO section"
config(8) was first imported from 4.4BSD.

Reported by:	rgrimes

This reverts commit e6ab1e365c.
2021-04-14 20:22:48 +02:00
Gordon Bergling e6ab1e365c config(8): Correct the mentioned paper in the SEE ALSO section
FreeBSD's version of the config(8) utility is based on 4.3BSD not
4.4BSD. So correct the mentioned paper in the SEE ALSO section.

Reported by:	imp
Reviewed by:	imp
X-MFC-with:	2b59392cb0
Differential Revision:	https://reviews.freebsd.org/D29701
2021-04-13 06:49:00 +02:00
Gordon Bergling 2b59392cb0 config(8): Mention the authors of a paper in the SEE ALSO section
Obtained from:	OpenBSD
MFC after:	1 week
2021-04-09 11:20:49 +02:00
Konstantin Belousov 69efe3695d config(8): remove support for -p
and other equivalent ways to request mcount-based profiling, like
'profile N' in kernel config.

Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D29529
2021-04-02 15:41:51 +03:00
John Baldwin bcaa6aa153 config: Fix typo in comment. 2021-02-01 13:13:36 -08:00
Gordon Bergling aeb0c721f5 config: Fix a few mandoc related errors
- new sentence, new line
- no blank before trailing delimiter

MFC after:	1 week
2020-12-19 13:11:44 +00:00
Mateusz Piotrowski f36e950b9b Do not use macros in the argument to -width
This patch improves the presentation of the FILES section dramatically.

MFC after:	2 weeks
2020-06-28 22:04:52 +00:00
Bryan Drewery 5dda1d0b82 config: Add no-ctfconvert support.
Bump CONFIGVERS to 600018 for this support.

Some files may purposely have debug info disabled or are *source files*
that attempt to run ctfconvert on them. Currently ctfconvert ignores
these errors but I have a change to make the errors real so we can
catch real problems like exceeding type limits.

Sponsored by:		Dell EMC
Reviewed by:		imp, cem, kevans
Differential Revision:	https://reviews.freebsd.org/D24535
2020-04-28 16:09:22 +00:00
Jason A. Harmening 31de6cad17 config(8): use sbuf to manage line buffers
PR:	245476
Reported by:	kevans
Reviewed by:	imp, kevans
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D24373
2020-04-12 02:42:42 +00:00
Kyle Evans 610acef538 config(8): "fix" a couple of buffer overflows
Recently added/changed lines in various kernel configs have caused some
buffer overflows that went undetected. These were detected with a config
built using -fno-common as these line buffers smashed one of our arrays,
then further triaged with ASAN.

Double the sizes; this is really not a great fix, but addresses the
immediate need until someone rewrites config. While here, add some bounds
checking so that we don't need to detect this by random bus errors or other
weird failures.

MFC after:	3 days
2020-04-07 14:14:59 +00:00
Kyle Evans a33e986417 config(8): fixes for -fno-common
Move this handful of definitions into main.c, properly declare these as
extern in config.h. This fixes the config(8) build with -fno-common.

Unexplained in my previous commit to gas, -fno-common will become the
default in GCC10 and LLVM11, so it's worth addressing these in advance.

MFC after:	3 days
2020-03-28 04:02:00 +00:00
Warner Losh f33a95bc86 Create ../compile
Give up the battle to keep extra files in $MACHINE/compile to keep the file in
the tree. Instead, create CDIR (usually ../compile) if it doesn't exist when
we're using a default build location (eg, not using -d). If it does, we do
nothing. This only affects people that do old-school builds, but it's bit me a
dozen times since last summer so time to fix the bug.
2020-02-24 16:41:16 +00:00
Warner Losh 6e773df698 Bump CONFIGVERS to 600017.
This change reflects the ability to change machine_arch in a config file. This
is useful for including one config in another and changing the machine_arch
in the second one.
2020-02-23 23:39:55 +00:00
Warner Losh 9bcb741864 Relax machine directives a little.
Currently, you can have multiple machine directives if they are otherwise
identical. Relax this so that only the machinename part is the same. This allows
one to change the machine arch in a different config file you've included easily.
2020-02-23 23:36:56 +00:00
Warner Losh 31719b4962 For valid arch values (really $MACHINE), remove references to alpha
and sparc64. Add references to arm64 and riscv

Reivewed by: cy@, bcr@
Differential Revision: https://reviews.freebsd.org/D23593
2020-02-10 17:16:54 +00:00
Baptiste Daroussin ef5312c38e config: do not link against libl, it is not needed
MFC after:	3 days
2019-09-10 07:14:39 +00:00
Warner Losh 2bc9c25782 Fix small bug in wrapping introduced in r325955.
When local support was fixed, it introduced a minor bug in formatting. We don't
increment the lpos by enouogh, so lines are a little too long. Adjust to be
correct now with variable length srcprefix.
2019-08-17 02:36:42 +00:00
Warner Losh 44fcf30bdd Add nowerror and local to the list of tokens. 2019-08-17 02:36:37 +00:00
Warner Losh 622c9cdd31 Move initializations of config earlier.
Inizialize global variables earlier in the process. It doesn't matter today, but
may in the future if we want to access these lists earlier in config's run.
2019-08-17 02:35:53 +00:00
Warner Losh ecc7fd09a6 Catch mkheaders.c up to the removal of counted device support in 2005.
mkheaders.c hasn't made headers in ~15 years. Belatedly update the comments to
reflect that all it does these days is warn about 'device foo' lines in the
config where we don't know what a 'foo' is.

Remove extra includes too. These also haven't been needed for 15 years and
weren't removed at the time the comment wasn't updated...
2019-08-15 17:21:38 +00:00
Warner Losh 0a829d84d0 Sort getopt(3) options and case statements per style(9)
Alphebetize the options and cases without regard for case.
2019-08-15 17:06:53 +00:00
Emmanuel Vadot 91221f548e config: Only warn if duplicate option/device comes from the same file
This is useful for arm (possibly other arches too) where we want to have
a GENERIC kernel that only include files for the different SoC. Since
multiple SoCs/Board needs the same device we would need to do either :

    Include the device in a generic file
    Include the device in each file that really needs it

Option 1 works but if someone wants to create a specific kernel config
(which isn't uncommon for embedded system), he will need to add a lots
of nodevice to it.

Option 2 also works but produce a lots of warnings.

Reviewed by:	kevans
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D19424
2019-04-16 20:08:19 +00:00
Kyle Evans aebda5bf06 config(8): replace opteq with a call to strcasecmp
This obscures the comparison slightly less; when option name appear in
files, they are case-insensitive.

MFC after:	1 week
2019-04-15 21:20:06 +00:00
Kyle Evans ac0a7e2a3c config(8): Remove all instances of an option when opting out
Quick follow-up to r342362: options can appear multiple times now, so
clean up all of them as needed. For non-OPTIONS options, this has no effect
since they're already de-duplicated.

MFC after:	1 week
X-MFC-With:	r342362
2018-12-22 06:08:06 +00:00