Index: sys/kern/kern_fail.c =================================================================== --- sys/kern/kern_fail.c +++ sys/kern/kern_fail.c @@ -167,7 +167,7 @@ volatile bool fe_stale; enum fail_point_t fe_type; /**< type of entry */ int fe_arg; /**< argument to type (e.g. return value) */ - int fe_prob; /**< likelihood of firing in millionths */ + u_int fe_prob; /**< likelihood of firing in millionths */ int32_t fe_count; /**< number of times to fire, -1 means infinite */ pid_t fe_pid; /**< only fail for this process */ struct fail_point *fe_parent; /**< backpointer to fp */ @@ -568,7 +568,7 @@ continue; if (ent->fe_prob < PROB_MAX && - ent->fe_prob < random() % PROB_MAX) + ent->fe_prob < arc4random() % PROB_MAX) continue; if (ent->fe_pid != NO_PID && ent->fe_pid != curproc->p_pid) Index: sys/kern/kern_synch.c =================================================================== --- sys/kern/kern_synch.c +++ sys/kern/kern_synch.c @@ -607,7 +607,7 @@ * run at regular intervals. */ callout_reset_sbt(&loadav_callout, - SBT_1US * (4000000 + (int)(random() % 2000001)), SBT_1US, + SBT_1US * (4000000 + (arc4random() % 2000001)), SBT_1US, loadav, NULL, C_DIRECT_EXEC | C_PREL(32)); } Index: sys/net/altq/altq_classq.h =================================================================== --- sys/net/altq/altq_classq.h +++ sys/net/altq/altq_classq.h @@ -152,7 +152,7 @@ _getq_random(class_queue_t *q) { struct mbuf *m; - int i, n; + u_int i, n; if ((m = qtail(q)) == NULL) return NULL; @@ -161,7 +161,7 @@ else { struct mbuf *prev = NULL; - n = random() % qlen(q) + 1; + n = arc4random() % qlen(q) + 1; for (i = 0; i < n; i++) { prev = m; m = m->m_nextpkt; Index: sys/netinet/cc/cc_cdg.c =================================================================== --- sys/netinet/cc/cc_cdg.c +++ sys/netinet/cc/cc_cdg.c @@ -500,7 +500,7 @@ static inline int prob_backoff(long qtrend) { - int backoff, idx, p; + unsigned int backoff, idx, p; backoff = (qtrend > ((MAXGRAD * V_cdg_exp_backoff_scale) << D_P_E)); @@ -512,8 +512,8 @@ idx = qtrend; /* Backoff probability proportional to rate of queue growth. */ - p = (INT_MAX / (1 << EXP_PREC)) * probexp[idx]; - backoff = (random() < p); + p = (UINT_MAX / (1 << EXP_PREC)) * probexp[idx]; + backoff = (arc4random() < p); } return (backoff); Index: sys/netinet/cc/cc_chd.c =================================================================== --- sys/netinet/cc/cc_chd.c +++ sys/netinet/cc/cc_chd.c @@ -84,8 +84,8 @@ */ #define CC_CHD_DELAY 0x02000000 -/* Largest possible number returned by random(). */ -#define RANDOM_MAX INT_MAX +/* Largest possible number returned by arc4random(). */ +#define RANDOM_MAX UINT_MAX static void chd_ack_received(struct cc_var *ccv, uint16_t ack_type); static void chd_cb_destroy(struct cc_var *ccv); @@ -158,7 +158,7 @@ { unsigned long p, rand; - rand = random(); + rand = arc4random(); if (qdly < V_chd_qthresh) { chd_data->loss_compete = 0; Index: sys/netinet/cc/cc_hd.c =================================================================== --- sys/netinet/cc/cc_hd.c +++ sys/netinet/cc/cc_hd.c @@ -79,8 +79,8 @@ #include -/* Largest possible number returned by random(). */ -#define RANDOM_MAX INT_MAX +/* Largest possible number returned by arc4random(). */ +#define RANDOM_MAX UINT_MAX static void hd_ack_received(struct cc_var *ccv, uint16_t ack_type); static int hd_mod_init(void); @@ -119,7 +119,7 @@ p = (RANDOM_MAX / 100) * V_hd_pmax; } - return (random() < p); + return (arc4random() < p); } /* Index: sys/netpfil/ipfw/ip_dn_io.c =================================================================== --- sys/netpfil/ipfw/ip_dn_io.c +++ sys/netpfil/ipfw/ip_dn_io.c @@ -405,7 +405,7 @@ if (fs->fs.flags & DN_QSIZE_BYTES) p_b = div64((p_b * len) , fs->max_pkt_size); if (++q->count == 0) - q->random = random() & 0xffff; + q->random = arc4random() & 0xffff; else { /* * q->count counts packets arrived since last drop, so a greater @@ -414,7 +414,7 @@ if (SCALE_MUL(p_b, SCALE((int64_t)q->count)) > q->random) { q->count = 0; /* After a drop we calculate a new random value. */ - q->random = random() & 0xffff; + q->random = arc4random() & 0xffff; return (1); /* drop */ } } @@ -511,7 +511,7 @@ ni->tot_pkts++; if (drop) goto drop; - if (f->plr && random() < f->plr) + if (f->plr && arc4random() < f->plr) goto drop; #ifdef NEW_AQM /* Call AQM enqueue function */ @@ -583,7 +583,7 @@ if (!pf || pf->samples_no == 0) return 0; - index = random() % pf->samples_no; + index = arc4random() % pf->samples_no; bits = div64((uint64_t)pf->samples[index] * s->link.bandwidth, 1000); if (index >= pf->loss_level) { struct dn_pkt_tag *dt = dn_tag_get(m); Index: sys/netpfil/ipfw/ip_dn_private.h =================================================================== --- sys/netpfil/ipfw/ip_dn_private.h +++ sys/netpfil/ipfw/ip_dn_private.h @@ -265,7 +265,7 @@ /* RED parameters */ int avg; /* average queue length est. (scaled) */ int count; /* arrivals since last RED drop */ - int random; /* random value (scaled) */ + u_int random; /* random value (scaled) */ uint64_t q_time; /* start of queue idle time */ #ifdef NEW_AQM void *aqm_status; /* per-queue status variables*/ Index: sys/vm/memguard.c =================================================================== --- sys/vm/memguard.c +++ sys/vm/memguard.c @@ -447,7 +447,7 @@ if ((memguard_options & MG_GUARD_ALLLARGE) != 0 && size >= PAGE_SIZE) return (1); if (memguard_frequency > 0 && - (random() % 100000) < memguard_frequency) { + (arc4random() % 100000) < memguard_frequency) { memguard_frequency_hits++; return (1); }