-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On 11/2/14 5:13 PM, Bruce Evans wrote:
> % - % -    KASSERT(random_adaptor != NULL, ("No active random
> adaptor in %s", __func__)); %  } % %  void
> 
> Lots of style bugs (long lines, use of the __func__ obfuscation,
> and general verboseness).

What would you recommend doing for cases like this?  Do we just do
KASSERT without the __func__ and rely on ddb to provide the
information in backtrace or something else?

Speaking for long lines -- I usually use the MTA's default so the diff
won't wrap.  style(9) is a little bit vague here, what should new code
appear like?

> % @@ -256,11 +258,15 @@ random_adaptor_read(struct cdev *dev
> __unused, str %          /* Let the entropy source do any post-read
> cleanup. */ %          (random_adaptor->ra_read)(NULL, 1); % % -
> free(random_buf, M_ENTROPY); % +        if (nbytes !=
> uio->uio_resid && (error == ERESTART || % +            error ==
> EINTR) ) % +            error = 0;    /* Return partial read, not
> error. */
> 
> This adjustment has no effect.  Upper layers already do it for
> these 2 errors and one more.  Other cases remain broken.
> 
> It is simpler to do nothing.  Let upper layers get it right or
> wrong. Doesn't matter much either way.

Will remove these two portions of the change.

> % +
> 
> More style bugs.  Extra blank line here.  Space bereofe parentheses
> above.
> 
> %      } % - %      sx_sunlock(&random_adaptors_lock); % % +
> free(random_buf, M_ENTROPY); % +
> 
> Extra blank lines are sprinkled randomly.  Mostly added, but one
> was removed. There is an extra blank line after the sx_slock() that
> separates it from the blocks(s) of code that it locks; the removed
> one used the same style.

Will change the code to consistently use no blank line after
sx_slock() and before sx_sunlock() if that's correct, can you confirm?

Cheers,
-----BEGIN PGP SIGNATURE-----

iQIcBAEBCgAGBQJUVz4HAAoJEJW2GBstM+nsZnkP/0PDU6SvwEG94w/csmWiWRuE
IhhmH3oKz+LAzsU7pGUPpyE+UqWaMhRod6CHH9Io7EaJmZ9gsoMD29KWSdrYhWmS
eMuZIt/vNkHGd+4SpFMUVq15s1gmRO2AK7wev6PZ1lOeqlJQtEkelnwaO7gWZdyp
yWjdBW3MOOuVPR/kj0qF7Nx3nuCPkixO/SldXbMOeM0ofKhZw2DkiJmjSDx17Mk7
q/x2cuui4+nDxyJleFeLDpZqI+zaII/2yGly8OMzmhOsaAUtQrhxFM5I8Py/E85t
yIK6U01tuRu1pVMNtqY1EgFqEkzRAr/kWG/wHZOuiITNroGye5J+u9VLaBVgCmQF
hJW2Wthq2qFaWX2oqlSamHSss1Mt048iIzIzQd7GhwRYb6Be5IGPaqI2QOyKAYeE
ojHvddkL30xIVLwM9qkFmIiyOvaC4gi/dSc6cbSEEYarTLqsIUZlJ1Xx5X5OK9y9
sAsIIo+0v4njB/cv9x4e5aeDXsRU1ABFHk4IUb7hBv2/Um9FRTuVKyKDWiEm4mRV
U/uDxRDIFc0KAFj0bEtJXyeB/GsGsYqlba63Z978QQUvtlk7Rjtq8hDBks+I6CcC
Hb8UOttzY+jS/XDxphNw5eXeg6rgy0v6isLqSAJvmwnyrXCUPJF5oMYxUla3lYrc
QzxqUTKnPyyid4Hl+7n9
=ixEW
-----END PGP SIGNATURE-----
Index: sys/dev/random/random_adaptors.c
===================================================================
--- sys/dev/random/random_adaptors.c	(revision 274006)
+++ sys/dev/random/random_adaptors.c	(working copy)
@@ -210,7 +210,6 @@ random_adaptor_read(struct cdev *dev __unused, str
 	random_buf = malloc(PAGE_SIZE, M_ENTROPY, M_WAITOK);
 
 	sx_slock(&random_adaptors_lock);
-
 	KASSERT(random_adaptor != NULL, ("No active random adaptor in %s", __func__));
 
 	/* Let the entropy source do any pre-read setup. */
@@ -234,15 +233,15 @@ random_adaptor_read(struct cdev *dev __unused, str
 		(random_adaptor->ra_read)(NULL, 0);
 	}
 
+	/*
+	 * The read-rate stuff is a rough indication of the instantaneous
+	 * read rate, used to increase the use of 'live' entropy sources
+	 * when lots of reads are done.
+	 */
 	mtx_lock(&random_read_rate_mtx);
-
-	/* The read-rate stuff is a rough indication of the instantaneous read rate,
-	 * used to increase the use of 'live' entropy sources when lots of reads are done.
-	 */
 	nbytes = (uio->uio_resid + 32 - 1)/32; /* Round up to units of 32 */
 	random_adaptor_read_rate_cache += nbytes*32;
 	random_adaptor_read_rate_cache = MIN(random_adaptor_read_rate_cache, 32);
-
 	mtx_unlock(&random_read_rate_mtx);
 
 	if (error == 0) {
@@ -257,11 +256,6 @@ random_adaptor_read(struct cdev *dev __unused, str
 
 		/* Let the entropy source do any post-read cleanup. */
 		(random_adaptor->ra_read)(NULL, 1);
-
-		if (nbytes != uio->uio_resid && (error == ERESTART ||
-		    error == EINTR) )
-			error = 0;	/* Return partial read, not error. */
-
 	}
 	sx_sunlock(&random_adaptors_lock);
 
@@ -296,11 +290,9 @@ random_adaptor_write(struct cdev *dev __unused, st
 #ifdef RANDOM_DEBUG
 	printf("random: %s %zd\n", __func__, uio->uio_resid);
 #endif
-
 	random_buf = malloc(PAGE_SIZE, M_ENTROPY, M_WAITOK);
 
 	sx_slock(&random_adaptors_lock);
-
 	KASSERT(random_adaptor != NULL, ("No active random adaptor in %s", __func__));
 
 	nbytes = uio->uio_resid;
@@ -317,15 +309,9 @@ random_adaptor_write(struct cdev *dev __unused, st
 		KASSERT(random_adaptor != NULL, ("No active random adaptor in %s",
 		    __func__));
 	}
-
 	sx_sunlock(&random_adaptors_lock);
 
-	if (nbytes != uio->uio_resid && (error == ERESTART ||
-	    error == EINTR) )
-		error = 0;	/* Partial write, not error. */
-
 	free(random_buf, M_ENTROPY);
-
 	return (error);
 }
 
@@ -339,7 +325,6 @@ random_adaptor_poll(struct cdev *dev __unused, int
 #endif
 
 	sx_slock(&random_adaptors_lock);
-
 	KASSERT(random_adaptor != NULL, ("No active random adaptor in %s", __func__));
 
 	if (events & (POLLIN | POLLRDNORM)) {
@@ -348,7 +333,6 @@ random_adaptor_poll(struct cdev *dev __unused, int
 		else
 			selrecord(td, &rsel);
 	}
-
 	sx_sunlock(&random_adaptors_lock);
 
 	return (events);
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to