[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] PATCH: 21/25: Use random_r for random numbers



"Daniel P. Berrange" <berrange redhat com> wrote:
> How about this then....

Looks fine.  Thanks!

> BTW, what's good practice for actually initializing a seed ?
>
>  time() ?
>  time() ^ getpid() ?
>
> anything better ?

You could mix in some more get*id numbers.
If we really care, using gnulib's gethrxtime module
would be nice, but parts of it are GPL'd.
Here's part of coreutils' gl/lib/rand-isaac.c:

void
isaac_seed (struct isaac_state *s)
{
  isaac_seed_start (s);

  { pid_t t = getpid ();   ISAAC_SEED (s, t); }
  { pid_t t = getppid ();  ISAAC_SEED (s, t); }
  { uid_t t = getuid ();   ISAAC_SEED (s, t); }
  { gid_t t = getgid ();   ISAAC_SEED (s, t); }

  {
    xtime_t t = gethrxtime ();
    ISAAC_SEED (s, t);
  }

  isaac_seed_finish (s);
}

> diff --git a/Makefile.maint b/Makefile.maint

ACK


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]