Skip to contentSkip to conversation

random.c compiler warning

PATCH New René Scharfe 1 participant 1 message Oct 27, 2001 Random number driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 random.c compiler warning

Hi all,

the patch below removes a compiler warning in random.c. To be exact it's the first hunk of the patch that does it. There's a comparision between signed and unsigned values which triggers that warning.

The rest of the patch is just there for consistency and because it just looks better to me. Those sizeof()s were introduced in kernel 2.4.13, I just can't imagine why. Care to explain anyone?

René

drivers/char/random.c +4 -4
@@ -1246,7 +1246,7 @@
 	if (r->entropy_count < nbytes * 8 &&
 	    r->entropy_count < r->poolinfo.POOLBITS) {
 		int nwords = min(r->poolinfo.poolwords - r->entropy_count/32,
-				 sizeof(tmp) / 4);
+				 TMP_BUF_SIZE);
 
 		DEBUG_ENT("xfer %d from primary to %s (have %d, need %d)\n",
 			  nwords * 32,
@@ -1260,9 +1260,9 @@
 	if (r->extract_count > 1024) {
 		DEBUG_ENT("reseeding %s with %d from primary\n",
 			  r == sec_random_state ? "secondary" : "unknown",
-			  sizeof(tmp) * 8);
-		extract_entropy(random_state, tmp, sizeof(tmp), 0);
-		add_entropy_words(r, tmp, sizeof(tmp) / 4);
+			  TMP_BUF_SIZE * 32);
+		extract_entropy(random_state, tmp, TMP_BUF_SIZE * 4, 0);
+		add_entropy_words(r, tmp, TMP_BUF_SIZE);
 		r->extract_count = 0;
 	}
 }