diff options
author | David Howells <dhowells@redhat.com> | 2013-04-04 16:32:28 +0100 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-04-09 15:16:50 -0400 |
commit | ad147d011f4e9d4e4309f7974fd19c7f875ccb14 (patch) | |
tree | 97b2b327e036c0001e6a597da1f7802a226f1453 /fs/proc | |
parent | f805442e130c6eeb6c25bc5c3b3cefc27ab6dcec (diff) | |
download | blackbird-op-linux-ad147d011f4e9d4e4309f7974fd19c7f875ccb14.tar.gz blackbird-op-linux-ad147d011f4e9d4e4309f7974fd19c7f875ccb14.zip |
procfs: Clean up huge if-statement in __proc_file_read()
Switch huge if-statement in __proc_file_read() around. This then puts the
single line loop break immediately after the if-statement and allows us to
de-indent the huge comment and make it take fewer lines. The code following
the if-statement then follows naturally from the call to dp->read_proc().
Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'fs/proc')
-rw-r--r-- | fs/proc/generic.c | 98 |
1 files changed, 47 insertions, 51 deletions
diff --git a/fs/proc/generic.c b/fs/proc/generic.c index 5453f1c0b70c..a6a1cb5d589d 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c @@ -71,59 +71,55 @@ __proc_file_read(struct file *file, char __user *buf, size_t nbytes, count = min_t(size_t, PROC_BLOCK_SIZE, nbytes); start = NULL; - if (dp->read_proc) { - /* - * How to be a proc read function - * ------------------------------ - * Prototype: - * int f(char *buffer, char **start, off_t offset, - * int count, int *peof, void *dat) - * - * Assume that the buffer is "count" bytes in size. - * - * If you know you have supplied all the data you - * have, set *peof. - * - * You have three ways to return data: - * 0) Leave *start = NULL. (This is the default.) - * Put the data of the requested offset at that - * offset within the buffer. Return the number (n) - * of bytes there are from the beginning of the - * buffer up to the last byte of data. If the - * number of supplied bytes (= n - offset) is - * greater than zero and you didn't signal eof - * and the reader is prepared to take more data - * you will be called again with the requested - * offset advanced by the number of bytes - * absorbed. This interface is useful for files - * no larger than the buffer. - * 1) Set *start = an unsigned long value less than - * the buffer address but greater than zero. - * Put the data of the requested offset at the - * beginning of the buffer. Return the number of - * bytes of data placed there. If this number is - * greater than zero and you didn't signal eof - * and the reader is prepared to take more data - * you will be called again with the requested - * offset advanced by *start. This interface is - * useful when you have a large file consisting - * of a series of blocks which you want to count - * and return as wholes. - * (Hack by Paul.Russell@rustcorp.com.au) - * 2) Set *start = an address within the buffer. - * Put the data of the requested offset at *start. - * Return the number of bytes of data placed there. - * If this number is greater than zero and you - * didn't signal eof and the reader is prepared to - * take more data you will be called again with the - * requested offset advanced by the number of bytes - * absorbed. - */ - n = dp->read_proc(page, &start, *ppos, - count, &eof, dp->data); - } else + if (!dp->read_proc) break; + /* How to be a proc read function + * ------------------------------ + * Prototype: + * int f(char *buffer, char **start, off_t offset, + * int count, int *peof, void *dat) + * + * Assume that the buffer is "count" bytes in size. + * + * If you know you have supplied all the data you have, set + * *peof. + * + * You have three ways to return data: + * + * 0) Leave *start = NULL. (This is the default.) Put the + * data of the requested offset at that offset within the + * buffer. Return the number (n) of bytes there are from + * the beginning of the buffer up to the last byte of data. + * If the number of supplied bytes (= n - offset) is greater + * than zero and you didn't signal eof and the reader is + * prepared to take more data you will be called again with + * the requested offset advanced by the number of bytes + * absorbed. This interface is useful for files no larger + * than the buffer. + * + * 1) Set *start = an unsigned long value less than the buffer + * address but greater than zero. Put the data of the + * requested offset at the beginning of the buffer. Return + * the number of bytes of data placed there. If this number + * is greater than zero and you didn't signal eof and the + * reader is prepared to take more data you will be called + * again with the requested offset advanced by *start. This + * interface is useful when you have a large file consisting + * of a series of blocks which you want to count and return + * as wholes. + * (Hack by Paul.Russell@rustcorp.com.au) + * + * 2) Set *start = an address within the buffer. Put the data + * of the requested offset at *start. Return the number of + * bytes of data placed there. If this number is greater + * than zero and you didn't signal eof and the reader is + * prepared to take more data you will be called again with + * the requested offset advanced by the number of bytes + * absorbed. + */ + n = dp->read_proc(page, &start, *ppos, count, &eof, dp->data); + if (n == 0) /* end of file */ break; if (n < 0) { /* error */ |