History log of /freebsd-current/usr.bin/random/randomize_fd.c
Revision Date Author Comments
# 5e3934b1 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

usr.bin: 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


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 06257a71 15-Feb-2020 Conrad Meyer <cem@FreeBSD.org>

random(6): Re-add undocumented support for floating point denominators

And document it in the manual page.

PR: 244139
Submitted by: Keith White <kwhite AT site.uottawa.ca> (earlier version)


# 92f7ba20 16-Jan-2020 Conrad Meyer <cem@FreeBSD.org>

random(6): Fix off-by-one

After r355693, random(6) -f sometimes fail to output all the lines of the
input file. This is because the range from which random indices are chosen
is too big, so occasionally the random selection doesn't correspond to any
line and nothing gets printed.

(Ed. note: Mea culpa. Working on r355693, I was confused by the sometime
use of 1-indexing, sometimes 0-indexing in randomize_fd().)

Submitted by: Ryan Moeller <ryan AT freqlabs.com>
X-MFC-With: r355693
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D23199


# c7b8411c 12-Dec-2019 Conrad Meyer <cem@FreeBSD.org>

random(6): produce random results

This program is trash and there's no reason to keep it in base. But as long as
we're shipping a silly program named 'random', let's actually make it random.


# 290dadbd 07-Jun-2016 Don Lewis <truckman@FreeBSD.org>

Fix a (false positive?) Argument cannot be negative coverity defect.

Rather than guarding close(fd) with an fd >= 0 test and setting fd
to -1 when it is closed to avoid a potential double-close, just
move the close() call after the conditional "goto make_token". This
moves the close() call totally outside the loop to avoid the
possibility of calling it twice. This should also prevent a Coverity
warning about checking fd for validity after it was previously passed
to read().

Reported by: Coverity
CID: 1355335
MFC after: 1 week
X-MFC with: r299484


# 7bfdbca5 11-May-2016 Conrad Meyer <cem@FreeBSD.org>

random(6): Fix double-close

In the case where a file lacks a trailing newline, there is some "evil" code to
reverse goto the tokenizing code ("make_token") for the final token in the
file. In this case, 'fd' is closed more than once. Use a negative sentinel
value to guard close(2), preventing the double close.

Ideally, this code would be restructured to avoid this ugly construction.

Reported by: Coverity
CID: 1006123
Sponsored by: EMC / Isilon Storage Division


# 6ae1554a 02-Oct-2015 Colin Percival <cperciva@FreeBSD.org>

Final step of eliminating the "games" distribution: Merge src/games
(or what's left of it, at least) into src/usr.bin.

This change will not be MFCed.

Discussed at: EuroBSDCon 2014
Committed from: EuroBSDCon 2015