Skip to contentSkip to conversation

printk: tweak do_syslog() to match comments

PATCH New Alex Elder 1 participant 1 message Jun 27, 2014 Printk

lore
Share & tools
lore

Alex Elder

author
#0 lore raw

PATCH 1/1 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.

---
This patch is also available here:
http://git.linaro.org/landing-teams/working/broadcom/kernel.git
Branch review/do_syslog_tweak

 kernel/printk/printk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/printk/printk.c +1 -1
index ea2d5f6..f4a92e8 100644
@@ -1310,7 +1310,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;
Signature · 1 line
1.9.1