Commit 90b75ee5 authored by Matt Mackall's avatar Matt Mackall Committed by Linus Torvalds

random: clean up checkpatch complaints

Signed-off-by: default avatarMatt Mackall <mpm@selenic.com>
Cc: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 03021904
...@@ -272,7 +272,7 @@ static int random_write_wakeup_thresh = 128; ...@@ -272,7 +272,7 @@ static int random_write_wakeup_thresh = 128;
static int trickle_thresh __read_mostly = INPUT_POOL_WORDS * 28; static int trickle_thresh __read_mostly = INPUT_POOL_WORDS * 28;
static DEFINE_PER_CPU(int, trickle_count) = 0; static DEFINE_PER_CPU(int, trickle_count);
/* /*
* A pool of size .poolwords is stirred with a primitive polynomial * A pool of size .poolwords is stirred with a primitive polynomial
...@@ -372,9 +372,10 @@ static DECLARE_WAIT_QUEUE_HEAD(random_read_wait); ...@@ -372,9 +372,10 @@ static DECLARE_WAIT_QUEUE_HEAD(random_read_wait);
static DECLARE_WAIT_QUEUE_HEAD(random_write_wait); static DECLARE_WAIT_QUEUE_HEAD(random_write_wait);
#if 0 #if 0
static int debug = 0; static int debug;
module_param(debug, bool, 0644); module_param(debug, bool, 0644);
#define DEBUG_ENT(fmt, arg...) do { if (debug) \ #define DEBUG_ENT(fmt, arg...) do { \
if (debug) \
printk(KERN_DEBUG "random %04d %04d %04d: " \ printk(KERN_DEBUG "random %04d %04d %04d: " \
fmt,\ fmt,\
input_pool.entropy_count,\ input_pool.entropy_count,\
...@@ -551,7 +552,7 @@ static void credit_entropy_store(struct entropy_store *r, int nbits) ...@@ -551,7 +552,7 @@ static void credit_entropy_store(struct entropy_store *r, int nbits)
/* There is one of these per entropy source */ /* There is one of these per entropy source */
struct timer_rand_state { struct timer_rand_state {
cycles_t last_time; cycles_t last_time;
long last_delta,last_delta2; long last_delta, last_delta2;
unsigned dont_count_entropy:1; unsigned dont_count_entropy:1;
}; };
...@@ -624,7 +625,7 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num) ...@@ -624,7 +625,7 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num)
min_t(int, fls(delta>>1), 11)); min_t(int, fls(delta>>1), 11));
} }
if(input_pool.entropy_count >= random_read_wakeup_thresh) if (input_pool.entropy_count >= random_read_wakeup_thresh)
wake_up_interruptible(&random_read_wait); wake_up_interruptible(&random_read_wait);
out: out:
...@@ -677,7 +678,7 @@ void add_disk_randomness(struct gendisk *disk) ...@@ -677,7 +678,7 @@ void add_disk_randomness(struct gendisk *disk)
* *
*********************************************************************/ *********************************************************************/
static ssize_t extract_entropy(struct entropy_store *r, void * buf, static ssize_t extract_entropy(struct entropy_store *r, void *buf,
size_t nbytes, int min, int rsvd); size_t nbytes, int min, int rsvd);
/* /*
...@@ -704,7 +705,7 @@ static void xfer_secondary_pool(struct entropy_store *r, size_t nbytes) ...@@ -704,7 +705,7 @@ static void xfer_secondary_pool(struct entropy_store *r, size_t nbytes)
"(%d of %d requested)\n", "(%d of %d requested)\n",
r->name, bytes * 8, nbytes * 8, r->entropy_count); r->name, bytes * 8, nbytes * 8, r->entropy_count);
bytes=extract_entropy(r->pull, tmp, bytes, bytes = extract_entropy(r->pull, tmp, bytes,
random_read_wakeup_thresh / 8, rsvd); random_read_wakeup_thresh / 8, rsvd);
add_entropy_words(r, tmp, (bytes + 3) / 4); add_entropy_words(r, tmp, (bytes + 3) / 4);
credit_entropy_store(r, bytes*8); credit_entropy_store(r, bytes*8);
...@@ -744,7 +745,7 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min, ...@@ -744,7 +745,7 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
if (r->limit && nbytes + reserved >= r->entropy_count / 8) if (r->limit && nbytes + reserved >= r->entropy_count / 8)
nbytes = r->entropy_count/8 - reserved; nbytes = r->entropy_count/8 - reserved;
if(r->entropy_count / 8 >= nbytes + reserved) if (r->entropy_count / 8 >= nbytes + reserved)
r->entropy_count -= nbytes*8; r->entropy_count -= nbytes*8;
else else
r->entropy_count = reserved; r->entropy_count = reserved;
...@@ -802,7 +803,7 @@ static void extract_buf(struct entropy_store *r, __u8 *out) ...@@ -802,7 +803,7 @@ static void extract_buf(struct entropy_store *r, __u8 *out)
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
} }
static ssize_t extract_entropy(struct entropy_store *r, void * buf, static ssize_t extract_entropy(struct entropy_store *r, void *buf,
size_t nbytes, int min, int reserved) size_t nbytes, int min, int reserved)
{ {
ssize_t ret = 0, i; ssize_t ret = 0, i;
...@@ -872,7 +873,6 @@ void get_random_bytes(void *buf, int nbytes) ...@@ -872,7 +873,6 @@ void get_random_bytes(void *buf, int nbytes)
{ {
extract_entropy(&nonblocking_pool, buf, nbytes, 0, 0); extract_entropy(&nonblocking_pool, buf, nbytes, 0, 0);
} }
EXPORT_SYMBOL(get_random_bytes); EXPORT_SYMBOL(get_random_bytes);
/* /*
...@@ -940,7 +940,7 @@ void rand_initialize_disk(struct gendisk *disk) ...@@ -940,7 +940,7 @@ void rand_initialize_disk(struct gendisk *disk)
#endif #endif
static ssize_t static ssize_t
random_read(struct file * file, char __user * buf, size_t nbytes, loff_t *ppos) random_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
{ {
ssize_t n, retval = 0, count = 0; ssize_t n, retval = 0, count = 0;
...@@ -1002,8 +1002,7 @@ random_read(struct file * file, char __user * buf, size_t nbytes, loff_t *ppos) ...@@ -1002,8 +1002,7 @@ random_read(struct file * file, char __user * buf, size_t nbytes, loff_t *ppos)
} }
static ssize_t static ssize_t
urandom_read(struct file * file, char __user * buf, urandom_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
size_t nbytes, loff_t *ppos)
{ {
return extract_entropy_user(&nonblocking_pool, buf, nbytes); return extract_entropy_user(&nonblocking_pool, buf, nbytes);
} }
...@@ -1045,8 +1044,7 @@ write_pool(struct entropy_store *r, const char __user *buffer, size_t count) ...@@ -1045,8 +1044,7 @@ write_pool(struct entropy_store *r, const char __user *buffer, size_t count)
return 0; return 0;
} }
static ssize_t static ssize_t random_write(struct file *file, const char __user *buffer,
random_write(struct file * file, const char __user * buffer,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
size_t ret; size_t ret;
...@@ -1064,8 +1062,7 @@ random_write(struct file * file, const char __user * buffer, ...@@ -1064,8 +1062,7 @@ random_write(struct file * file, const char __user * buffer,
return (ssize_t)count; return (ssize_t)count;
} }
static int static int random_ioctl(struct inode *inode, struct file *file,
random_ioctl(struct inode * inode, struct file * file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
int size, ent_count; int size, ent_count;
...@@ -1157,7 +1154,6 @@ void generate_random_uuid(unsigned char uuid_out[16]) ...@@ -1157,7 +1154,6 @@ void generate_random_uuid(unsigned char uuid_out[16])
/* Set the UUID variant to DCE */ /* Set the UUID variant to DCE */
uuid_out[8] = (uuid_out[8] & 0x3F) | 0x80; uuid_out[8] = (uuid_out[8] & 0x3F) | 0x80;
} }
EXPORT_SYMBOL(generate_random_uuid); EXPORT_SYMBOL(generate_random_uuid);
/******************************************************************** /********************************************************************
...@@ -1339,7 +1335,7 @@ ctl_table random_table[] = { ...@@ -1339,7 +1335,7 @@ ctl_table random_table[] = {
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
static __u32 twothirdsMD4Transform (__u32 const buf[4], __u32 const in[12]) static __u32 twothirdsMD4Transform(__u32 const buf[4], __u32 const in[12])
{ {
__u32 a = buf[0], b = buf[1], c = buf[2], d = buf[3]; __u32 a = buf[0], b = buf[1], c = buf[2], d = buf[3];
...@@ -1487,8 +1483,8 @@ __u32 secure_tcpv6_sequence_number(__be32 *saddr, __be32 *daddr, ...@@ -1487,8 +1483,8 @@ __u32 secure_tcpv6_sequence_number(__be32 *saddr, __be32 *daddr,
*/ */
memcpy(hash, saddr, 16); memcpy(hash, saddr, 16);
hash[4]=((__force u16)sport << 16) + (__force u16)dport; hash[4] = ((__force u16)sport << 16) + (__force u16)dport;
memcpy(&hash[5],keyptr->secret,sizeof(__u32) * 7); memcpy(&hash[5], keyptr->secret, sizeof(__u32) * 7);
seq = twothirdsMD4Transform((const __u32 *)daddr, hash) & HASH_MASK; seq = twothirdsMD4Transform((const __u32 *)daddr, hash) & HASH_MASK;
seq += keyptr->count; seq += keyptr->count;
...@@ -1538,10 +1534,10 @@ __u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr, ...@@ -1538,10 +1534,10 @@ __u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr,
* Note that the words are placed into the starting vector, which is * Note that the words are placed into the starting vector, which is
* then mixed with a partial MD4 over random data. * then mixed with a partial MD4 over random data.
*/ */
hash[0]=(__force u32)saddr; hash[0] = (__force u32)saddr;
hash[1]=(__force u32)daddr; hash[1] = (__force u32)daddr;
hash[2]=((__force u16)sport << 16) + (__force u16)dport; hash[2] = ((__force u16)sport << 16) + (__force u16)dport;
hash[3]=keyptr->secret[11]; hash[3] = keyptr->secret[11];
seq = half_md4_transform(hash, keyptr->secret) & HASH_MASK; seq = half_md4_transform(hash, keyptr->secret) & HASH_MASK;
seq += keyptr->count; seq += keyptr->count;
...@@ -1556,10 +1552,7 @@ __u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr, ...@@ -1556,10 +1552,7 @@ __u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr,
* Choosing a clock of 64 ns period is OK. (period of 274 s) * Choosing a clock of 64 ns period is OK. (period of 274 s)
*/ */
seq += ktime_to_ns(ktime_get_real()) >> 6; seq += ktime_to_ns(ktime_get_real()) >> 6;
#if 0
printk("init_seq(%lx, %lx, %d, %d) = %d\n",
saddr, daddr, sport, dport, seq);
#endif
return seq; return seq;
} }
...@@ -1582,14 +1575,15 @@ u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport) ...@@ -1582,14 +1575,15 @@ u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport)
} }
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr, __be16 dport) u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr,
__be16 dport)
{ {
struct keydata *keyptr = get_keyptr(); struct keydata *keyptr = get_keyptr();
u32 hash[12]; u32 hash[12];
memcpy(hash, saddr, 16); memcpy(hash, saddr, 16);
hash[4] = (__force u32)dport; hash[4] = (__force u32)dport;
memcpy(&hash[5],keyptr->secret,sizeof(__u32) * 7); memcpy(&hash[5], keyptr->secret, sizeof(__u32) * 7);
return twothirdsMD4Transform((const __u32 *)daddr, hash); return twothirdsMD4Transform((const __u32 *)daddr, hash);
} }
...@@ -1617,13 +1611,9 @@ u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr, ...@@ -1617,13 +1611,9 @@ u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr,
seq += ktime_to_ns(ktime_get_real()); seq += ktime_to_ns(ktime_get_real());
seq &= (1ull << 48) - 1; seq &= (1ull << 48) - 1;
#if 0
printk("dccp init_seq(%lx, %lx, %d, %d) = %d\n",
saddr, daddr, sport, dport, seq);
#endif
return seq; return seq;
} }
EXPORT_SYMBOL(secure_dccp_sequence_number); EXPORT_SYMBOL(secure_dccp_sequence_number);
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment