Skip to contentSkip to conversation

random.c MIN cleanup

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 MIN cleanup

Hello,

the MIN macro in random.c can be done away with. The patch below does just that.

MIN was used two times, in both cases comparing two unsigned values. The "builtin" min can be used instead.

René

drivers/char/random.c +2 -6
@@ -406,10 +406,6 @@
  * 
  *****************************************************************/
 
-#ifndef MIN
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
-#endif
-
 /*
  * Unfortunately, while the GCC optimizer for the i386 understands how
  * to optimize a static rotate left of x bits, it doesn't know how to
@@ -1359,7 +1355,7 @@
 #endif
 		
 		/* Copy data to destination buffer */
-		i = MIN(nbytes, HASH_BUFFER_SIZE*sizeof(__u32)/2);
+		i = min(nbytes, HASH_BUFFER_SIZE*sizeof(__u32)/2);
 		if (flags & EXTRACT_ENTROPY_USER) {
 			i -= copy_to_user(buf, (__u8 const *)tmp, i);
 			if (!i) {
@@ -1586,7 +1582,7 @@
 	size_t		c = count;
 
 	while (c > 0) {
-		bytes = MIN(c, sizeof(buf));
+		bytes = min(c, sizeof(buf));
 
 		bytes -= copy_from_user(&buf, p, bytes);
 		if (!bytes) {