path: root/include
diff options
authorConrad Meyer <cem@FreeBSD.org>2019-12-14 08:28:10 +0000
committerConrad Meyer <cem@FreeBSD.org>2019-12-14 08:28:10 +0000
commitc62ff2800ba9e4b6e851ae71b1696b28920854b9 (patch)
tree2d922f3783a4ca82ff1e832dad3276bd4f973cfd /include
parent815db20425013129469fc0ebe9f8f00c88c58184 (diff)
Deprecate sranddev(3) API
It serves no useful purpose and wasn't as popular as its equally meritless cousin, srandomdev(3). Setting aside the problems with rand(3) in general, the problem with this interface is that the seed isn't shared with the caller (other than by attacking the output of the generator, which is trivial, but not a hallmark of pleasant API design). The (arguable) utility of rand(3) or random(3) is as a semi-fast simulation generator which produces consistent results from a given seed. These are mutually at odd. Furthermore, sometimes people got the mistaken impression that a high quality random seed meant a weak generator like rand(3) or random(3) could be used for things like cryptographic key generation. This is absolutely not so. The API was never part of a standard and was not widely used in tree. Existing in-tree uses have all been removed. Possible replacement in out of tree codebases: char buf[3]; time_t t; time(t); strftime(buf, sizeof(buf), "%S", gmtime(&t)); srand(atoi(buf)); Relnotes: yes
Notes: svn path=/head/; revision=355747
Diffstat (limited to 'include')
1 files changed, 6 insertions, 1 deletions
diff --git a/include/stdlib.h b/include/stdlib.h
index 0289980d17f0..50bda707a0d3 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -309,12 +309,17 @@ int rpmatch(const char *);
void setprogname(const char *);
int sradixsort(const unsigned char **, int, const unsigned char *,
-void sranddev(void);
void srandomdev(void);
long long
strtonum(const char *, long long, long long, const char **);
/* Deprecated interfaces, to be removed. */
+static inline void
+__attribute__((__deprecated__("sranddev to be removed in FreeBSD 13")))
strtoq(const char *, char **, int);