[ovs-dev] [PATCH 2/3] uuid: Break code to read /dev/urandom into a new module.

Ben Pfaff blp at nicira.com
Thu Aug 12 22:46:56 UTC 2010


On Thu, Aug 12, 2010 at 02:30:42PM -0700, Justin Pettit wrote:
> On Aug 12, 2010, at 11:12 AM, Ben Pfaff wrote:
> 
> > +    fd = open(urandom, O_RDONLY);
> > +    if (fd < 0) {
> > +        VLOG_ERR("%s: open failed (%s)", urandom, strerror(errno));
> > +        return errno ? errno : EINVAL;
> > +    }
> > +    error = read_fully(fd, buffer, n, &bytes_read);
> > +    if (error) {
> > +        VLOG_ERR("%s: read error (%s)", urandom,
> > +                 error == EOF ? "unexpected end of file" : strerror(error));
> > +        return error;
> > +    }
> 
> Did you want to call close(fd) before returning on this error?

I did.  Thanks.

> > +/* Initializes 'buffer' with 'n' bytes of high-quality random numbers.  Exits
> > + * if an error occurs. */
> > +void
> > +get_entropy_or_die(void *buffer, size_t n)
> 
> I love this function's name.

I am truly an artist.




More information about the dev mailing list