Commit Graph

127 Commits

Author SHA1 Message Date
Warner Losh
b2c76c41be Remove $FreeBSD$: one-line nroff pattern
Remove /^\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:15 -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
1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Warner Losh
42b388439b Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:23 -06:00
Jessica Clarke
587458b7d6 rpcgen: Perform shell-style word expansion on RPCGEN_CPP
Up until recently, CPP has been a list of space-separated words, with no
quotes, backslashes or other characters with special meaning to a shell.
However, as of 8fad2cda93, (escaped) quotes appear in CPP, and the
rudimentary parser in rpcgen is insufficient, since it will leave the
escaped quotes as escaped rather than performing one level of expansion
as would be done by a shell (whether in a script or a Makefile).

Rather than hack around this in all the places RPCGEN_CPP gets set,
implement proper expansion inside rpcgen. Note that this only deals with
a subset of shell syntax, since we don't handle any of:

  | & ; < > ( ) $ ` * ? [ # ˜ = %

having special meaning (with the exception of how a backslash behaves
inside double quotes, where \$ means a literal $ inside double quotes
but \a means a literal \a), instead using their literal value, but those
are all reasonable restrictions, and can be worked around by avoiding
their use; what's important is that we get the quoting and splitting
right.

This fixes -Winvalid-pp-token spew during build${libcompat}.

Reviewed by:	brooks
Fixes:		8fad2cda93 ("bsd.compat.mk: Provide new CPP and sub-make variables")
Differential Revision:	https://reviews.freebsd.org/D41013
2023-07-14 02:35:25 +01:00
Jessica Clarke
9d843ba324 rpcgen: Clarify behaviour for idx
The re-initialisation of idx in the later else branch is a bit hidden,
and results in deviation from the earlier two paths. Use more consistent
code instead to make it abundantly clear what's going on.
2023-07-13 06:22:59 +01:00
Alfonso Gregory
1a7ac2bd24 Mark usage function as __dead2 in programs where it does not return
In most cases, usage does not return, so mark them as __dead2. For the
cases where they do return, they have not been marked __dead2.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/735
2023-07-07 10:45:18 -06:00
Simon J. Gerraty
090e9752d7 Additions to targets/pseudo/host-tools
More tools needed to be built for Linux.
These are the ones that "just work".
2023-04-27 14:16:49 -07:00
Simon J. Gerraty
d9a4274795 Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
John Baldwin
4fa1e855be rpcgen: Unindent a line not guarded by if (mtflag).
mtflag is used to add pthread mutex locking around operations to make
them thread-safe.  Setting the state to _SERVED is not conditional on
locking.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D37541
2022-12-04 16:32:03 -08:00
John Baldwin
f0b58b1901 rpcgen: Don't free() a pointer after realloc().
A successful realloc() already frees the old pointer.

Reported by:	GCC -Wuse-after-free
Reviewed by:	brooks, imp, emaste
Differential Revision:	https://reviews.freebsd.org/D37540
2022-12-04 16:31:35 -08:00
Brooks Davis
7c8b268a12 rpcgen: make compiler arglist allocation dynamic
Limit argmax to an absurdly large value prevent overflow (no overflow
possible on FreeBSD due to ARG_MAX).

In CheriBSD we exceed the 19 non-NULL arguments in the static array.  Add
a simple size doubling allocator and increase the default to 32.

GC remnants of support for fixed arguments.

Reviewed by:	archardson (prior version), James Clarke (prior version)
MFC after:	1 week
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D21971
2019-10-15 16:05:17 +00:00
Warner Losh
074170fb81 Free some variables before they go out of scope.
CID: 92074, 270099
2017-12-28 05:33:34 +00:00
Warner Losh
e893031d91 Plug two resource leaks.
CID: 92077, 92074
2017-12-28 05:33:29 +00:00
Bryan Drewery
ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Pedro F. Giffuni
f5ab496e62 rpcgen(1): Check getrlimit() return for generated code.
Obtained from:	NetBSD (CVS rev 1.27, 1.28)
MFC after:	1 week
2017-01-12 14:44:41 +00:00
Pedro F. Giffuni
e9ed334fd2 rpcgen(1): Avoid unused variable warning on generated code.
Avoid "unused variable 'i'" warnings in generated .c files by only
emitting the "int i;" for non-opaque arrays. Opaque arrays use
xdr_opaque() rather than iterating over the array.

Obtained from:	OpenBSD (CVS rev 1.28)
MFC after:	1 week
2017-01-11 23:05:29 +00:00
Alan Somers
398b756be8 Remove dead code in rpc_parse.c
It's been dead ever since it was imported from TI-RPC in 1995.  The dead
code is still present in Illumos today, but was removed from NetBSD in 2006.

Reported by:	Coverity
CID:		270097
Obtained from:	NetBSD
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
2017-01-04 17:39:20 +00:00
Marcelo Araujo
4b61b26b28 Use nitems() from sys/param.h.
MFC after:	2 weeks.
2016-08-16 15:53:05 +00:00
Conrad Meyer
1d1694a73b rpcgen(1): Tag crash() routine as __dead2 for static analyzers
Suggested by:	Coverity
CID:		1305464
Sponsored by:	EMC / Isilon Storage Division
2016-05-12 03:49:05 +00:00
Marcelo Araujo
7dbab9554d Use NULL for pointers.
strrchr(3) will return NULL if the character does not appears in
the string.

MFC after:	2 weeks.
2016-04-18 06:02:26 +00:00
Pedro F. Giffuni
80c7cc1c8f Cleanup unnecessary semicolons from utilities we all love. 2016-04-15 22:31:22 +00:00
Simon J. Gerraty
ccfb965433 Add META_MODE support.
Off by default, build behaves normally.
WITH_META_MODE we get auto objdir creation, the ability to
start build from anywhere in the tree.

Still need to add real targets under targets/ to build packages.

Differential Revision:       D2796
Reviewed by: brooks imp
2015-06-13 19:20:56 +00:00
Simon J. Gerraty
44d314f704 dirdeps.mk now sets DEP_RELDIR 2015-06-08 23:35:17 +00:00
Simon J. Gerraty
98e0ffaefb Merge sync of head 2015-05-27 01:19:58 +00:00
Eitan Adler
ba6663d9a1 rpcgen: fix use use of strcmp
strcmp only guarantee that it will return at least 1 if the string B
	is greater than that of string A.
2015-04-19 04:53:28 +00:00
Simon J. Gerraty
ee7b0571c2 Merge head from 7/28 2014-08-19 06:50:54 +00:00
Bryan Drewery
3675249837 Fix some rpcgen sample file issues.
* -Sc was generating code without a return type on main.
* -Sm was generating an unusable clean target due to undefined RM.
* -Sm was generating clean target with extra preceding space.

PR:		185582
Submitted by:	Pawel Biernacki <pawel.biernacki@gmail.com>
MFC after:	1 week
2014-06-06 17:38:37 +00:00
Simon J. Gerraty
fae50821ae Updated dependencies 2014-05-16 14:09:51 +00:00
Simon J. Gerraty
76b28ad6ab Updated dependencies 2014-05-10 05:16:28 +00:00
Simon J. Gerraty
3b8f084595 Merge head 2014-04-28 07:50:45 +00:00
Joel Dahl
7e700c30d2 mdoc: minor paragraph fixes. 2014-02-08 13:37:02 +00:00
Doug Rabson
7c31e86bcb Generate client sample code which compiles without warnings.
For 'rpcgen -a', generate a makefile where 'make clean all' works.
2013-12-26 11:38:33 +00:00
Simon J. Gerraty
7cf3a1c6b2 Updated dependencies 2013-03-11 17:21:52 +00:00
Simon J. Gerraty
f5f7c05209 Updated dependencies 2013-02-16 01:23:54 +00:00
Simon J. Gerraty
23090366f7 Sync from head 2012-11-04 02:52:03 +00:00
Ed Schouten
bf70becee6 More -Wmissing-variable-declarations fixes.
In addition to adding `static' where possible:

