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

Justin Pettit jpettit at nicira.com
Thu Aug 12 21:30:42 UTC 2010


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?

> +/* 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.

--Justin






More information about the dev mailing list