summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorAlex Elder <elder@linaro.org>2014-07-31 09:28:37 +1000
committerStephen Rothwell <sfr@canb.auug.org.au>2014-07-31 09:28:37 +1000
commitc08f1e87c2f02d0916cf6bee5cdefc1cea7f8953 (patch)
tree97ab55283c735cb70669d06173e0abd57b63842b /kernel
parent159cd032d31b5f3e351981a64b2352f29c20b729 (diff)
downloadlinux-c08f1e87c2f02d0916cf6bee5cdefc1cea7f8953.tar.gz
printk: tweak do_syslog() to match comments
In do_syslog() there's a path used by kmsg_poll() and kmsg_read() that only needs to know whether there's any data available to read (and not its size). These callers only check for non-zero return. As a shortcut, do_syslog() returns the difference between what has been logged and what has been "seen." The comments say that the "count of records" should be returned but it's not. Instead it returns (log_next_idx - syslog_idx), which is a difference between buffer offsets--and the result could be negative. The behavior is the same (it'll be zero or not in the same cases), but the count of records is more meaningful and it matches what the comments say. So change the code to return that. Signed-off-by: Alex Elder <elder@linaro.org> Cc: Petr Mladek <pmladek@suse.cz> Cc: Jan Kara <jack@suse.cz> Cc: Joe Perches <joe@perches.com> Cc: John Stultz <john.stultz@linaro.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/printk/printk.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index f855ec36dff9..ec3bfb0b1f62 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1351,7 +1351,7 @@ int do_syslog(int type, char __user *buf, int len, bool from_file)
* for pending data, not the size; return the count of
* records, not the length.
*/
- error = log_next_idx - syslog_idx;
+ error = log_next_seq - syslog_seq;
} else {
u64 seq = syslog_seq;
u32 idx = syslog_idx;