- bin/date: Move `retval' into extern.h to make it visible to date.c.
- bin/ed: Move globally used variables into ed.h.
- sbin/camcontrol: Move `verbose' into camcontrol.h and fix shadow warnings.
- usr.bin/calendar: Remove unneeded variables.
- usr.bin/chat: Make `line' local instead of global.
- usr.bin/elfdump: Comment out unneeded function.
- usr.bin/rlogin: Use _Noreturn instead of __dead2.
- usr.bin/tset: Pull `Ospeed' into extern.h.
- usr.sbin/mfiutil: Put global variables in mfiutil.h.
- usr.sbin/pkg: Remove unused `os_corres'.
- usr.sbin/quotaon, usr.sbin/repquota: Remove unused `qfname'.
2012-10-19 14:49:42 +00:00
Marcel Moolenaar
7750ad47a9 Sync FreeBSD's bmake branch with Juniper's internal bmake branch.
Requested by: Simon Gerraty <sjg@juniper.net>
2012-08-22 19:25:57 +00:00
Dimitry Andric
005576f63d In usr.bin/rpcgen/rpc_main.c, use execvp(3) instead of execv(3), so
rpcgen will search the current PATH for the preprocessor.  This makes it
possible to run a preprocessor built during the cross-tools stage of
buildworld.

