bug-hurd
[Top][All Lists]
Advanced

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

Re: Yet another updated entropy patch


From: olafBuddenhagen
Subject: Re: Yet another updated entropy patch
Date: Fri, 13 Jul 2007 16:55:22 +0200
User-agent: Mutt/1.5.13 (2006-08-11)

Hi,

On Fri, Jul 13, 2007 at 01:04:01AM -0400, Michael Casadevall wrote:

> + void entropy_putchar(int c) {
[...]
> +   if (entropy_write_offset == ENTROPYBUFSIZE) {
> +     entropy_write_offset = 0;
> +   }
> +
> +   if (entropy_write_offset == ENTROPYBUFSIZE) {
> +     entropy_write_offset = 0;
> +   }// Deep magic (tells any read functiosn more entropy is available)

Surely you don't really want to check twice :-)

> + void entropy_putdata(void *data, int size) {
> +   // This function is used to copy data from memory pointers directly
> +   // into the bufffer
> +   io_req_t ior; // Used to tell reads that we got entropy
> +
> +   // See if we are initalized; if not, initalize the driver
> +   if (!entropy_init_done) {
> +     entropyinit();
> +   }
> +
> +   /* See if the buffer is full, if it is, bail out */
> +   if (entropy_write_offset+1 == entropy_read_offset) {
> +     return;
> +   }

You only check whether a single byte fits in, although you might write
more than one...

> +  // Try to grab a lock on the device, otherwise bail
> +   if (!simple_lock_try(&entropy_lock)) {
> +     return; // Bailing out
> +   }
> +
> +   // Lets advance the pointer on
> +   entropy_write_offset++;

Still incrementing before the actual write?

-antrik-




reply via email to

[Prev in Thread] Current Thread [Next in Thread]