MFC after:	1 week
2012-02-06 21:35:11 +00:00
Dimitry Andric
ade215fd5a Amend r231079 by properly shifting up the existing arguments in
rpc_main.c's insarg() function.  I had forgotten to put this in my patch
queue, sorry.

Pointy hat to:	me
MFC after:	1 week
2012-02-06 12:08:41 +00:00
Dimitry Andric
0dac0ed841 Let rpcgen(1) support an environment variable RPCGEN_CPP to find the C
preprocessor to run.  Previously, it always ran /usr/bin/cpp, unless you
used the -Y option, and even then you could not set the basename.  It
also attempted to run /usr/ccs/lib/cpp for SVR4 compatibility, but this
is obsolete, and has been removed.

Note that setting RPCGEN_CPP to a command with arguments is supported,
though the command line parsing is simplistic.  However, setting it to
e.g. "gcc46 -E" or "clang -E" will lead to problems, because both gcc
and clang in -E mode will consider files with unknown extensions (such
as .x) as object files, and attempt to link them.

This could be worked around by also adding "-x c", but it is much safer
to set RPCGEN_CPP to e.g. "cpp46" or "clang-cpp" instead.

MFC after:	1 week
2012-02-06 12:03:21 +00:00
Dimitry Andric
faabfb8aff In usr.bin/rpcgen/rpc_main.c, properly check the return value of
strlcpy(), in addition to checking that of strlcat().

MFC after:	1 week
2012-02-05 20:55:38 +00:00
Ed Schouten
b3608ae18f Replace index() and rindex() calls with strchr() and strrchr().
The index() and rindex() functions were marked LEGACY in the 2001
revision of POSIX and were subsequently removed from the 2008 revision.
The strchr() and strrchr() functions are part of the C standard.

This makes the source code a lot more consistent, as most of these C
files also call into other str*() routines. In fact, about a dozen
already perform strchr() calls.
2012-01-03 18:51:58 +00:00
Ulrich Spörlein
487ac9ac21 Spelling fixes for usr.bin/ 2011-12-30 11:02:40 +00:00
Xin LI
682b64839a Use strlcpy().
MFC after:	1 month
2011-07-11 05:31:52 +00:00
Ben Laurie
9bde021a87 Fix clang warnings.
Note: these were actually bugs (printf with no format string).

Approved by: philip (mentor)
2011-05-18 20:52:52 +00:00
Xin LI
3f65dafda3 Plug a memory leak.
MFC after:	2 weeks
2010-05-06 21:57:38 +00:00
Ed Schouten
b7946da96b Build usr.bin/ with WARNS=6 by default.
Also add some missing $FreeBSD$ to keep svn happy.
2010-01-02 10:27:05 +00:00
Ed Schouten
ef636796f6 ANSIfy various tools in usr.bin/.
Most of these tools properly build at WARNS=6, except for their K&R
function declarations. Fix this, so we can bump WARNS as well.
2010-01-02 10:09:20 +00:00
Xin LI
821df508e8 Revert most part of 200420 as requested, as more review and polish is
needed.
2009-12-13 03:14:06 +00:00